|
| 1 | +// Copyright 2019-2025 The Liqo Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package telemetry |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + "fmt" |
| 20 | + |
| 21 | + corev1 "k8s.io/api/core/v1" |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 24 | + |
| 25 | + "github.com/liqotech/liqo/pkg/consts" |
| 26 | +) |
| 27 | + |
| 28 | +func createClusterIDTelemetryConfigMap(ctx context.Context, cl client.Client, namespace string) error { |
| 29 | + cm := &corev1.ConfigMap{ |
| 30 | + ObjectMeta: metav1.ObjectMeta{ |
| 31 | + Name: consts.ClusterIDTelemetryConfigMapName, |
| 32 | + Namespace: namespace, |
| 33 | + Labels: map[string]string{ |
| 34 | + consts.K8sAppNameKey: consts.ClusterIDTelemetryConfigMapNameLabelValue, |
| 35 | + }, |
| 36 | + }, |
| 37 | + Data: map[string]string{ |
| 38 | + consts.ClusterIDTelemetryConfigMapKey: generateClusterIDTelemetry(), |
| 39 | + }, |
| 40 | + } |
| 41 | + |
| 42 | + if err := cl.Create(ctx, cm); err != nil { |
| 43 | + return fmt.Errorf("failed to create configmap: %w", err) |
| 44 | + } |
| 45 | + return nil |
| 46 | +} |
0 commit comments