Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KIM Integration - setting default values - fix #1178

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions internal/process/provisioning/create_runtime_resource_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,15 @@ func (s *CreateRuntimeResourceStep) createNetworkingConfiguration(operation inte
networkingParams = &internal.NetworkingDTO{}
}

nodes := networking.DefaultNodesCIDR
if networkingParams.NodesCidr != "" {
nodes = networkingParams.NodesCidr
}

return imv1.Networking{
Pods: DefaultIfParamNotSet(networking.DefaultPodsCIDR, networkingParams.PodsCidr),
Services: DefaultIfParamNotSet(networking.DefaultServicesCIDR, networkingParams.ServicesCidr),
Nodes: DefaultIfParamZero(networking.DefaultNodesCIDR, networkingParams.NodesCidr),
Nodes: nodes,
//TODO remove when KIM is ready with setting this value
Type: ptr.String("calico"),
}
Expand Down Expand Up @@ -307,12 +312,24 @@ func (s *CreateRuntimeResourceStep) createKubernetesConfiguration(operation inte
UsernamePrefix: &s.oidcDefaultValues.UsernamePrefix,
}
if operation.ProvisioningParameters.Parameters.OIDC != nil {
oidc.SigningAlgs = DefaultIfParamZero(oidc.SigningAlgs, operation.ProvisioningParameters.Parameters.OIDC.SigningAlgs)
oidc.ClientID = DefaultIfParamZero(oidc.ClientID, &operation.ProvisioningParameters.Parameters.OIDC.ClientID)
oidc.GroupsClaim = DefaultIfParamZero(oidc.GroupsClaim, &operation.ProvisioningParameters.Parameters.OIDC.GroupsClaim)
oidc.IssuerURL = DefaultIfParamZero(oidc.IssuerURL, &operation.ProvisioningParameters.Parameters.OIDC.IssuerURL)
oidc.UsernameClaim = DefaultIfParamZero(oidc.UsernameClaim, &operation.ProvisioningParameters.Parameters.OIDC.UsernameClaim)
oidc.UsernamePrefix = DefaultIfParamZero(oidc.UsernamePrefix, &operation.ProvisioningParameters.Parameters.OIDC.UsernamePrefix)
if operation.ProvisioningParameters.Parameters.OIDC.ClientID != "" {
oidc.ClientID = &operation.ProvisioningParameters.Parameters.OIDC.ClientID
}
if operation.ProvisioningParameters.Parameters.OIDC.GroupsClaim != "" {
oidc.GroupsClaim = &operation.ProvisioningParameters.Parameters.OIDC.GroupsClaim
}
if operation.ProvisioningParameters.Parameters.OIDC.IssuerURL != "" {
oidc.IssuerURL = &operation.ProvisioningParameters.Parameters.OIDC.IssuerURL
}
if len(operation.ProvisioningParameters.Parameters.OIDC.SigningAlgs) > 0 {
oidc.SigningAlgs = operation.ProvisioningParameters.Parameters.OIDC.SigningAlgs
}
if operation.ProvisioningParameters.Parameters.OIDC.UsernameClaim != "" {
oidc.UsernameClaim = &operation.ProvisioningParameters.Parameters.OIDC.UsernameClaim
}
if operation.ProvisioningParameters.Parameters.OIDC.UsernamePrefix != "" {
oidc.UsernamePrefix = &operation.ProvisioningParameters.Parameters.OIDC.UsernamePrefix
}
}

return imv1.Kubernetes{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,36 @@ func Test_Defaults(t *testing.T) {
assert.Equal(t, "initial value", nonEmpty)
}

func Test_DefaultsOnActualStructures(t *testing.T) {
//given
_, operation := fixInstanceAndOperation(broker.AzurePlanID, "westeurope", "platform-region")
oidc := defaultOIDSConfig

//when
operation.ProvisioningParameters.Parameters.OIDC = &internal.OIDCConfigDTO{
ClientID: "",
GroupsClaim: "gc-custom",
IssuerURL: "issuer-url-custom",
SigningAlgs: []string{},
UsernameClaim: "",
UsernamePrefix: "up-custom",
}

oidc.ClientID = DefaultIfParamZero(defaultOIDSConfig.ClientID, operation.ProvisioningParameters.Parameters.OIDC.ClientID)
oidc.GroupsClaim = DefaultIfParamZero(defaultOIDSConfig.GroupsClaim, operation.ProvisioningParameters.Parameters.OIDC.GroupsClaim)
oidc.IssuerURL = DefaultIfParamZero(defaultOIDSConfig.IssuerURL, operation.ProvisioningParameters.Parameters.OIDC.IssuerURL)
oidc.UsernameClaim = DefaultIfParamZero(defaultOIDSConfig.UsernameClaim, operation.ProvisioningParameters.Parameters.OIDC.UsernameClaim)
oidc.UsernamePrefix = DefaultIfParamZero(defaultOIDSConfig.UsernamePrefix, operation.ProvisioningParameters.Parameters.OIDC.UsernamePrefix)

//then
assert.Len(t, oidc.SigningAlgs, 1)
assert.Equal(t, defaultOIDSConfig.ClientID, oidc.ClientID)
assert.Equal(t, "gc-custom", oidc.GroupsClaim)
assert.Equal(t, "issuer-url-custom", oidc.IssuerURL)
assert.Equal(t, defaultOIDSConfig.UsernameClaim, oidc.UsernameClaim)
assert.Equal(t, "up-custom", oidc.UsernamePrefix)
}

// assertions

func assertSecurityWithDefaultAdministrator(t *testing.T, runtime imv1.Runtime) {
Expand Down
Loading