-
Notifications
You must be signed in to change notification settings - Fork 462
/
utils.go
32 lines (25 loc) · 888 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package operatingsystemconfig
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
)
// SecretObjectMetaForConfig returns the object meta structure that can be used inside the
// secret that shall contain the generated OSC output.
func SecretObjectMetaForConfig(config *extensionsv1alpha1.OperatingSystemConfig) metav1.ObjectMeta {
var (
name = fmt.Sprintf("osc-result-%s", config.Name)
namespace = config.Namespace
)
if cloudConfig := config.Status.CloudConfig; cloudConfig != nil {
name = cloudConfig.SecretRef.Name
namespace = cloudConfig.SecretRef.Namespace
}
return metav1.ObjectMeta{
Name: name,
Namespace: namespace,
}
}