Skip to content

Commit

Permalink
Support user group migration to project & org scopes (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
puthrayaharness authored May 25, 2023
1 parent 3640545 commit 61c2191
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/docs/upgrade/user-groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Use the following command -
```shell
harness-upgrade --api-key SAT_API_KEY --account ACCOUNT_ID --env ENV user-groups
```

Use the below command if you want to scope the user groups to a specific org or project.

```shell
harness-upgrade --api-key SAT_API_KEY --account ACCOUNT_ID --env ENV --org ORG --project PROJECT --user-group-scope SCOPE user-groups
```
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var migrationReq = struct {
WorkflowScope string `survey:"workflowScope"`
PipelineScope string `survey:"pipelineScope"`
TemplateScope string `survey:"templateScope"`
UserGroupScope string `survey:"userGroupScope"`
OrgIdentifier string `survey:"org"`
ProjectIdentifier string `survey:"project"`
AppId string `survey:"appId"`
Expand Down Expand Up @@ -63,6 +64,7 @@ func getReqBody(entityType EntityType, filter Filter) RequestBody {
Connector: EntityDefaults{Scope: getOrDefault(migrationReq.ConnectorScope, Project)},
Template: EntityDefaults{Scope: getOrDefault(migrationReq.TemplateScope, Project)},
Workflow: EntityDefaults{Scope: getOrDefault(migrationReq.WorkflowScope, Project), WorkflowAsPipeline: migrationReq.AsPipelines},
UserGroup: EntityDefaults{Scope: getOrDefault(migrationReq.UserGroupScope, Account)},
},
}
destination := DestinationDetails{ProjectIdentifier: migrationReq.ProjectIdentifier, OrgIdentifier: migrationReq.OrgIdentifier, AccountIdentifier: migrationReq.TargetAccount, AuthToken: migrationReq.TargetAuthToken}
Expand Down Expand Up @@ -161,6 +163,11 @@ func main() {
Usage: "`SCOPE` to create templates in. Possible values - account, org, project",
Destination: &migrationReq.TemplateScope,
}),
altsrc.NewStringFlag(&cli.StringFlag{
Name: "user-group-scope",
Usage: "`SCOPE` to create user groups in. Possible values - account, org, project",
Destination: &migrationReq.UserGroupScope,
}),
altsrc.NewStringFlag(&cli.StringFlag{
Name: "org",
Usage: "organisation `IDENTIFIER` in next gen",
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Defaults struct {
Connector EntityDefaults `json:"CONNECTOR"`
Workflow EntityDefaults `json:"WORKFLOW"`
Template EntityDefaults `json:"TEMPLATE"`
UserGroup EntityDefaults `json:"USER_GROUP"`
}

type Inputs struct {
Expand Down

0 comments on commit 61c2191

Please sign in to comment.