Skip to content
parameter.go 3.2 KiB
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
/*

Timothee Gosselin's avatar
Timothee Gosselin committed
Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (the "License");
Timothee Gosselin's avatar
Timothee Gosselin committed
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Timothee Gosselin's avatar
Timothee Gosselin committed
    https://www.gnu.org/licenses/agpl-3.0.html
Timothee Gosselin's avatar
Timothee Gosselin committed

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

Timothee Gosselin's avatar
Timothee Gosselin committed
package parameters
Timothee Gosselin's avatar
Timothee Gosselin committed

const (
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Random value
	GenerateRand Generate = "rand"
	// Random value of size 12
	GenerateRand12 Generate = "rand12"
	// Random value of size 24
	GenerateRand24 Generate = "rand24"
	// Value is generated from a template
	// Value container the template and will be replaced
Timothee Gosselin's avatar
Timothee Gosselin committed
	GenerateTemplate Generate = "template"
Timothee Gosselin's avatar
Timothee Gosselin committed
)

Timothee Gosselin's avatar
Timothee Gosselin committed
	// Parameter is mounted as key/value in the container envVar specs
Timothee Gosselin's avatar
Timothee Gosselin committed
	MountLiteral MountType = "literal"
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Parameter is mounted as as  EnvVarSource in the container envVar specs
Timothee Gosselin's avatar
Timothee Gosselin committed
	// no data is transformed in a new resource
Timothee Gosselin's avatar
Timothee Gosselin committed
	MountFrom MountType = "from"
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Parameter is mouned as file in the container path
Timothee Gosselin's avatar
Timothee Gosselin committed
	MountFile MountType = "file"
	// Parameter is mounted as EnvFromSource in the container specs
	// Data can be retrieved from the crds or external resources specified in the parameter envFrom
Timothee Gosselin's avatar
Timothee Gosselin committed
	// and transformed in a new secret or configmap
Timothee Gosselin's avatar
Timothee Gosselin committed
	MountEnvFile MountType = "envFile"
Timothee Gosselin's avatar
Timothee Gosselin committed
	ConfigParameter      ParameterType = "configmap"
	SecretParameter      ParameterType = "secret"
	ObjectFieldParameter ParameterType = "field"
Timothee Gosselin's avatar
Timothee Gosselin committed
	TemplateValue        ParameterType = "templateValue"
)

type MountType string
Timothee Gosselin's avatar
Timothee Gosselin committed
type Generate string
type ParameterType string
Timothee Gosselin's avatar
Timothee Gosselin committed

// +kubebuilder:object:generate=true
type Parameters []*Parameter

// +kubebuilder:object:generate=true
type Parameter struct {
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Key of the parameter, can be mounted as as an environment variable, used in template
	// or as in the data fied of configmap/secret
	//
	// Key must be unique
Timothee Gosselin's avatar
Timothee Gosselin committed
	Key string `json:"key,omitempty"`
	// Value of the paramater, should not contain secret values
	// If it is a template, ParameterType should be template
Timothee Gosselin's avatar
Timothee Gosselin committed
	Value string `json:"value,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// ValueFrom when specified indicates the source of the parameter.
	// Cannot be used if value is not empty.
Timothee Gosselin's avatar
Timothee Gosselin committed
	ValueFrom `json:",inline"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// MountPath specifies where the parameter will be mounted as a file
	MountPath MountPath `json:"mountFrom,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Generate if specified defines how the parameter value will be generated
Timothee Gosselin's avatar
Timothee Gosselin committed
	Generate Generate `json:"generate,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Type specifies specifies the parameter type
	Type ParameterType `json:"type,omitempty"`
	// MountType defined how the parameter will be mounted in the pod
	// Defaults to EnvFile
	MountType MountType `json:"mountType,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
}

type ValueFrom struct {
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Key to select from the source
Timothee Gosselin's avatar
Timothee Gosselin committed
	FromKey string `json:"fromKey,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Name of the referent.
Timothee Gosselin's avatar
Timothee Gosselin committed
	Ref string `json:"ref,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Type of the parameter's source
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Defaults to the parameter type if not specified
Timothee Gosselin's avatar
Timothee Gosselin committed
	RefType ParameterType `json:"refType,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
}

type MountPath struct {
	Path    string `json:"path,omitempty"`
	SubPath string `json:"subPath,omitempty"`
}