mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Make toKubeContainerImageSpec deterministic
This commit is contained in:
parent
6324c137ea
commit
7335770670
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package kuberuntime
|
package kuberuntime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
)
|
)
|
||||||
@ -26,11 +28,16 @@ import (
|
|||||||
func toKubeContainerImageSpec(image *runtimeapi.Image) kubecontainer.ImageSpec {
|
func toKubeContainerImageSpec(image *runtimeapi.Image) kubecontainer.ImageSpec {
|
||||||
var annotations []kubecontainer.Annotation
|
var annotations []kubecontainer.Annotation
|
||||||
|
|
||||||
if image.Spec != nil && image.Spec.Annotations != nil {
|
if image.Spec != nil && len(image.Spec.Annotations) > 0 {
|
||||||
for k, v := range image.Spec.Annotations {
|
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{
|
annotations = append(annotations, kubecontainer.Annotation{
|
||||||
Name: k,
|
Name: k,
|
||||||
Value: v,
|
Value: image.Spec.Annotations[k],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user