func()

in pkg/client/nexus/provider.go [99:117]


func (p *ApiClientProvider) getNexusSecret(ctx context.Context, nexus *nexusApi.Nexus) (corev1.Secret, error) {
	secret := corev1.Secret{}
	if err := p.k8sClient.Get(ctx, types.NamespacedName{
		Name:      nexus.Spec.Secret,
		Namespace: nexus.Namespace,
	}, &secret); err != nil {
		return corev1.Secret{}, fmt.Errorf("failed to get nexus secret: %w", err)
	}

	if secret.Data["user"] == nil {
		return corev1.Secret{}, fmt.Errorf("nexus secret doesn't contain user")
	}

	if secret.Data["password"] == nil {
		return corev1.Secret{}, fmt.Errorf("nexus secret doesn't contain password")
	}

	return secret, nil
}