Skip to content

Commit

Permalink
Support migration of just Services (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
puthrayaharness authored Mar 23, 2023
1 parent 6a61045 commit 23d03fe
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ To migrate an application and all the workflows & pipelines
harness-upgrade app --all
```

To migrate services from an app
```shell
harness-upgrade service
```

To migrate workflows
```shell
harness-upgrade workflows
Expand Down Expand Up @@ -118,6 +123,12 @@ HARNESS_MIGRATOR_AUTH=apiKey harness-upgrade --project PROJECT --org ORG --accou
HARNESS_MIGRATOR_AUTH=apiKey harness-upgrade --app APP_ID --project PROJECT --org ORG --account ACCOUNT_ID --secret-scope SCOPE --connector-scope SCOPE --template-scope SCOPE --env ENV app
```

### To migrate services

```shell
HARNESS_MIGRATOR_AUTH=apiKey harness-upgrade --app APP_ID --project PROJECT --org ORG --account ACCOUNT_ID --secret-scope SCOPE --connector-scope SCOPE --template-scope SCOPE --env ENV service
```

### To migrate workflows

```shell
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ func main() {
},
},
},
{
Name: "service",
Usage: "Import services into an existing project from an application",
Action: func(context *cli.Context) error {
return cliWrapper(migrateServices, context)
},
},
{
Name: "workflows",
Usage: "Import workflows as stage or pipeline templates by providing the `appId` & `workflowIds`",
Expand Down
33 changes: 33 additions & 0 deletions services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)

func migrateServices(*cli.Context) error {
promptConfirm := PromptDefaultInputs()
if len(migrationReq.AppId) == 0 {
promptConfirm = true
migrationReq.AppId = TextInput("Please provide the application ID -")
}

promptConfirm = PromptOrgAndProject([]string{Project}) || promptConfirm

logMigrationDetails()

if promptConfirm {
confirm := ConfirmInput("Do you want to proceed?")
if !confirm {
log.Fatal("Aborting...")
}
}

log.Info("Importing the services....")
CreateEntities(getReqBody(Service, Filter{
AppId: migrationReq.AppId,
}))
log.Info("Imported the services.")

return nil
}

0 comments on commit 23d03fe

Please sign in to comment.