// createContainerRegistrySecret use environment variables to check for container registry
// credentials secret, when not found a new secret is created.
createContainerRegistrySecret use environment variables to check for container registry
credentials secret, when not found a new secret is created.
// createContainerRegistrySecret use environment variables to check for container registry // credentials secret when not found a new secret is created .
func createContainerRegistrySecret(ctx *framework.Context, f *framework.Framework, namespace string, timeout time.Duration, retry time.Duration) {
	secretName := os.Getenv(EnvVarImageRepoSecret)
	secretPayload := os.Getenv(EnvVarSourceRepoSecretJSON)
	if secretName == "" || secretPayload == "" {
		Logf("Container registry secret won't be created.")
		return
	}
	secretNsName := types.NamespacedName{Namespace: namespace, Name: secretName}
	secret := &corev1.Secret{}
	if err := clientGet(secretNsName, secret); err == nil {
		Logf("Container registry secret is found at '%s/%s'", namespace, secretName)
		return
	}
	payload := []byte(secretPayload)
	secret = &corev1.Secret{
		ObjectMeta: metav1.ObjectMeta{
			Namespace: namespace,
			Name:      secretName,
		},
		Type: corev1.SecretTypeDockerConfigJson,
		Data: map[string][]byte{
			".dockerconfigjson": payload,
		},
	}
	Logf("Creating container-registry secret '%s/%s' (%d bytes)", namespace, secretName, len(payload))
	err := f.Client.Create(goctx.TODO(), secret, cleanupOptions(ctx, timeout, retry))
	Expect(err).ToNot(HaveOccurred(), "on creating container registry secret")
}
func createContainerRegistrySecret ( ctx * framework . Context , f * framework . Framework , namespace string , timeout time . Duration , retry time . Duration ) { secretName := os . Getenv ( EnvVarImageRepoSecret ) secretPayload := os . Getenv ( EnvVarSourceRepoSecretJSON ) if secretName == " " || secretPayload == " " { Logf ( " " ) return } secretNsName := types . NamespacedName { Namespace : namespace , Name : secretName } secret := & corev1 . Secret { } if err := clientGet ( secretNsName , secret ) ; err == nil { Logf ( " " , namespace , secretName ) return } payload := [ ] byte ( secretPayload ) secret = & corev1 . Secret { ObjectMeta : metav1 . ObjectMeta { Namespace : namespace , Name : secretName , } , Type : corev1 . SecretTypeDockerConfigJson , Data : map [ string ] [ ] byte { " " : payload , } , } Logf ( " " , namespace , secretName , len ( payload ) ) err := f . Client . Create ( goctx . TODO ( ) , secret , cleanupOptions ( ctx , timeout , retry ) ) Expect ( err ) . ToNot ( HaveOccurred ( ) , " " ) }
createContainerRegistrySecret use environment variables to check for container registry
credentials secret, when not found a new secret is created.
createContainerRegistrySecret use environment variables to check for container registry credentials secret when not found a new secret is created .