Newer
Older
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
*/
corev1 "k8s.io/api/core/v1"
)
func (p *Parameter) GetEnvVar() (envVar corev1.EnvVar, err error) {
switch p.MountType {
case MountLiteral:
if len(p.Value) > 0 && len(p.Key) > 0 {
envVar := corev1.EnvVar{
Name: p.Key,
Value: p.Value,
}
return envVar, nil
return envVar, errors.New("missing key and/or value argument")
if len(p.FromKey) > 0 && len(p.Ref) > 0 && len(p.Key) > 0 {
envVar = corev1.EnvVar{
Name: p.Key,
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
},
Key: p.FromKey,
},
},
}
return envVar, nil
case ConfigParameter:
envVar = corev1.EnvVar{
Name: p.Key,
ValueFrom: &corev1.EnvVarSource{
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
}
return envVar, nil
case ObjectFieldParameter:
envVar = corev1.EnvVar{
Name: p.Key,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: p.FromKey,
},
},
}
return envVar, nil
default:
return envVar, errors.New("wrong MountType")
func (p *Parameter) GetPodVolume() *corev1.Volume {
return nil
}
func (p *Parameter) GetVolumeMount() *corev1.VolumeMount {
return nil
}