Skip to content

Commit

Permalink
fix:[ASSMT-265]: Move app-name to Migrator config. (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritek01 authored Mar 18, 2024
1 parent 63d3c9d commit 9119dcf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ demo/
.vscode

harness-upgrade

.DS_Store
17 changes: 8 additions & 9 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
Expand Down
10 changes: 6 additions & 4 deletions docs/docs/spinnaker-migration/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ func main() {
Usage: "Base64 <username>:<password> 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",
Expand Down Expand Up @@ -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,
},
},
},
{
Expand Down

0 comments on commit 9119dcf

Please sign in to comment.