Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cadenmarchese committed Apr 29, 2024
1 parent a893321 commit 45a6eab
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 12 deletions.
3 changes: 1 addition & 2 deletions pkg/api/v20191231preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
},
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
if oc.Properties.ServicePrincipalProfile != nil {

Check failure on line 49 in pkg/api/v20191231preview/openshiftcluster_convert.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v20200430/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v20210901preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v20220401/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v20220401/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp
}

func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
if spp == nil {
return nil
}

valid := uuid.IsValid(spp.ClientID)
if !valid {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v20220904/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v20230701preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Properties.ServicePrincipalProfile != nil {
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
out.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
Expand Down
5 changes: 0 additions & 5 deletions pkg/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,10 @@ func (m *manager) Update(ctx context.Context) error {
steps.AuthorizationRetryingAction(m.fpAuthorizer, m.validateResources),
steps.Action(m.initializeKubernetesClients), // All init steps are first
steps.Action(m.initializeOperatorDeployer), // depends on kube clients
steps.Action(m.initializeClusterSPClients),
// Since ServicePrincipalProfile is now a pointer and our converters re-build the struct,
// our update path needs to enrich the doc with SPObjectID since it was overwritten by our API on put/patch.
steps.AuthorizationRetryingAction(m.fpAuthorizer, m.fixupClusterSPObjectID),

// TODO: this relies on an authorizer that isn't exposed in the manager
// struct, so we'll rebuild the fpAuthorizer and use the error catching
// to advance
steps.AuthorizationRetryingAction(m.fpAuthorizer, m.clusterSPObjectID),
// credentials rotation flow steps
steps.Action(m.createOrUpdateClusterServicePrincipalRBAC),
steps.Action(m.createOrUpdateDenyAssignment),
Expand Down

0 comments on commit 45a6eab

Please sign in to comment.