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

feat: Change types for infrastructure stack CRD files/environment #988

Merged
merged 3 commits into from
May 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,79 @@ spec:
environment:
items:
properties:
configMapRef:
description: Selects a key from a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the ConfigMap or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
name:
type: string
secret:
type: boolean
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
value:
type: string
required:
- name
- value
type: object
type: array
files:
description: Files reference to ConfigMaps with a key as a path and
value as a content
description: Files reference to Secret with a key as a part of mount
path and value as a content
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
mountPath:
type: string
secretRef:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
type: object
x-kubernetes-map-type: atomic
required:
- mountPath
- secretRef
type: object
x-kubernetes-map-type: atomic
type: array
git:
description: Git reference w/in the repository where the IaC lives
Expand Down Expand Up @@ -318,23 +364,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
secretFiles:
description: SecretFiles reference to Secrets with a key as a path
and value as a content
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
type: object
x-kubernetes-map-type: atomic
type: array
type:
description: Type specifies the tool to use to apply it
enum:
Expand Down
20 changes: 10 additions & 10 deletions controller/api/v1alpha1/infrastructurestack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ type InfrastructureStackSpec struct {
// +kubebuilder:validation:Optional
Environment []StackEnvironment `json:"environment,omitempty"`

// Files reference to ConfigMaps with a key as a path and value as a content
// Files reference to Secret with a key as a part of mount path and value as a content
// +kubebuilder:validation:Optional
Files []corev1.LocalObjectReference `json:"files,omitempty"`
// SecretFiles reference to Secrets with a key as a path and value as a content
// +kubebuilder:validation:Optional
SecretFiles []corev1.LocalObjectReference `json:"secretFiles,omitempty"`
Files []StackFile `json:"files,omitempty"`

// Detach determined if user want to delete or detach stack
Detach bool `json:"detach"`
Expand Down Expand Up @@ -105,8 +102,8 @@ func init() {
}

type StackFile struct {
Path string `json:"path"`
Content string `json:"content"`
MountPath string `json:"mountPath"`
SecretRef corev1.LocalObjectReference `json:"secretRef"`
}

type StackConfiguration struct {
Expand All @@ -118,10 +115,13 @@ type StackConfiguration struct {
}

type StackEnvironment struct {
Name string `json:"name"`
Value string `json:"value"`
Name string `json:"name"`
// +kubebuilder:validation:Optional
Value *string `json:"value,omitempty"`
// +kubebuilder:validation:Optional
SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef,omitempty"`
// +kubebuilder:validation:Optional
Secret *bool `json:"secret,omitempty"`
ConfigMapRef *corev1.ConfigMapKeySelector `json:"configMapRef,omitempty"`
}

func (p *InfrastructureStack) StackName() string {
Expand Down
24 changes: 15 additions & 9 deletions controller/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,79 @@ spec:
environment:
items:
properties:
configMapRef:
description: Selects a key from a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the ConfigMap or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
name:
type: string
secret:
type: boolean
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
value:
type: string
required:
- name
- value
type: object
type: array
files:
description: Files reference to ConfigMaps with a key as a path and
value as a content
description: Files reference to Secret with a key as a part of mount
path and value as a content
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
mountPath:
type: string
secretRef:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
type: object
x-kubernetes-map-type: atomic
required:
- mountPath
- secretRef
type: object
x-kubernetes-map-type: atomic
type: array
git:
description: Git reference w/in the repository where the IaC lives
Expand Down Expand Up @@ -318,23 +364,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
secretFiles:
description: SecretFiles reference to Secrets with a key as a path
and value as a content
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
type: object
x-kubernetes-map-type: atomic
type: array
type:
description: Type specifies the tool to use to apply it
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: existing
namespace: default
spec:
handle: mgmt
handle: lukasz
---
apiVersion: deployments.plural.sh/v1alpha1
kind: GitRepository
Expand All @@ -15,13 +15,12 @@ spec:
url: https://github.com/zreigz/tf-hello.git
---
apiVersion: v1
kind: ConfigMap
kind: Secret
metadata:
name: infrastructurestack
namespace: default
data:
your-file.json: |
{key1: value1, key2: value2, keyN: valueN}
secret: dGVzdA==
---
apiVersion: deployments.plural.sh/v1alpha1
kind: InfrastructureStack
Expand Down Expand Up @@ -50,8 +49,15 @@ spec:
ref: main
folder: terraform
files:
- name: infrastructurestack
- mountPath: /tmp
secretRef:
name: infrastructurestack
environment:
- name: test
- name: TEST
value: test
- name: SECRET
secretKeyRef:
name: infrastructurestack
key: secret


Loading
Loading