Change SecretVolumeSource to use a secret name instead of ObjRef
This commit is contained in:
@@ -1377,6 +1377,14 @@ func init() {
|
||||
out.PodID = in.Name
|
||||
return nil
|
||||
},
|
||||
func(in *newer.SecretVolumeSource, out *SecretVolumeSource, s conversion.Scope) error {
|
||||
out.Target.ID = in.SecretName
|
||||
return nil
|
||||
},
|
||||
func(in *SecretVolumeSource, out *newer.SecretVolumeSource, s conversion.Scope) error {
|
||||
out.SecretName = in.Target.ID
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
|
@@ -462,3 +462,31 @@ func TestEndpointsConversion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecretVolumeSourceConversion(t *testing.T) {
|
||||
given := current.SecretVolumeSource{
|
||||
Target: current.ObjectReference{
|
||||
ID: "foo",
|
||||
},
|
||||
}
|
||||
|
||||
expected := newer.SecretVolumeSource{
|
||||
SecretName: "foo",
|
||||
}
|
||||
|
||||
got := newer.SecretVolumeSource{}
|
||||
if err := Convert(&given, &got); err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
if got.SecretName != expected.SecretName {
|
||||
t.Errorf("Expected %v; got %v", expected, got)
|
||||
}
|
||||
|
||||
got2 := current.SecretVolumeSource{}
|
||||
if err := Convert(&got, &got2); err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
if got2.Target.ID != given.Target.ID {
|
||||
t.Errorf("Expected %v; got %v", given, got2)
|
||||
}
|
||||
}
|
||||
|
@@ -171,7 +171,8 @@ type GitRepoVolumeSource struct {
|
||||
|
||||
// SecretVolumeSource adapts a Secret into a VolumeSource
|
||||
type SecretVolumeSource struct {
|
||||
// Reference to a Secret
|
||||
// Reference to a Secret to use. Only the ID field of this reference is used; a
|
||||
// secret can only be used by pods in its namespace.
|
||||
Target ObjectReference `json:"target" description:"target is a reference to a secret"`
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user