Merge pull request #93610 from liggitt/deterministic-container

Make toKubeContainerImageSpec deterministic
This commit is contained in:
Kubernetes Prow Robot 2020-08-01 20:22:32 -07:00 committed by GitHub
commit 78ab6d8bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,8 @@ limitations under the License.
package kuberuntime
import (
"sort"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
)
@ -26,11 +28,16 @@ import (
func toKubeContainerImageSpec(image *runtimeapi.Image) kubecontainer.ImageSpec {
var annotations []kubecontainer.Annotation
if image.Spec != nil && image.Spec.Annotations != nil {
for k, v := range image.Spec.Annotations {
if image.Spec != nil && len(image.Spec.Annotations) > 0 {
annotationKeys := make([]string, 0, len(image.Spec.Annotations))
for k := range image.Spec.Annotations {
annotationKeys = append(annotationKeys, k)
}
sort.Strings(annotationKeys)
for _, k := range annotationKeys {
annotations = append(annotations, kubecontainer.Annotation{
Name: k,
Value: v,
Value: image.Spec.Annotations[k],
})
}
}