Skip to content

Commit

Permalink
Add role prefix flag on create wif-config (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobGray committed Aug 28, 2024
1 parent ac42b5c commit 65bf8cf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
16 changes: 11 additions & 5 deletions cmd/ocm/gcp/create-wif-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import (
var (
// CreateWifConfigOpts captures the options that affect creation of the workload identity configuration
CreateWifConfigOpts = options{
DryRun: false,
Name: "",
Project: "",
TargetDir: "",
DryRun: false,
Name: "",
Project: "",
RolePrefix: "",
TargetDir: "",
}
)

Expand All @@ -54,6 +55,8 @@ func NewCreateWorkloadIdentityConfiguration() *cobra.Command {
createWifConfigCmd.PersistentFlags().StringVar(&CreateWifConfigOpts.Project, "project", "",
"ID of the Google cloud project")
createWifConfigCmd.MarkPersistentFlagRequired("project")
createWifConfigCmd.PersistentFlags().StringVar(&CreateWifConfigOpts.RolePrefix, "role-prefix", "",
"Prefix for naming custom roles")
createWifConfigCmd.PersistentFlags().BoolVar(&CreateWifConfigOpts.DryRun, "dry-run", false,
"Skip creating objects, and just save what would have been created into files")
createWifConfigCmd.PersistentFlags().StringVar(&CreateWifConfigOpts.TargetDir, "output-dir", "",
Expand Down Expand Up @@ -157,9 +160,12 @@ func createWorkloadIdentityConfiguration(client gcp.GcpClient, displayName, proj
ProjectId(projectId).
ProjectNumber(strconv.FormatInt(projectNum, 10))

wifBuilder.DisplayName(displayName)
if CreateWifConfigOpts.RolePrefix != "" {
gcpBuilder.RolePrefix(CreateWifConfigOpts.RolePrefix)
}
wifBuilder.Gcp(gcpBuilder)

wifBuilder.DisplayName(displayName)
wifConfigInput, err := wifBuilder.Build()
if err != nil {
return nil, errors.Wrap(err, "failed to build WIF config")
Expand Down
1 change: 1 addition & 0 deletions cmd/ocm/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type options struct {
Region string
Name string
Project string
RolePrefix string
WorkloadIdentityPool string
WorkloadIdentityProvider string
DryRun bool
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/nwidger/jsoncolor v0.3.2
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/openshift-online/ocm-sdk-go v0.1.434
github.com/openshift-online/ocm-sdk-go v0.1.437
github.com/openshift/rosa v1.2.24
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
github.com/openshift-online/ocm-sdk-go v0.1.434 h1:5AbNG+Nci9Z3AaT6qzkK2QG/u1RpeJHjE5YcWqtU4rw=
github.com/openshift-online/ocm-sdk-go v0.1.434/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/openshift-online/ocm-sdk-go v0.1.437 h1:2xFFOu3lvrrA0wfz4zUmX7UxcWQvqfbgBWelLLB5T2I=
github.com/openshift-online/ocm-sdk-go v0.1.437/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/openshift/rosa v1.2.24 h1:vv0yYnWHx6CCPEAau/0rS54P2ksaf+uWXb1TQPWxiYE=
github.com/openshift/rosa v1.2.24/go.mod h1:MVXB27O3PF8WoOic23I03mmq6/9kVxpFx6FKyLMCyrQ=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
Expand Down

0 comments on commit 65bf8cf

Please sign in to comment.