-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code by moving them into separate files (#3)
- Loading branch information
1 parent
f7028b6
commit 0c58c14
Showing
16 changed files
with
467 additions
and
282 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/urfave/cli/v2" | ||
"os" | ||
) | ||
|
||
func migrateAccountLevelEntities(*cli.Context) error { | ||
log.Info("Migrating all account level entities like secret managers, secrets, connectors.") | ||
promptConfirm := PromptDefaultInputs() | ||
// Based on the scopes of entities determine the destination details | ||
promptConfirm = PromptOrgAndProject([]string{migrationReq.SecretScope, migrationReq.ConnectorScope}) || promptConfirm | ||
logMigrationDetails() | ||
|
||
// We confirm if they wish to proceed or not | ||
if promptConfirm { | ||
confirm := ConfirmInput("Do you wish to proceed importing all secret managers, secrets & connectors?") | ||
if !confirm { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
// Finally Make the API calls to create all entities | ||
url := GetUrl(migrationReq.Environment, "save/v2", migrationReq.Account) | ||
|
||
// Create Secret Managers | ||
log.Info("Importing all secret managers from CG to NG...") | ||
CreateEntity(url, migrationReq.Auth, getReqBody(SecretManager, Filter{ | ||
Type: All, | ||
})) | ||
log.Info("Imported all secret managers.") | ||
|
||
// Create Secrets | ||
log.Info("Importing all secrets from CG to NG...") | ||
CreateEntity(url, migrationReq.Auth, getReqBody(Secret, Filter{ | ||
Type: All, | ||
})) | ||
log.Info("Imported all secrets.") | ||
|
||
// Create Connectors | ||
log.Info("Importing all connectors from CG to NG....") | ||
CreateEntity(url, migrationReq.Auth, getReqBody(Connector, Filter{ | ||
Type: All, | ||
})) | ||
log.Info("Imported all connectors.") | ||
|
||
return nil | ||
} |
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,35 @@ | ||
package main | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func migrateApp(*cli.Context) error { | ||
promptConfirm := PromptDefaultInputs() | ||
if len(migrationReq.AppId) == 0 { | ||
promptConfirm = true | ||
migrationReq.AppId = TextInput("Please provide the application ID of the app that you wish to import -") | ||
} | ||
|
||
promptConfirm = PromptOrgAndProject([]string{migrationReq.SecretScope, migrationReq.ConnectorScope, migrationReq.TemplateScope}) || promptConfirm | ||
|
||
logMigrationDetails() | ||
|
||
if promptConfirm { | ||
confirm := ConfirmInput("Do you want to proceed with app migration?") | ||
if !confirm { | ||
log.Fatal("Aborting...") | ||
} | ||
} | ||
|
||
url := GetUrl(migrationReq.Environment, "save/v2", migrationReq.Account) | ||
// Migrating the app | ||
log.Info("Importing the application....") | ||
CreateEntity(url, migrationReq.Auth, getReqBody(Application, Filter{ | ||
AppId: migrationReq.AppId, | ||
})) | ||
log.Info("Imported the application.") | ||
|
||
return nil | ||
} |
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
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
Oops, something went wrong.