diff --git a/pkg/apis/serving/k8s_validation.go b/pkg/apis/serving/k8s_validation.go index 585ebc9f29cc..0eddc2122846 100644 --- a/pkg/apis/serving/k8s_validation.go +++ b/pkg/apis/serving/k8s_validation.go @@ -154,9 +154,11 @@ func validateEnvFrom(envFromList []corev1.EnvFromSource) *apis.FieldError { } func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { - if equality.Semantic.DeepEqual(ps, corev1.PodSpec{}) { - return apis.ErrMissingField(apis.CurrentField) - } + // This is inlined, and so it makes for a less meaningful + // error message. + // if equality.Semantic.DeepEqual(ps, corev1.PodSpec{}) { + // return apis.ErrMissingField(apis.CurrentField) + // } errs := apis.CheckDisallowedFields(ps, *PodSpecMask(&ps)) diff --git a/pkg/apis/serving/k8s_validation_test.go b/pkg/apis/serving/k8s_validation_test.go index 2cd9ceeb1790..3d1528aa2606 100644 --- a/pkg/apis/serving/k8s_validation_test.go +++ b/pkg/apis/serving/k8s_validation_test.go @@ -140,7 +140,7 @@ func TestPodSpecValidation(t *testing.T) { ps: corev1.PodSpec{ Containers: []corev1.Container{}, }, - want: apis.ErrMissingField(apis.CurrentField), + want: apis.ErrMissingField("containers"), }, { name: "missing container", ps: corev1.PodSpec{ diff --git a/pkg/apis/serving/v1alpha1/configuration_conversion_test.go b/pkg/apis/serving/v1alpha1/configuration_conversion_test.go index fef23f2b20e2..314e018f687f 100644 --- a/pkg/apis/serving/v1alpha1/configuration_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/configuration_conversion_test.go @@ -59,7 +59,7 @@ func TestConfigurationConversion(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -114,7 +114,7 @@ func TestConfigurationConversion(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/pkg/apis/serving/v1alpha1/configuration_defaults_test.go b/pkg/apis/serving/v1alpha1/configuration_defaults_test.go index 896c3a8f4d3d..998c50dd8d8e 100644 --- a/pkg/apis/serving/v1alpha1/configuration_defaults_test.go +++ b/pkg/apis/serving/v1alpha1/configuration_defaults_test.go @@ -93,7 +93,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -111,7 +111,7 @@ func TestConfigurationDefaulting(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{}}, }, }, @@ -125,7 +125,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, diff --git a/pkg/apis/serving/v1alpha1/configuration_validation_test.go b/pkg/apis/serving/v1alpha1/configuration_validation_test.go index bef4a348adc2..0adab4b0857a 100644 --- a/pkg/apis/serving/v1alpha1/configuration_validation_test.go +++ b/pkg/apis/serving/v1alpha1/configuration_validation_test.go @@ -53,7 +53,7 @@ func TestConfigurationSpecValidation(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -120,7 +120,7 @@ func TestConfigurationSpecValidation(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, diff --git a/pkg/apis/serving/v1alpha1/revision_conversion.go b/pkg/apis/serving/v1alpha1/revision_conversion.go index 85e8b1cf861f..6a8f9db8ec59 100644 --- a/pkg/apis/serving/v1alpha1/revision_conversion.go +++ b/pkg/apis/serving/v1alpha1/revision_conversion.go @@ -55,7 +55,7 @@ func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1beta1.Revisio case source.DeprecatedContainer != nil && len(source.Containers) > 0: return apis.ErrMultipleOneOf("container", "containers") case source.DeprecatedContainer != nil: - sink.PodSpec = v1beta1.PodSpec{ + sink.PodSpec = corev1.PodSpec{ ServiceAccountName: source.ServiceAccountName, Containers: []corev1.Container{*source.DeprecatedContainer}, Volumes: source.Volumes, diff --git a/pkg/apis/serving/v1alpha1/revision_conversion_test.go b/pkg/apis/serving/v1alpha1/revision_conversion_test.go index feb719b38b41..50e6514eb312 100644 --- a/pkg/apis/serving/v1alpha1/revision_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/revision_conversion_test.go @@ -57,7 +57,7 @@ func TestRevisionConversion(t *testing.T) { }, Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -108,7 +108,7 @@ func TestRevisionConversion(t *testing.T) { Name: "foo", }, RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -219,7 +219,7 @@ func TestRevisionConversionError(t *testing.T) { }, Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -254,7 +254,7 @@ func TestRevisionConversionError(t *testing.T) { }, Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{}, }, diff --git a/pkg/apis/serving/v1alpha1/revision_defaults_test.go b/pkg/apis/serving/v1alpha1/revision_defaults_test.go index 72a1168b1805..f7d30bd45973 100644 --- a/pkg/apis/serving/v1alpha1/revision_defaults_test.go +++ b/pkg/apis/serving/v1alpha1/revision_defaults_test.go @@ -150,7 +150,7 @@ func TestRevisionDefaulting(t *testing.T) { want: &Revision{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "foo", VolumeMounts: []corev1.VolumeMount{{ @@ -176,7 +176,7 @@ func TestRevisionDefaulting(t *testing.T) { RevisionSpec: v1beta1.RevisionSpec{ ContainerConcurrency: 1, TimeoutSeconds: ptr.Int64(99), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "foo", Resources: defaultResources, @@ -193,7 +193,7 @@ func TestRevisionDefaulting(t *testing.T) { RevisionSpec: v1beta1.RevisionSpec{ ContainerConcurrency: 1, TimeoutSeconds: ptr.Int64(99), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "foo", Resources: defaultResources, diff --git a/pkg/apis/serving/v1alpha1/revision_validation_test.go b/pkg/apis/serving/v1alpha1/revision_validation_test.go index 9f47fc23c4c5..17dc6e6550ab 100644 --- a/pkg/apis/serving/v1alpha1/revision_validation_test.go +++ b/pkg/apis/serving/v1alpha1/revision_validation_test.go @@ -103,7 +103,7 @@ func TestRevisionSpecValidation(t *testing.T) { name: "missing container", rs: &RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Volumes: []corev1.Volume{{ Name: "the-name", VolumeSource: corev1.VolumeSource{ @@ -128,7 +128,7 @@ func TestRevisionSpecValidation(t *testing.T) { }}, }, RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Volumes: []corev1.Volume{{ Name: "the-name", VolumeSource: corev1.VolumeSource{ @@ -153,7 +153,7 @@ func TestRevisionSpecValidation(t *testing.T) { }}, }, RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Volumes: []corev1.Volume{{ Name: "the-name", VolumeSource: corev1.VolumeSource{ diff --git a/pkg/apis/serving/v1alpha1/service_conversion_test.go b/pkg/apis/serving/v1alpha1/service_conversion_test.go index 1de5f7a460c5..b21bbe7f59a2 100644 --- a/pkg/apis/serving/v1alpha1/service_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/service_conversion_test.go @@ -58,7 +58,7 @@ func TestServiceConversion(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -180,7 +180,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Volumes: []corev1.Volume{{ Name: "the-name", @@ -220,7 +220,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -271,7 +271,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Volumes: []corev1.Volume{{ Name: "the-name", @@ -311,7 +311,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -370,7 +370,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Volumes: []corev1.Volume{{ Name: "the-name", @@ -410,7 +410,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -475,7 +475,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Volumes: []corev1.Volume{{ Name: "the-name", @@ -515,7 +515,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", @@ -579,7 +579,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Volumes: []corev1.Volume{{ Name: "the-name", @@ -619,7 +619,7 @@ func TestServiceConversionFromDeprecated(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "robocop", Containers: []corev1.Container{{ Image: "busybox", diff --git a/pkg/apis/serving/v1alpha1/service_defaults_test.go b/pkg/apis/serving/v1alpha1/service_defaults_test.go index 535a794a25ff..402367cb3504 100644 --- a/pkg/apis/serving/v1alpha1/service_defaults_test.go +++ b/pkg/apis/serving/v1alpha1/service_defaults_test.go @@ -121,7 +121,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -238,7 +238,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -359,7 +359,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -418,7 +418,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -475,7 +475,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -548,7 +548,7 @@ func TestServiceDefaulting(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", }}, @@ -567,7 +567,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", Resources: defaultResources, @@ -629,7 +629,7 @@ func TestServiceDefaulting(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", }}, @@ -651,7 +651,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", Resources: defaultResources, @@ -679,7 +679,7 @@ func TestServiceDefaulting(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", }}, @@ -704,7 +704,7 @@ func TestServiceDefaulting(t *testing.T) { Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "blah", Resources: defaultResources, diff --git a/pkg/apis/serving/v1alpha1/service_validation_test.go b/pkg/apis/serving/v1alpha1/service_validation_test.go index 330839712a85..492de47a8ab4 100644 --- a/pkg/apis/serving/v1alpha1/service_validation_test.go +++ b/pkg/apis/serving/v1alpha1/service_validation_test.go @@ -50,7 +50,7 @@ func TestServiceValidation(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -77,7 +77,7 @@ func TestServiceValidation(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -127,7 +127,7 @@ func TestServiceValidation(t *testing.T) { DeprecatedRevisionTemplate: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -578,7 +578,7 @@ func TestServiceValidation(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -610,7 +610,7 @@ func TestServiceValidation(t *testing.T) { Spec: RevisionSpec{ DeprecatedConcurrencyModel: "Multi", RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -641,7 +641,7 @@ func TestServiceValidation(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -674,7 +674,7 @@ func TestServiceValidation(t *testing.T) { Template: &RevisionTemplateSpec{ Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -991,7 +991,7 @@ func TestImmutableServiceFields(t *testing.T) { }, Spec: RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, diff --git a/pkg/apis/serving/v1beta1/configuration_defaults_test.go b/pkg/apis/serving/v1beta1/configuration_defaults_test.go index 85f4b8a24bd3..7c14115548a5 100644 --- a/pkg/apis/serving/v1beta1/configuration_defaults_test.go +++ b/pkg/apis/serving/v1beta1/configuration_defaults_test.go @@ -39,7 +39,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -55,7 +55,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -68,7 +68,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -85,7 +85,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -99,7 +99,7 @@ func TestConfigurationDefaulting(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, diff --git a/pkg/apis/serving/v1beta1/configuration_validation_test.go b/pkg/apis/serving/v1beta1/configuration_validation_test.go index b43830e575f1..1726b6c16573 100644 --- a/pkg/apis/serving/v1beta1/configuration_validation_test.go +++ b/pkg/apis/serving/v1beta1/configuration_validation_test.go @@ -41,7 +41,7 @@ func TestConfigurationValidation(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -60,7 +60,7 @@ func TestConfigurationValidation(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -85,7 +85,7 @@ func TestConfigurationValidation(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -107,7 +107,7 @@ func TestConfigurationValidation(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -129,7 +129,7 @@ func TestConfigurationValidation(t *testing.T) { Name: "foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "hellworld", }}, @@ -170,7 +170,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -186,7 +186,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Spec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, @@ -208,7 +208,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -227,7 +227,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-bar", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, @@ -249,7 +249,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -268,7 +268,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -290,7 +290,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -309,7 +309,7 @@ func TestImmutableConfigurationFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, diff --git a/pkg/apis/serving/v1beta1/revision_defaults_test.go b/pkg/apis/serving/v1beta1/revision_defaults_test.go index 9a76aa42a28e..e1f474085682 100644 --- a/pkg/apis/serving/v1beta1/revision_defaults_test.go +++ b/pkg/apis/serving/v1beta1/revision_defaults_test.go @@ -51,7 +51,7 @@ func TestRevisionDefaulting(t *testing.T) { want: &Revision{ Spec: RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -78,7 +78,7 @@ func TestRevisionDefaulting(t *testing.T) { Spec: RevisionSpec{ ContainerConcurrency: 0, TimeoutSeconds: ptr.Int64(123), - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -89,7 +89,7 @@ func TestRevisionDefaulting(t *testing.T) { name: "readonly volumes", in: &Revision{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "foo", VolumeMounts: []corev1.VolumeMount{{ @@ -103,7 +103,7 @@ func TestRevisionDefaulting(t *testing.T) { }, want: &Revision{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "foo", VolumeMounts: []corev1.VolumeMount{{ @@ -129,7 +129,7 @@ func TestRevisionDefaulting(t *testing.T) { Spec: RevisionSpec{ ContainerConcurrency: 1, TimeoutSeconds: ptr.Int64(99), - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -144,7 +144,7 @@ func TestRevisionDefaulting(t *testing.T) { want: &Revision{ Spec: RevisionSpec{ TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds), - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, diff --git a/pkg/apis/serving/v1beta1/revision_types.go b/pkg/apis/serving/v1beta1/revision_types.go index e5bee971bc40..d42e8ec675eb 100644 --- a/pkg/apis/serving/v1beta1/revision_types.go +++ b/pkg/apis/serving/v1beta1/revision_types.go @@ -77,44 +77,9 @@ const ( RevisionContainerConcurrencyMax RevisionContainerConcurrencyType = 1000 ) -// PodSpec is our standing for corev1.PodSpec. -// TODO(mattmoor): We cannot inline PodSpec until 0.7 when the containers -// field it introduces has been available for a release because this -// definition doesn't "omitempty" the containers field, which means that -// 0.6 clients would send `containers: null`, which 0.5 webhooks will -// reject. Once we ship a webhook that will parse the null properly, we -// can switch to the PodSpec definition. -type PodSpec struct { - // ServiceAccountName holds the name of the Kubernetes service account - // as which the underlying K8s resources should be run. If unspecified - // this will default to the "default" service account for the namespace - // in which the Revision exists. - // This may be used to provide access to private container images by - // following: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account - // TODO(ZhiminXiang): verify the corresponding service account exists. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Containers holds the single container that defines the unit of - // execution for this Revision. - // In the context of a Revision, we disallow a number of the fields of - // this Container, including: name and lifecycle. - // See also the runtime contract for more information about the execution - // environment: - // https://github.com/knative/serving/blob/master/docs/runtime-contract.md - // +optional - Containers []corev1.Container `json:"containers,omitempty"` - - // Volumes defines a set of Kubernetes volumes to be mounted into the - // specified Container. Currently only ConfigMap and Secret volumes are - // supported. - // +optional - Volumes []corev1.Volume `json:"volumes,omitempty"` -} - // RevisionSpec holds the desired state of the Revision (from the client). type RevisionSpec struct { - PodSpec `json:",inline"` + corev1.PodSpec `json:",inline"` // ContainerConcurrency specifies the maximum allowed in-flight (concurrent) // requests per container of the Revision. Defaults to `0` which means diff --git a/pkg/apis/serving/v1beta1/revision_validation.go b/pkg/apis/serving/v1beta1/revision_validation.go index b8d7cd35ba8e..c30caa7800a1 100644 --- a/pkg/apis/serving/v1beta1/revision_validation.go +++ b/pkg/apis/serving/v1beta1/revision_validation.go @@ -105,33 +105,11 @@ func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og Re return nil } -// Validate helps implement apis.Validatable -func (ps *PodSpec) Validate(ctx context.Context) (errs *apis.FieldError) { - // TODO(mattmoor): Once we have the whole corev1.PodSpec, this should - // move to pkg/apis/serving/k8s_validation.go and needs a field mask. - - volumes, err := serving.ValidateVolumes(ps.Volumes) - if err != nil { - errs = errs.Also(err.ViaField("volumes")) - } - - switch len(ps.Containers) { - case 0: - errs = errs.Also(apis.ErrMissingField("containers")) - case 1: - errs = errs.Also(serving.ValidateContainer(ps.Containers[0], volumes). - ViaFieldIndex("containers", 0)) - default: - errs = errs.Also(apis.ErrMultipleOneOf("containers")) - } - return errs -} - // Validate implements apis.Validatable func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { err := rs.ContainerConcurrency.Validate(ctx).ViaField("containerConcurrency") - err = err.Also(rs.PodSpec.Validate(ctx)) + err = err.Also(serving.ValidatePodSpec(rs.PodSpec)) if rs.TimeoutSeconds != nil { ts := *rs.TimeoutSeconds diff --git a/pkg/apis/serving/v1beta1/revision_validation_test.go b/pkg/apis/serving/v1beta1/revision_validation_test.go index d6601ee44418..bb3f02f4f50d 100644 --- a/pkg/apis/serving/v1beta1/revision_validation_test.go +++ b/pkg/apis/serving/v1beta1/revision_validation_test.go @@ -43,7 +43,7 @@ func TestRevisionValidation(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -58,7 +58,7 @@ func TestRevisionValidation(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -132,7 +132,7 @@ func TestRevisionSpecValidation(t *testing.T) { }{{ name: "valid", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -142,7 +142,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "with volume (ok)", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", VolumeMounts: []corev1.VolumeMount{{ @@ -165,7 +165,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "with volume name collision", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", VolumeMounts: []corev1.VolumeMount{{ @@ -196,7 +196,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "bad pod spec", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Name: "steve", Image: "helloworld", @@ -207,7 +207,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "missing container", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{}, }, }, @@ -215,7 +215,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "too many containers", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }, { @@ -227,7 +227,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "exceed max timeout", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -240,7 +240,7 @@ func TestRevisionSpecValidation(t *testing.T) { }, { name: "negative timeout", rs: &RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -276,7 +276,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -288,7 +288,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -303,7 +303,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -319,7 +319,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -345,7 +345,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -357,7 +357,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -379,7 +379,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -392,7 +392,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -415,7 +415,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -428,7 +428,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -450,7 +450,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld", }}, @@ -463,7 +463,7 @@ func TestImmutableFields(t *testing.T) { Name: "valid", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/pkg/apis/serving/v1beta1/service_defaults_test.go b/pkg/apis/serving/v1beta1/service_defaults_test.go index 5b11ac0aeb7f..ad58d22146de 100644 --- a/pkg/apis/serving/v1beta1/service_defaults_test.go +++ b/pkg/apis/serving/v1beta1/service_defaults_test.go @@ -40,7 +40,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Resources: defaultResources, }}, @@ -64,7 +64,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -79,7 +79,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -104,7 +104,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -120,7 +120,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, @@ -145,7 +145,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -173,7 +173,7 @@ func TestServiceDefaulting(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", Resources: defaultResources, diff --git a/pkg/apis/serving/v1beta1/service_validation_test.go b/pkg/apis/serving/v1beta1/service_validation_test.go index 027d624cd365..14ed9fbfbcb0 100644 --- a/pkg/apis/serving/v1beta1/service_validation_test.go +++ b/pkg/apis/serving/v1beta1/service_validation_test.go @@ -32,7 +32,7 @@ func TestServiceValidation(t *testing.T) { goodConfigSpec := ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -136,7 +136,7 @@ func TestServiceValidation(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, @@ -188,7 +188,7 @@ func TestImmutableServiceFields(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -212,7 +212,7 @@ func TestImmutableServiceFields(t *testing.T) { ConfigurationSpec: ConfigurationSpec{ Template: RevisionTemplateSpec{ Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, @@ -242,7 +242,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -269,7 +269,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-bar", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, @@ -299,7 +299,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -326,7 +326,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-bar", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, @@ -356,7 +356,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:foo", }}, @@ -383,7 +383,7 @@ func TestImmutableServiceFields(t *testing.T) { Name: "byo-name-foo", }, Spec: RevisionSpec{ - PodSpec: PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "helloworld:bar", }}, diff --git a/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go b/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go index 2ab7514cc701..da1db5915a47 100644 --- a/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go @@ -23,7 +23,6 @@ package v1beta1 import ( apis "github.com/knative/pkg/apis" duckv1beta1 "github.com/knative/pkg/apis/duck/v1beta1" - v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -139,36 +138,6 @@ func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodSpec) DeepCopyInto(out *PodSpec) { - *out = *in - if in.Containers != nil { - in, out := &in.Containers, &out.Containers - *out = make([]v1.Container, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]v1.Volume, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSpec. -func (in *PodSpec) DeepCopy() *PodSpec { - if in == nil { - return nil - } - out := new(PodSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Revision) DeepCopyInto(out *Revision) { *out = *in diff --git a/pkg/reconciler/configuration/configuration_test.go b/pkg/reconciler/configuration/configuration_test.go index 710273827295..50c8b6c77648 100644 --- a/pkg/reconciler/configuration/configuration_test.go +++ b/pkg/reconciler/configuration/configuration_test.go @@ -45,7 +45,7 @@ import ( var revisionSpec = v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/pkg/reconciler/configuration/queueing_test.go b/pkg/reconciler/configuration/queueing_test.go index 1744fa5e754f..cc69a22290b1 100644 --- a/pkg/reconciler/configuration/queueing_test.go +++ b/pkg/reconciler/configuration/queueing_test.go @@ -60,7 +60,7 @@ func getTestConfiguration() *v1alpha1.Configuration { Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "test-account", // corev1.Container has a lot of setting. We try to pass many // of them here to verify that we pass through the settings to diff --git a/pkg/reconciler/revision/queueing_test.go b/pkg/reconciler/revision/queueing_test.go index 4f67211e30b4..8ebd6379493b 100644 --- a/pkg/reconciler/revision/queueing_test.go +++ b/pkg/reconciler/revision/queueing_test.go @@ -93,7 +93,7 @@ func testRevision() *v1alpha1.Revision { }, Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ // corev1.Container has a lot of setting. We try to pass many // of them here to verify that we pass through the settings to // derived objects. diff --git a/pkg/reconciler/revision/resources/imagecache_test.go b/pkg/reconciler/revision/resources/imagecache_test.go index 7b2c794a6952..2d379f216d6f 100644 --- a/pkg/reconciler/revision/resources/imagecache_test.go +++ b/pkg/reconciler/revision/resources/imagecache_test.go @@ -95,7 +95,7 @@ func TestMakeImageCache(t *testing.T) { Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ ContainerConcurrency: 1, - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ ServiceAccountName: "privilegeless", }, }, diff --git a/pkg/reconciler/revision/resources/queue_test.go b/pkg/reconciler/revision/resources/queue_test.go index fb76d6c87999..907e14dc307d 100644 --- a/pkg/reconciler/revision/resources/queue_test.go +++ b/pkg/reconciler/revision/resources/queue_test.go @@ -93,7 +93,7 @@ func TestMakeQueueContainer(t *testing.T) { RevisionSpec: v1beta1.RevisionSpec{ ContainerConcurrency: 1, TimeoutSeconds: ptr.Int64(45), - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Ports: []corev1.ContainerPort{{ ContainerPort: 1955, diff --git a/pkg/reconciler/revision/table_test.go b/pkg/reconciler/revision/table_test.go index 8e672792be76..d5018b91b3d1 100644 --- a/pkg/reconciler/revision/table_test.go +++ b/pkg/reconciler/revision/table_test.go @@ -721,7 +721,7 @@ func rev(namespace, name string, ro ...RevisionOption) *v1alpha1.Revision { }, Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/pkg/reconciler/route/table_test.go b/pkg/reconciler/route/table_test.go index 28d92cb7ae13..2d9590fc21b4 100644 --- a/pkg/reconciler/route/table_test.go +++ b/pkg/reconciler/route/table_test.go @@ -2091,7 +2091,7 @@ func cfg(namespace, name string, co ...ConfigOption) *v1alpha1.Configuration { Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/pkg/reconciler/route/traffic/traffic_test.go b/pkg/reconciler/route/traffic/traffic_test.go index ad3484ab162b..b6306d9987e4 100644 --- a/pkg/reconciler/route/traffic/traffic_test.go +++ b/pkg/reconciler/route/traffic/traffic_test.go @@ -1005,7 +1005,7 @@ func testConfig(name string) *v1alpha1.Configuration { Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "test-image", }}, diff --git a/pkg/reconciler/testing/functional.go b/pkg/reconciler/testing/functional.go index 8d4e476df18c..8916a2d0b7b6 100644 --- a/pkg/reconciler/testing/functional.go +++ b/pkg/reconciler/testing/functional.go @@ -87,7 +87,7 @@ func WithInlineRollout(s *v1alpha1.Service) { Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: "busybox", }}, diff --git a/test/crd.go b/test/crd.go index 9cd9aad63da5..cdfc99c7db29 100644 --- a/test/crd.go +++ b/test/crd.go @@ -101,7 +101,7 @@ func ConfigurationSpec(imagePath string, options *Options) *v1alpha1.Configurati Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ RevisionSpec: v1beta1.RevisionSpec{ - PodSpec: v1beta1.PodSpec{ + PodSpec: corev1.PodSpec{ Containers: []corev1.Container{{ Image: imagePath, Resources: options.ContainerResources,