Skip to content
component.go 851 B
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
package instance

import (
	"github.com/presslabs/controller-util/syncer"
	"k8s.io/apimachinery/pkg/labels"
	interfaces "k8s.libre.sh/interfaces"
)

type Component interface {
	//	settings.Interface
	//	mutate.ObjectMeta
	Meta
	// GetName() string
	SetDefaults(i Instance)
	GetObjects() map[int]Object
	//	HasCommonSettings() bool
}

func GenComponentLabels(c Component) map[string]string {
	labels := labels.Set{
		"app.kubernetes.io/component": c.GetName(),
	}
	return labels
}

func NewSyncer(i Component, r interfaces.Reconcile, owner interfaces.Object) (syncers []syncer.Interface) {
	mutators := i.GetObjects()
	//	labels := InstanceLabels(i)

	for _, m := range mutators {
		//	m.SetLabels(labels)
		//	m.SetName(i.GetName())
		//	m.SetNamespace(i.GetNamespace())
		syncers = append(syncers, NewObjectSyncer(m, owner, r))
	}

	return syncers
}