Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (32 sloc) 1.03 KB
package namespace
import (
"context"
"github.com/giantswarm/microerror"
apiv1 "k8s.io/api/core/v1"
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/giantswarm/kvm-operator/service/controller/v22/key"
)
func (r *Resource) GetDesiredState(ctx context.Context, obj interface{}) (interface{}, error) {
customObject, err := key.ToCustomObject(obj)
if err != nil {
return nil, microerror.Mask(err)
}
r.logger.LogCtx(ctx, "level", "debug", "message", "computing the desired namespace")
// Compute the desired state of the namespace to have a reference of data how
// it should be.
namespace := &apiv1.Namespace{
TypeMeta: apismetav1.TypeMeta{
Kind: "Namespace",
APIVersion: "v1",
},
ObjectMeta: apismetav1.ObjectMeta{
Name: key.ClusterNamespace(customObject),
Labels: map[string]string{
"cluster": key.ClusterID(customObject),
"customer": key.ClusterCustomer(customObject),
},
},
}
r.logger.LogCtx(ctx, "level", "debug", "message", "computed the desired namespace")
return namespace, nil
}
You can’t perform that action at this time.