INNER CODE UNIT · Go

ResolveAuthorization

metacontroller/metacontroller · pkg/hooks/auth.go:42

func ResolveAuthorization(ctx context.Context, k8sClient client.Client, spec *v1alpha1.Authorization) (string, error) {
	if spec == nil {
		return "", nil
	}

	if strings.EqualFold(strings.TrimSpace(spec.Type), "basic") {
		return "", fmt.Errorf("authorization type %q is not supported; use the basicAuth field instead", spec.Type)
	}

	secret := &corev1.Secret{}
	if err := k8sClient.Get(ctx, types.NamespacedName{
		Name:      spec.SecretRef.Name,
		Namespace: spec.SecretRef.Namespace,
	}, secret); err != nil {
		return "", fmt.Errorf("can't get authorization secret %s/%s: %w",
			spec.SecretRef.Namespace, spec.SecretRef.Name, err)
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…