Skip to content

Commit 6f3c3c7

Browse files
Merge pull request #603 from mrWinston/OSD-24926-update-osdctl-wif-generation-to-polish-the-template
[OSD-24926] wif template generation fixes
2 parents 2cbdd86 + c15d39a commit 6f3c3c7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/openshift/osdctl/cmd/cost"
2727
"github.com/openshift/osdctl/cmd/env"
2828
"github.com/openshift/osdctl/cmd/hive"
29+
"github.com/openshift/osdctl/cmd/iampermissions"
2930
"github.com/openshift/osdctl/cmd/jira"
3031
"github.com/openshift/osdctl/cmd/jumphost"
3132
"github.com/openshift/osdctl/cmd/mc"
@@ -101,6 +102,7 @@ func NewCmdRoot(streams genericclioptions.IOStreams) *cobra.Command {
101102
rootCmd.AddCommand(servicelog.NewCmdServiceLog())
102103
rootCmd.AddCommand(setup.NewCmdSetup())
103104
rootCmd.AddCommand(swarm.Cmd)
105+
rootCmd.AddCommand(iampermissions.NewCmdIamPermissions())
104106

105107
// Add cost command to use AWS Cost Manager
106108
rootCmd.AddCommand(cost.NewCmdCost(streams, globalOpts))

pkg/policies/gcp.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package policies
22

33
import (
4+
"slices"
45
"strings"
56

67
cco "github.com/openshift/cloud-credential-operator/pkg/apis/cloudcredential/v1"
@@ -51,8 +52,11 @@ func CredentialsRequestToWifServiceAccount(credReq *cco.CredentialsRequest) (*Se
5152
}
5253

5354
if len(gcpSpec.Permissions) > 0 {
55+
roleId := strings.ReplaceAll(credReq.Name, "-", "_")
56+
roleId = roleId[:min(64, len(roleId))]
57+
slices.Sort(gcpSpec.Permissions)
5458
sa.Roles = append(sa.Roles, Role{
55-
Id: credReq.Name,
59+
Id: roleId,
5660
Kind: "Role",
5761
Permissions: gcpSpec.Permissions,
5862
Predefined: false,

pkg/policies/gcp_models.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ type ServiceAccount struct {
2323
}
2424

2525
type CredentialRequest struct {
26-
SecretRef SecretRef
27-
ServiceAccountNames []string
26+
SecretRef SecretRef `json:"secret_ref,omitempty"`
27+
ServiceAccountNames []string `json:"service_account_names,omitempty"`
2828
}
2929

3030
type SecretRef struct {
31-
Name string
32-
Namespace string
31+
Name string `json:"name,omitempty"`
32+
Namespace string `json:"namespace,omitempty"`
3333
}
3434

3535
func (s ServiceAccount) GetId() string {

0 commit comments

Comments
 (0)