func newPullSecret()

in internal/controller/acrpullbinding_controller.go [327:356]


func newPullSecret(acrBinding client.Object,
	name, dockerConfig string, scheme *runtime.Scheme, expiry time.Time, now func() time.Time, inputHash string) *corev1.Secret {

	pullSecret := &corev1.Secret{
		Type: corev1.SecretTypeDockerConfigJson,
		ObjectMeta: metav1.ObjectMeta{
			Labels: map[string]string{
				ACRPullBindingLabel: acrBinding.GetName(),
			},
			Annotations: map[string]string{
				tokenExpiryAnnotation:  expiry.Format(time.RFC3339),
				tokenRefreshAnnotation: now().Format(time.RFC3339),
				tokenInputsAnnotation:  inputHash,
			},
			Name:      name,
			Namespace: acrBinding.GetNamespace(),
		},
		Data: map[string][]byte{
			dockerConfigKey: []byte(dockerConfig),
		},
	}

	if err := ctrl.SetControllerReference(acrBinding, pullSecret, scheme); err != nil {
		// ctrl.SetControllerReference can only error if the object already has an owner, and we're
		// creating this object from scratch so we know it cannot ever error, so handle this inline
		panic(fmt.Sprintf("programmer error: cannot set controller reference: %v", err))
	}

	return pullSecret
}