chore(label): new label "values-from"
This labels allow to use some environment variables from another service and use the configMap / secret instead of the original value. This is useful to avoid duplication of values for several variables.
This commit is contained in:
@@ -33,6 +33,7 @@ const (
|
||||
LabelCronJob Label = KatenaryLabelPrefix + "/cronjob"
|
||||
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||
LabelValueFrom Label = KatenaryLabelPrefix + "/values-from"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@@ -321,4 +321,36 @@
|
||||
mountPath: /opt
|
||||
init: cp -ra /var/www/html/* /opt
|
||||
|
||||
"values-from":
|
||||
short: "Add values from another service."
|
||||
long: |-
|
||||
This label allows adding values from another service to the current service.
|
||||
It avoid duplicating values, environment or secrets that should be the same.
|
||||
|
||||
The key is the value to be added, and the value is the "key" to fetch in the
|
||||
form `service_name.environment_name`.
|
||||
|
||||
type: "map[string]string"
|
||||
example: |-
|
||||
database:
|
||||
image: mariadb:10.5
|
||||
environment:
|
||||
MARIADB_USER: myuser
|
||||
MARIADB_PASSWORD: mypassword
|
||||
labels:
|
||||
# it can be a secret
|
||||
{{ .KatenaryPrefix }}/secrets: |-
|
||||
- DB_PASSWORD
|
||||
php:
|
||||
image: php:7.4-fpm
|
||||
environment:
|
||||
# it's duplicated in docker / podman
|
||||
DB_USER: myuser
|
||||
DB_PASSWORD: mypassword
|
||||
labels:
|
||||
# removes the duplicated, use the configMap and secrets from "database"
|
||||
{{ .KatenaryPrefix }}/values-from: |-
|
||||
DB_USER: database.MARIADB_USER
|
||||
DB_PASSWORD: database.MARIADB_PASSWORD
|
||||
|
||||
# vim: ft=gotmpl.yaml
|
||||
|
13
generator/labels/labelStructs/valueFrom.go
Normal file
13
generator/labels/labelStructs/valueFrom.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package labelStructs
|
||||
|
||||
import "gopkg.in/yaml.v3"
|
||||
|
||||
type ValueFrom map[string]string
|
||||
|
||||
func GetValueFrom(data string) (*ValueFrom, error) {
|
||||
vf := ValueFrom{}
|
||||
if err := yaml.Unmarshal([]byte(data), &vf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &vf, nil
|
||||
}
|
Reference in New Issue
Block a user