Skip to content

Commit

Permalink
add platformCredentialsSets to the supported configurationResources (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
linki authored Apr 12, 2024
1 parent 4156b43 commit b751578
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 8 deletions.
23 changes: 20 additions & 3 deletions docs/stack_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ spec:
- metrics
type: object
configurationResources:
description: ConfigurationResources describes the ConfigMaps that
will be created. Later Secrets and PlatformCredentialSets will also
be defined on ConfigurationResources
description: ConfigurationResources describes the ConfigMaps, Secrets,
and/or PlatformCredentialsSet that will be created.
items:
description: ConfigurationResourcesSpec makes it possible to defined
the config resources to be created
Expand Down Expand Up @@ -377,6 +376,24 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
platformCredentialsSet:
description: PlatformCredentialsSet to be created and owned
by Stack
properties:
name:
type: string
tokens:
additionalProperties:
properties:
privileges:
items:
type: string
type: array
required:
- privileges
type: object
type: object
type: object
secretRef:
description: SecretRef is a reference to a Secret to be owned
by Stack
Expand Down
23 changes: 20 additions & 3 deletions docs/stackset_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,8 @@ spec:
- metrics
type: object
configurationResources:
description: ConfigurationResources describes the ConfigMaps
that will be created. Later Secrets and PlatformCredentialSets
will also be defined on ConfigurationResources
description: ConfigurationResources describes the ConfigMaps,
Secrets, and/or PlatformCredentialsSet that will be created.
items:
description: ConfigurationResourcesSpec makes it possible
to defined the config resources to be created
Expand Down Expand Up @@ -655,6 +654,24 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
platformCredentialsSet:
description: PlatformCredentialsSet to be created and
owned by Stack
properties:
name:
type: string
tokens:
additionalProperties:
properties:
privileges:
items:
type: string
type: array
required:
- privileges
type: object
type: object
type: object
secretRef:
description: SecretRef is a reference to a Secret to
be owned by Stack
Expand Down
6 changes: 6 additions & 0 deletions e2e/apply/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ spec:
name: e2e-deploy-sample-{{{CDP_BUILD_VERSION}}}-my-reference-config
- secretRef:
name: e2e-deploy-sample-{{{CDP_BUILD_VERSION}}}-my-reference-secret
- platformCredentialsSet:
name: e2e-deploy-sample-{{{CDP_BUILD_VERSION}}}-my-pcs
tokens:
sample-token:
privileges:
- com.zalando::foobar.read
autoscaler:
minReplicas: 2
maxReplicas: 2
Expand Down
23 changes: 21 additions & 2 deletions pkg/apis/zalando.org/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ type StackSpec struct {
// Strategy describe the rollout strategy for the underlying deployment
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`

// ConfigurationResources describes the ConfigMaps that will be created.
// Later Secrets and PlatformCredentialSets will also be defined on ConfigurationResources
// ConfigurationResources describes the ConfigMaps, Secrets, and/or
// PlatformCredentialsSet that will be created.
ConfigurationResources []ConfigurationResourcesSpec `json:"configurationResources,omitempty"`
}

Expand All @@ -449,6 +449,16 @@ type ConfigurationResourcesSpec struct {

// SecretRef is a reference to a Secret to be owned by Stack
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`

// PlatformCredentialsSet to be created and owned by Stack
PlatformCredentialsSet *PCS `json:"platformCredentialsSet,omitempty"`
}

// PCS is the PlatformCredentialsSet definition for a stack
// +k8s:deepcopy-gen=true
type PCS struct {
Name string `json:"name,omitempty"`
Tokens map[string]Token `json:"tokens,omitempty"`
}

// GetName returns the name of the ConfigurationResourcesSpec.
Expand All @@ -465,6 +475,10 @@ func (crs *ConfigurationResourcesSpec) GetName() string {
return crs.SecretRef.Name
}

if crs.IsPlatformCredentialsSet() {
return crs.PlatformCredentialsSet.Name
}

return ""
}

Expand All @@ -483,6 +497,11 @@ func (crs *ConfigurationResourcesSpec) IsSecretRef() bool {
return crs.SecretRef != nil && crs.SecretRef.Name != ""
}

// IsPlatformCredentialsSet returns true if the ConfigurationResourcesSpec is an inline PlatformCredentialsSet.
func (crs *ConfigurationResourcesSpec) IsPlatformCredentialsSet() bool {
return crs.PlatformCredentialsSet != nil && crs.PlatformCredentialsSet.Name != ""
}

// ConfigMap holds the name and data of an inline ConfigMap.
// +k8s:deepcopy-gen=true
type ConfigMap struct {
Expand Down
28 changes: 28 additions & 0 deletions pkg/apis/zalando.org/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b751578

Please sign in to comment.