Skip to content

Commit

Permalink
secret_object_data_test unit tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
manedurphy committed Aug 22, 2021
1 parent 82f2537 commit 3461249
Show file tree
Hide file tree
Showing 2 changed files with 328 additions and 9 deletions.
8 changes: 7 additions & 1 deletion pkg/util/spcutil/secret_object_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func BuildSecretObjectData(files map[string]string, secretObj *v1alpha1.SecretOb
}
}

// BuildSecretObjects build the .Spec.SecretObjects list of a SecretProviderClass with .SyncOptions.SyncAll is true
// BuildSecretObjects builds the .Spec.SecretObjects list of a SecretProviderClass when .SyncOptions.SyncAll is true
// How a SecretObject is built is dependent on the type of secret
func BuildSecretObjects(files map[string]string, secretType corev1.SecretType) []*v1alpha1.SecretObject {
secretObjects := []*v1alpha1.SecretObject{}

Expand All @@ -67,6 +68,7 @@ func BuildSecretObjects(files map[string]string, secretType corev1.SecretType) [
return secretObjects
}

// createOpaqueSecretDataObject creates a SecretObject for an Opaque secret
func createOpaqueSecretDataObject(key string) *v1alpha1.SecretObject {
return &v1alpha1.SecretObject{
SecretName: setSecretName(key),
Expand All @@ -80,6 +82,7 @@ func createOpaqueSecretDataObject(key string) *v1alpha1.SecretObject {
}
}

// createTLSSecretDataObject creates a SecretObject for an TLS secret
func createTLSSecretDataObject(key string) *v1alpha1.SecretObject {
return &v1alpha1.SecretObject{
SecretName: setSecretName(key),
Expand All @@ -97,6 +100,7 @@ func createTLSSecretDataObject(key string) *v1alpha1.SecretObject {
}
}

// createDockerConfigJsonSecretDataObject creates a SecretObject for an DockerConfigJSON secret
func createDockerConfigJsonSecretDataObject(key string) *v1alpha1.SecretObject {
return &v1alpha1.SecretObject{
SecretName: setSecretName(key),
Expand All @@ -110,6 +114,7 @@ func createDockerConfigJsonSecretDataObject(key string) *v1alpha1.SecretObject {
}
}

// createBasicAuthSecretDataObject creates a SecretObject for an Basic-Auth secret
func createBasicAuthSecretDataObject(key string) *v1alpha1.SecretObject {
return &v1alpha1.SecretObject{
SecretName: setSecretName(key),
Expand All @@ -123,6 +128,7 @@ func createBasicAuthSecretDataObject(key string) *v1alpha1.SecretObject {
}
}

// createSSHSecretDataObject creates a SecretObject for an SSH-Auth secret
func createSSHSecretDataObject(key string) *v1alpha1.SecretObject {
return &v1alpha1.SecretObject{
SecretName: setSecretName(key),
Expand Down
Loading

0 comments on commit 3461249

Please sign in to comment.