Some checks failed
Build and Publish / build-release (push) Failing after 26s
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package builder
|
|
|
|
import (
|
|
"fmt"
|
|
zitadelv1alpha1 "gitea.corredorconect.com/software-engineering/zitadel-k8s-operator/api/v1alpha1"
|
|
metadata "gitea.corredorconect.com/software-engineering/zitadel-k8s-operator/pkg/builder/metadata"
|
|
corev1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
|
)
|
|
|
|
type ConfigMapOpts struct {
|
|
Zitadel *zitadelv1alpha1.Cluster
|
|
Key types.NamespacedName
|
|
Data map[string]string
|
|
Labels map[string]string
|
|
Annotations map[string]string
|
|
Immutable bool
|
|
}
|
|
|
|
func (b *Builder) BuildConfigMap(opts ConfigMapOpts, owner metav1.Object) (*corev1.ConfigMap, error) {
|
|
objMeta :=
|
|
metadata.NewMetadataBuilder(opts.Key).
|
|
WithZitadel(opts.Zitadel).
|
|
WithLabels(opts.Labels).
|
|
WithAnnotations(opts.Annotations).
|
|
Build()
|
|
|
|
configMap := &corev1.ConfigMap{
|
|
Data: opts.Data,
|
|
ObjectMeta: objMeta,
|
|
Immutable: &opts.Immutable,
|
|
}
|
|
if err := controllerutil.SetControllerReference(owner, configMap, b.scheme); err != nil {
|
|
return nil, fmt.Errorf("error setting controller reference in ConfigMap manifest: %v", err)
|
|
}
|
|
return configMap, nil
|
|
}
|