Skip to content

Commit

Permalink
Add configs section to App CRD (#38)
Browse files Browse the repository at this point in the history
* Add configs section to App CRD

* Update CHANGELOG.md

* Add configs section to App CRD struct definition

* Add updated description for repositories field of Catalog CRD to the struct as well

* Regenerate App CRD yaml and deepcopy

* Add priority field to App CRD extraConfigs

* Regenerate App CRD yaml and deepcopy

* Ignore unused constants about App CRD config layer priority levels

These will be used in merging logics and makes sense to keep with the actual
configuration.

* Set configMap as the default value for kind of extra config entries of App CRD
  • Loading branch information
uvegla authored Jul 1, 2022
1 parent ddc8656 commit 0f9c9db
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `configs` section to `App` CRD based on RFC: https://github.com/giantswarm/rfc/tree/main/multi-layer-app-config#enhancing-app-cr

## [0.4.1] - 2022-06-30

## [0.4.1] - 2022-06-30
Expand Down
33 changes: 33 additions & 0 deletions api/v1alpha1/app_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import (
const (
kindApp = "App"
appDocumentationLink = "https://docs.giantswarm.io/ui-api/management-api/crd/apps.application.giantswarm.io/"

// NOTE: These should match the kubebuilder annotations set on AppExtraConfig
configPriorityDistance = 50
configPriorityCatalog = 0
configPriorityDefault = configPriorityCatalog + configPriorityDistance/2 //nolint
configPriorityCluster = configPriorityCatalog + configPriorityDistance
configPriorityUser = configPriorityCluster + configPriorityDistance
configPriorityMaximum = configPriorityUser + configPriorityDistance //nolint
)

func NewAppTypeMeta() metav1.TypeMeta {
Expand Down Expand Up @@ -68,6 +76,11 @@ type AppSpec struct {
Config AppSpecConfig `json:"config,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// ExtraConfigs is a list of configurations to merge together based on the priority and order in the list.
// See: https://github.com/giantswarm/rfc/tree/main/multi-layer-app-config#enhancing-app-cr
ExtraConfigs []AppExtraConfig `json:"extraConfigs,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// Install is the config used when installing the app.
Install AppSpecInstall `json:"install,omitempty"`
// KubeConfig is the kubeconfig to connect to the cluster when deploying
Expand Down Expand Up @@ -106,6 +119,26 @@ type AppSpecConfig struct {
Secret AppSpecConfigSecret `json:"secret,omitempty"`
}

// +k8s:openapi-gen=true
type AppExtraConfig struct {
// +optional
// +kubebuilder:validation:Enum=configMap;secret
// +kubebuilder:default:=configMap
// Kind of configuration to look up that should be applied to the app when deployed.
Kind string `json:"kind"`
// Name of the resource of the given kind to look up.
Name string `json:"name"`
// Namespace where the resource with the given name and kind to look up is located.
Namespace string `json:"namespace"`
// +optional
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Maximum:=150
// +kubebuilder:default:=25
// Priority is used to indicate at which stage the extra configuration should be merged.
// See: https://github.com/giantswarm/rfc/tree/main/multi-layer-app-config#enhancing-app-cr
Priority int `json:"priority"`
}

// +k8s:openapi-gen=true
type AppSpecInstall struct {
// +kubebuilder:validation:Optional
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/catalog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ type CatalogSpec struct {
Config *CatalogSpecConfig `json:"config,omitempty"`
// LogoURL contains the links for logo image file for this catalog
LogoURL string `json:"logoURL"`
// Storage references an object defining catalog repository. Will be
// deprecated. Replaced by Repositories.
// Storage references an object defining catalog repository.
// This field is deprecated and replaced by Repositories.
Storage CatalogSpecStorage `json:"storage"`
// +kubebuilder:validation:MinItems=1
// Repositories is an array of objects defining catalog repositories.
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

34 changes: 34 additions & 0 deletions config/crd/application.giantswarm.io_apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ spec:
- namespace
type: object
type: object
extraConfigs:
description: 'ExtraConfigs is a list of configurations to merge together
based on the priority and order in the list. See: https://github.com/giantswarm/rfc/tree/main/multi-layer-app-config#enhancing-app-cr'
items:
properties:
kind:
default: configMap
description: Kind of configuration to look up that should be
applied to the app when deployed.
enum:
- configMap
- secret
type: string
name:
description: Name of the resource of the given kind to look
up.
type: string
namespace:
description: Namespace where the resource with the given name
and kind to look up is located.
type: string
priority:
default: 25
description: 'Priority is used to indicate at which stage the
extra configuration should be merged. See: https://github.com/giantswarm/rfc/tree/main/multi-layer-app-config#enhancing-app-cr'
maximum: 150
minimum: 0
type: integer
required:
- name
- namespace
type: object
nullable: true
type: array
install:
description: Install is the config used when installing the app.
nullable: true
Expand Down

0 comments on commit 0f9c9db

Please sign in to comment.