From 9119dcfa541c921ee27f4d8b5bcaf837ed32abba Mon Sep 17 00:00:00 2001 From: Ritek <140505097+ritek01@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:03:43 +0530 Subject: [PATCH] fix:[ASSMT-265]: Move app-name to Migrator config. (#109) --- .gitignore | 2 ++ app.go | 17 ++++++++--------- docs/docs/spinnaker-migration/instructions.md | 10 ++++++---- main.go | 10 +++++----- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 186c246..3fd6f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ demo/ .vscode harness-upgrade + +.DS_Store \ No newline at end of file diff --git a/app.go b/app.go index 1dfa919..d447e97 100644 --- a/app.go +++ b/app.go @@ -54,26 +54,25 @@ func migrateApp(*cli.Context) error { } func migrateSpinnakerApplication() error { + log.Info("Starting the migration of Spinnaker application") authMethod := authBasic if len(migrationReq.Cert) > 0 { authMethod = authx509 } - + log.Info("Importing the application....") if len(migrationReq.SpinnakerHost) == 0 { - migrationReq.SpinnakerHost = TextInput("Please provide spinnaker host") + migrationReq.SpinnakerHost = TextInput("Please provide spinnaker host : ") } if len(migrationReq.SpinnakerAppName) == 0 { - migrationReq.SpinnakerAppName = TextInput("Please provide the Spinnaker application name") + migrationReq.SpinnakerAppName = TextInput("Please provide the Spinnaker application name : ") } - - log.Info("Importing the application....") logSpinnakerMigrationDetails(authMethod) - confirm := ConfirmInput("Do you want to proceed with application migration?") + confirm := ConfirmInput("Do you want to proceed?") if !confirm { log.Fatal("Aborting...") } if len(migrationReq.ProjectIdentifier) == 0 { - migrationReq.ProjectIdentifier = TextInput("Name of the Project - ") + migrationReq.ProjectIdentifier = TextInput("Name of the Project : ") } jsonBody, err := getAllPipelines(authMethod) @@ -97,8 +96,8 @@ func migrateSpinnakerApplication() error { if len(id) > 0 { log.Info("Project already exists with the given name") } else { - log.Info("Creating the project....") - if err := createAProject("default", migrationReq.ProjectIdentifier, formatString(migrationReq.ProjectIdentifier)); err != nil { + log.Info("Creating project....") + if err := createAProject(migrationReq.OrgIdentifier, migrationReq.ProjectIdentifier, formatString(migrationReq.ProjectIdentifier)); err != nil { log.Error(err) } } diff --git a/docs/docs/spinnaker-migration/instructions.md b/docs/docs/spinnaker-migration/instructions.md index 530dfd3..f882316 100644 --- a/docs/docs/spinnaker-migration/instructions.md +++ b/docs/docs/spinnaker-migration/instructions.md @@ -23,17 +23,19 @@ secret-scope: project connector-scope: project template-scope: project workflow-scope: project +app-name: SpinnakerAppName auth64: AUTH_TOKEN ``` ## Run command -`harness-upgrade --load migrator-config.yml app --app-name SpinnakerAppName` +`harness-upgrade --load migrator-config.yml app` ## You should get output like this with some prompts: ```shell -`INFO[2024-03-04T15:50:38-08:00] Importing the application.... +INFO[2024-03-04T15:50:38-08:00] Starting the migration of Spinnaker application +INFO[2024-03-04T15:50:38-08:00] Importing the application.... INFO[2024-03-04T15:50:38-08:00] Migration details: Platform: spinnaker @@ -42,6 +44,6 @@ Migration details: Pipeline Name: Authentication method: basic Insecure: false -? Do you want to proceed with application migration? Yes -INFO[2024-03-04T15:50:41-08:00] Spinnaker migration completed` +? Do you want to proceed? Yes +INFO[2024-03-04T15:50:41-08:00] Spinnaker migration completed ``` diff --git a/main.go b/main.go index 38786f9..ab9dfe4 100644 --- a/main.go +++ b/main.go @@ -357,6 +357,11 @@ func main() { Usage: "Base64 : in case Spinnaker uses basic auth.", Destination: &migrationReq.Auth64, }), + altsrc.NewStringFlag(&cli.StringFlag{ + Name: "app-name", + Usage: "Specifies Spinnaker Application from which pipelines to be migrated.", + Destination: &migrationReq.SpinnakerAppName, + }), } app := &cli.App{ Name: "harness-upgrade", @@ -430,11 +435,6 @@ func main() { Usage: "if set will migrate all workflows & pipelines", Destination: &migrationReq.AllAppEntities, }, - &cli.StringFlag{ - Name: "app-name", - Usage: "Specifies Spinnaker Application from which pipelines to be migrated.", - Destination: &migrationReq.SpinnakerAppName, - }, }, }, {