mirror of https://github.com/knative/caching.git
Allow creators to produce / consume a slice of LocalObjectReference for pull secrets. (#12)
PodSpec has this as a slice, and if we wanted to start creating these references more automatically for e.g. Deployment it isn't immediately obvious which secret is used for which image (certainly without reading the secrets). This changes it to a more pass-through model for simplicity. Fixes: https://github.com/knative/caching/issues/9
This commit is contained in:
parent
bba06b0586
commit
a9dfa18660
|
@ -66,10 +66,10 @@ type ImageSpec struct {
|
||||||
// +optional
|
// +optional
|
||||||
ServiceAccountName string `json:"serviceAccountName,omitempty"`
|
ServiceAccountName string `json:"serviceAccountName,omitempty"`
|
||||||
|
|
||||||
// ImagePullSecrets is the name of the Kubernetes Secret containing login information
|
// ImagePullSecrets contains the names of the Kubernetes Secrets containing login
|
||||||
// used by the Pods which will run this container.
|
// information used by the Pods which will run this container.
|
||||||
// +optional
|
// +optional
|
||||||
ImagePullSecrets *corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
|
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageConditionType is used to communicate the status of the reconciliation process.
|
// ImageConditionType is used to communicate the status of the reconciliation process.
|
||||||
|
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
|
|
||||||
|
@ -34,9 +36,9 @@ func (rs *ImageSpec) Validate() *apis.FieldError {
|
||||||
// TODO(mattmoor): Consider using go-containerregistry to validate
|
// TODO(mattmoor): Consider using go-containerregistry to validate
|
||||||
// the image reference. This is effectively the function we want.
|
// the image reference. This is effectively the function we want.
|
||||||
// https://github.com/google/go-containerregistry/blob/2f3e3e1/pkg/name/ref.go#L41
|
// https://github.com/google/go-containerregistry/blob/2f3e3e1/pkg/name/ref.go#L41
|
||||||
if rs.ImagePullSecrets != nil {
|
for index, ips := range rs.ImagePullSecrets {
|
||||||
if equality.Semantic.DeepEqual(rs.ImagePullSecrets, &corev1.LocalObjectReference{}) {
|
if equality.Semantic.DeepEqual(ips, corev1.LocalObjectReference{}) {
|
||||||
return apis.ErrMissingField("imagePullSecrets.name")
|
return apis.ErrMissingField(fmt.Sprintf("imagePullSecrets[%d].name", index))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -47,10 +47,10 @@ func TestImageValidation(t *testing.T) {
|
||||||
r: &Image{
|
r: &Image{
|
||||||
Spec: ImageSpec{
|
Spec: ImageSpec{
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
ImagePullSecrets: &corev1.LocalObjectReference{},
|
ImagePullSecrets: []corev1.LocalObjectReference{{}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: apis.ErrMissingField("spec.imagePullSecrets.name"),
|
want: apis.ErrMissingField("spec.imagePullSecrets[0].name"),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
@ -108,8 +108,8 @@ func (in *ImageSpec) DeepCopyInto(out *ImageSpec) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.ImagePullSecrets != nil {
|
if in.ImagePullSecrets != nil {
|
||||||
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
|
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
|
||||||
*out = new(v1.LocalObjectReference)
|
*out = make([]v1.LocalObjectReference, len(*in))
|
||||||
**out = **in
|
copy(*out, *in)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue