Skip to content

Commit

Permalink
Merge branch 'master' into feature/fix-docker-image-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
matthijswolters-rl committed Oct 24, 2024
2 parents 181ada2 + 70ce314 commit 7f7aefc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: endpointmonitors.endpointmonitor.stakater.com
Expand Down
11 changes: 10 additions & 1 deletion pkg/secret/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func LoadSecretData(apiReader client.Reader, secretName, namespace, dataKey stri

func ReadBasicAuthSecret(apiReader clientv1.SecretInterface, secretName string) (string, string, error) {
secret, err := apiReader.Get(context.TODO(), secretName, metav1.GetOptions{})
var username, password string
username, password := "", ""

if err != nil {
return "", "", err
}
Expand All @@ -44,5 +45,13 @@ func ReadBasicAuthSecret(apiReader clientv1.SecretInterface, secretName string)
}
}

if username == "" {
return "", "", fmt.Errorf("secret %s does not contain expected key '%s'", secretName, "username")
} else if password == "" {
return "", "", fmt.Errorf("secret %s does not contain expected key '%s'", secretName, "password")
} else if username == "" && password == "" {
return "", "", fmt.Errorf("secret %s does not contain expected keys '%s','%s'", secretName, "username", "password")
}

return username, password, err
}

0 comments on commit 7f7aefc

Please sign in to comment.