Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Adding spec for target namespace in app CRD (#700)
Browse files Browse the repository at this point in the history
* add namespace spec

* update unittest

* fmt

* add generated files

* changelog

* address reviews

* regenerate (2)

* address review
  • Loading branch information
tomahawk28 authored Mar 15, 2021
1 parent bdb394c commit b114684
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 75 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `NamespaceConfig` spec to `App` CRD.

## [3.20.0] - 2021-03-15


- Add label `ui.giantswarm.io/display`.
- Add shortnames `org` and `orgs` for CRD `organizations.security.giantswarm.io`.
- Disallow generated IDs to start with digits.
Expand Down
20 changes: 20 additions & 0 deletions config/crd/v1/application.giantswarm.io_apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ spec:
description: Namespace is the namespace where the app should be deployed.
e.g. monitoring
type: string
namespaceConfig:
description: NamespaceConfig is the namespace config to be applied
to the target namespace when the app is deployed.
nullable: true
properties:
annotations:
additionalProperties:
type: string
description: Annotations is a string map of annotations to apply
to the target namespace.
nullable: true
type: object
labels:
additionalProperties:
type: string
description: Labels is a string map of labels to apply to the
target namespace.
nullable: true
type: object
type: object
userConfig:
description: UserConfig is the user config to be applied when the
app is deployed.
Expand Down
20 changes: 20 additions & 0 deletions config/crd/v1beta1/application.giantswarm.io_apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ spec:
description: Namespace is the namespace where the app should be deployed.
e.g. monitoring
type: string
namespaceConfig:
description: NamespaceConfig is the namespace config to be applied to
the target namespace when the app is deployed.
nullable: true
properties:
annotations:
additionalProperties:
type: string
description: Annotations is a string map of annotations to apply
to the target namespace.
nullable: true
type: object
labels:
additionalProperties:
type: string
description: Labels is a string map of labels to apply to the target
namespace.
nullable: true
type: object
type: object
userConfig:
description: UserConfig is the user config to be applied when the app
is deployed.
Expand Down
3 changes: 3 additions & 0 deletions docs/cr/application.giantswarm.io_v1alpha1_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
namespace: f2def
name: prometheus
namespace: monitoring
namespaceConfig:
annotations:
linkerd.io/inject: enabled
userConfig:
configMap:
name: prometheus-user-values
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/application/v1alpha1/app_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ type AppSpec struct {
Namespace string `json:"namespace"`
// +kubebuilder:validation:Optional
// +nullable
// NamespaceConfig is the namespace config to be applied to the target namespace when the app is deployed.
NamespaceConfig AppSpecNamespaceConfig `json:"namespaceConfig,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// UserConfig is the user config to be applied when the app is deployed.
UserConfig AppSpecUserConfig `json:"userConfig,omitempty"`
// Version is the version of the app that should be deployed.
Expand Down Expand Up @@ -160,6 +164,18 @@ type AppSpecKubeConfigSecret struct {
Namespace string `json:"namespace"`
}

// +k8s:openapi-gen=true
type AppSpecNamespaceConfig struct {
// +kubebuilder:validation:Optional
// +nullable
// Annotations is a string map of annotations to apply to the target namespace.
Annotations map[string]string `json:"annotations,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// Labels is a string map of labels to apply to the target namespace.
Labels map[string]string `json:"labels,omitempty"`
}

// +k8s:openapi-gen=true
type AppSpecUserConfig struct {
// +kubebuilder:validation:Optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/application/v1alpha1/app_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func newAppExampleCR() *App {
Namespace: "f2def",
},
},
NamespaceConfig: AppSpecNamespaceConfig{
Annotations: map[string]string{
"linkerd.io/inject": "enabled",
},
},
UserConfig: AppSpecUserConfig{
ConfigMap: AppSpecUserConfigConfigMap{
Name: "prometheus-user-values",
Expand Down
32 changes: 31 additions & 1 deletion pkg/apis/application/v1alpha1/zz_generated.deepcopy.go

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

152 changes: 78 additions & 74 deletions pkg/crd/internal/zz_generated.fs.go

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

0 comments on commit b114684

Please sign in to comment.