-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds support for inline sysprep which was introduced in the API in v1alpha2. For the secrets, we are currently decoding them and adding the data to the Data field under BootstrapArgs. There could be a situiation wherein 2 or more secrets are storing data under the same key which will cause the secret values to be overidden. This patch adds tests for the changes to enable inline sysprep. It also reads the secret data into distinct fields to avoid the overwriting of values if the selector key for the fields in UserData, Identification anf GUIAttended are the same. Instead of waiting till doBootstrap to pull the secret data for inline sysprep, this patch adds the secret data to the BootstrapArgs earlier for verification purposes. Signed-off-by: Sagar Muchhal <[email protected]>
- Loading branch information
Showing
24 changed files
with
978 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package util | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func GetSecretData( | ||
ctx context.Context, | ||
k8sClient ctrlclient.Client, | ||
secretNamespace, secretName, secretKey string, | ||
out *string) error { | ||
|
||
secret, err := GetSecretResource(ctx, k8sClient, secretNamespace, secretName) | ||
if err != nil { | ||
return err | ||
} | ||
data := secret.Data[secretKey] | ||
if len(data) == 0 { | ||
return fmt.Errorf( | ||
"no data found for key %q for secret %s/%s", | ||
secretKey, secretNamespace, secretName) | ||
} | ||
*out = string(data) | ||
return nil | ||
} | ||
|
||
func GetSecretResource( | ||
ctx context.Context, | ||
k8sClient ctrlclient.Client, | ||
secretNamespace, secretName string) (*corev1.Secret, error) { | ||
|
||
var secret corev1.Secret | ||
key := ctrlclient.ObjectKey{Name: secretName, Namespace: secretNamespace} | ||
if err := k8sClient.Get(ctx, key, &secret); err != nil { | ||
return nil, err | ||
} | ||
return &secret, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.