You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Message: "DockerMachineTemplate.infrastructure.cluster.x-k8s.io \"docker-template-one\" is invalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2732
-
Details: &metav1.StatusDetails{
2733
-
Group: "infrastructure.cluster.x-k8s.io",
2734
-
Kind: "DockerMachineTemplate",
2735
-
Name: "docker-template-one",
2736
-
Causes: []metav1.StatusCause{
2737
-
{
2738
-
Type: "FieldValueInvalid",
2739
-
Message: "Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2740
-
Field: "spec.template.spec.preLoadImages",
2741
-
},
2742
-
},
2743
-
},
2744
-
}}
2745
-
wantError:=&apierrors.StatusError{
2746
-
ErrStatus: metav1.Status{
2747
-
Status: metav1.StatusFailure,
2748
-
Code: http.StatusUnprocessableEntity,
2749
-
Reason: metav1.StatusReasonInvalid,
2750
-
// The only difference between the two objects should be in the Message section.
2751
-
Message: "failed to create DockerMachineTemplate.infrastructure.cluster.x-k8s.io: FieldValueInvalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2752
-
Details: &metav1.StatusDetails{
2753
-
Group: "infrastructure.cluster.x-k8s.io",
2754
-
Kind: "DockerMachineTemplate",
2755
-
Name: "docker-template-one",
2756
-
Causes: []metav1.StatusCause{
2757
-
{
2758
-
Type: "FieldValueInvalid",
2759
-
Message: "Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2760
-
Field: "spec.template.spec.preLoadImages",
2761
-
},
2762
-
},
2763
-
},
2764
-
},
2765
-
}
2766
-
t.Run("Transform a create error correctly", func(t*testing.T) {
Message: "DockerMachineTemplate.infrastructure.cluster.x-k8s.io \"docker-template-one\" is invalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2836
+
Details: &metav1.StatusDetails{
2837
+
Group: "infrastructure.cluster.x-k8s.io",
2838
+
Kind: "DockerMachineTemplate",
2839
+
Name: "docker-template-one",
2840
+
Causes: []metav1.StatusCause{
2841
+
{
2842
+
Type: "FieldValueInvalid",
2843
+
Message: "Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2844
+
Field: "spec.template.spec.preLoadImages",
2845
+
},
2846
+
},
2847
+
},
2848
+
},
2849
+
}
2850
+
expectedDetailsError:=&apierrors.StatusError{
2851
+
ErrStatus: metav1.Status{
2852
+
Status: metav1.StatusFailure,
2853
+
Code: http.StatusUnprocessableEntity,
2854
+
Reason: metav1.StatusReasonInvalid,
2855
+
// The only difference between the two objects should be in the Message section.
2856
+
Message: "failed to create DockerMachineTemplate.infrastructure.cluster.x-k8s.io: FieldValueInvalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2857
+
Details: &metav1.StatusDetails{
2858
+
Group: "infrastructure.cluster.x-k8s.io",
2859
+
Kind: "DockerMachineTemplate",
2860
+
Name: "docker-template-one",
2861
+
Causes: []metav1.StatusCause{
2862
+
{
2863
+
Type: "FieldValueInvalid",
2864
+
Message: "Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2865
+
Field: "spec.template.spec.preLoadImages",
2866
+
},
2867
+
},
2868
+
},
2869
+
},
2870
+
}
2871
+
NoCausesDetailsError:=&apierrors.StatusError{
2872
+
ErrStatus: metav1.Status{
2873
+
Status: metav1.StatusFailure,
2874
+
Code: http.StatusUnprocessableEntity,
2875
+
Reason: metav1.StatusReasonInvalid,
2876
+
Message: "DockerMachineTemplate.infrastructure.cluster.x-k8s.io \"docker-template-one\" is invalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
// The only difference between the two objects should be in the Message section.
2890
+
Message: "failed to create DockerMachineTemplate.infrastructure.cluster.x-k8s.io",
2891
+
Details: &metav1.StatusDetails{
2892
+
Group: "infrastructure.cluster.x-k8s.io",
2893
+
Kind: "DockerMachineTemplate",
2894
+
Name: "docker-template-one",
2895
+
},
2896
+
},
2897
+
}
2898
+
noDetailsError:=&apierrors.StatusError{
2899
+
ErrStatus: metav1.Status{
2900
+
Status: metav1.StatusFailure,
2901
+
Code: http.StatusUnprocessableEntity,
2902
+
Reason: metav1.StatusReasonInvalid,
2903
+
Message: "DockerMachineTemplate.infrastructure.cluster.x-k8s.io \"docker-template-one\" is invalid: spec.template.spec.preLoadImages: Invalid value: \"array\": spec.template.spec.preLoadImages in body must be of type string: \"array\"",
2904
+
},
2905
+
}
2906
+
expectedNoDetailsError:=&apierrors.StatusError{
2907
+
ErrStatus: metav1.Status{
2908
+
Status: metav1.StatusFailure,
2909
+
Code: http.StatusUnprocessableEntity,
2910
+
Reason: metav1.StatusReasonInvalid,
2911
+
// The only difference between the two objects should be in the Message section.
2912
+
Message: "failed to create TestControlPlane.controlplane.cluster.x-k8s.io",
2913
+
},
2914
+
}
2915
+
expectedObjectNilError:=&apierrors.StatusError{
2916
+
ErrStatus: metav1.Status{
2917
+
Status: metav1.StatusFailure,
2918
+
Code: http.StatusUnprocessableEntity,
2919
+
Reason: metav1.StatusReasonInvalid,
2920
+
// The only difference between the two objects should be in the Message section.
2921
+
Message: "failed to create object",
2922
+
},
2923
+
}
2924
+
nonStatusError:=errors.New("an unexpected error with unknown information inside")
2925
+
expectedNonStatusError:=errors.New("failed to create TestControlPlane.controlplane.cluster.x-k8s.io")
2926
+
expectedNilObjectNonStatusError:=errors.New("failed to create object")
2927
+
tests:= []struct {
2928
+
namestring
2929
+
inputerror
2930
+
expectederror
2931
+
obj client.Object
2932
+
}{
2933
+
{
2934
+
name: "Remove name from status error with details",
0 commit comments