Skip to content
settings.go 1.55 KiB
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
package components

Timothee Gosselin's avatar
Timothee Gosselin committed
/*
Timothee Gosselin's avatar
Timothee Gosselin committed
// +kubebuilder:object:generate=true
type Settings struct {
	*meta.ObjectMeta      `json:"meta,omitempty"`
	parameters.Parameters `json:"parameters,omitempty"`
}

func (s *Settings) GetParameters() *parameters.Parameters {
	return &s.Parameters
}

func (s *Settings) GetObjects() []instance.Object {
	objects := []instance.Object{}

	//	for _, param := range *s.Parameters {
	//		if len(param.Value) > 0 && len(param.Key) > 0 {
	//			if param.Type == "Secret" {
	//				objects = append(objects, secret)
	//			}
	//			objects = append(objects, secret)
	//		}
	//	}
	return objects

}

func (s *Settings) GetConfigRefs() []string { return nil }

func (s *Settings) GetSecretRefs() []string { return nil }

func (s *Settings) SetDefaults(i instance.Instance) {

	if s.ObjectMeta == nil {
		s.ObjectMeta = new(meta.ObjectMeta)
	}

	if len(s.ObjectMeta.Labels) == 0 {
		s.ObjectMeta.Labels = make(map[string]string)
	}

	instanceLabels := instance.InstanceLabels(i)

	s.ObjectMeta.SetLabels(instanceLabels)
	s.ObjectMeta.Labels["app.kubernetes.io/component"] = "settings"

	if len(s.ObjectMeta.Name) == 0 {
		s.ObjectMeta.Name = fmt.Sprintf("%v-%v", i.GetName(), "settings")
	}

	if len(s.ObjectMeta.Namespace) == 0 {
		s.ObjectMeta.Namespace = i.GetNamespace()
	}

}

func CreateAndInitSettings(i instance.Settings) *Settings {
	return &Settings{
		ObjectMeta: &meta.ObjectMeta{
			Name:      i.GetMeta().GetName(),
			Namespace: i.GetMeta().GetNamespace(),
			Labels:    instance.InstanceLabels(i.GetMeta()),
		},
Timothee Gosselin's avatar
Timothee Gosselin committed
		Parameters: *i.GetParameters().Parameters,
Timothee Gosselin's avatar
Timothee Gosselin committed
	}
}
Timothee Gosselin's avatar
Timothee Gosselin committed
*/