-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storage functions for the migration phases (#6529)
* Get organisation API changes added Signed-off-by: sonali wale <sonali.wale@progress.com> * minor changes added Signed-off-by: sonali wale <sonali.wale@progress.com> * Remove command to create an orgs Signed-off-by: sonali wale <sonali.wale@progress.com> * Client Mock changes Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com> * Storage function for all the phases of migration Signed-off-by: sonali wale <sonali.wale@progress.com> * Minor changes added Signed-off-by: sonali wale <sonali.wale@progress.com> * Incorporated review comments Signed-off-by: sonali wale <sonali.wale@progress.com> * Minor changes added Signed-off-by: sonali wale <sonali.wale@progress.com> * Changes for review comments Signed-off-by: sonali wale <sonali.wale@progress.com> * Comments removed Signed-off-by: sonali wale <sonali.wale@progress.com> Co-authored-by: Yashvi Jain <Yashvi.jain@progress.com>
- Loading branch information
Showing
16 changed files
with
495 additions
and
137 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,48 @@ | ||
package constants | ||
|
||
// MigrationPhase: enum of migration phases | ||
type MigrationPhase int64 | ||
|
||
// Migration phases id should be between 100 & 5000 | ||
const ( | ||
StartMigration = 100 | ||
CompleteMigration = 5000 | ||
) | ||
|
||
// MigrationStatus: enum of migration status | ||
type MigrationStatus int64 | ||
|
||
// IAM default project ID | ||
const ( | ||
UnassignedProjectID = "(unassigned)" | ||
) | ||
|
||
const ( | ||
StartFileUpload MigrationPhase = iota + 1000 | ||
CompleteFileUpload | ||
FailedFileUpload | ||
StartUnzip | ||
ComplteUnzip | ||
FailedUnzip | ||
StartZipParsing | ||
CompleteZipParsing | ||
FailedZipParsing | ||
StartOrgMigration | ||
CompleteOrgMigration | ||
FailedOrgMigration | ||
StartUserMigration | ||
CompleteUserMigration | ||
FailedUserMigration | ||
StartAssciation | ||
CompleteAssciation | ||
FailedAssciation | ||
StartPermissionMigration | ||
CompletePermissionMigration | ||
FailedPermissionMigration | ||
) | ||
|
||
const ( | ||
InProgress MigrationStatus = iota + 100 | ||
Completed | ||
Failed | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package server | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
secrets "github.com/chef/automate/api/external/secrets" | ||
"github.com/chef/automate/components/infra-proxy-service/service" | ||
) | ||
|
||
var IsMigrationAlreadyRunning bool | ||
|
||
func setMigrationStatus(status bool) { | ||
IsMigrationAlreadyRunning = status | ||
} | ||
|
||
// getChefClient: creates the chef client | ||
func (s *Server) getChefClient(ctx context.Context, serverId string) (*ChefClient, error) { | ||
// Get the credential ID from servers table | ||
server, err := s.service.Storage.GetServer(ctx, serverId) | ||
if err != nil { | ||
return nil, service.ParseStorageError(err, serverId, "server") | ||
} | ||
if server.CredentialID == "" { | ||
return nil, errors.New("webui key is not available with server") | ||
} | ||
// Get web ui key from secrets service | ||
secret, err := s.service.Secrets.Read(ctx, &secrets.Id{Id: server.CredentialID}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
c, err := s.createChefServerClient(ctx, serverId, GetAdminKeyFrom(secret), "pivotal", true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c, nil | ||
} |
Oops, something went wrong.