fix: Fix var initialization in lib/service function (#1107)

This commit is contained in:
David Simansky 2020-11-10 14:37:58 +01:00 committed by GitHub
parent 1b7985eac5
commit 9610c933b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -43,16 +43,6 @@ type ExpectedRevisionListOption func(*servingv1.RevisionList)
// ExpectedKNExportOption enables further configuration of a Export. // ExpectedKNExportOption enables further configuration of a Export.
type ExpectedKNExportOption func(*clientv1alpha1.Export) type ExpectedKNExportOption func(*clientv1alpha1.Export)
var revisionSpec = servingv1.RevisionSpec{
PodSpec: corev1.PodSpec{
Containers: []corev1.Container{{
Image: pkgtest.ImagePath("helloworld"),
}},
EnableServiceLinks: ptr.Bool(false),
},
TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds),
}
// ServiceCreate verifies given service creation in sync mode and also verifies output // ServiceCreate verifies given service creation in sync mode and also verifies output
func ServiceCreate(r *KnRunResultCollector, serviceName string) { func ServiceCreate(r *KnRunResultCollector, serviceName string) {
out := r.KnTest().Kn().Run("service", "create", serviceName, "--image", pkgtest.ImagePath("helloworld")) out := r.KnTest().Kn().Run("service", "create", serviceName, "--image", pkgtest.ImagePath("helloworld"))
@ -222,7 +212,7 @@ func BuildConfigurationSpec(co ...servingtest.ConfigOption) *servingv1.Configura
c := &servingv1.Configuration{ c := &servingv1.Configuration{
Spec: servingv1.ConfigurationSpec{ Spec: servingv1.ConfigurationSpec{
Template: servingv1.RevisionTemplateSpec{ Template: servingv1.RevisionTemplateSpec{
Spec: *revisionSpec.DeepCopy(), Spec: *BuildRevisionSpec(pkgtest.ImagePath("helloworld")),
}, },
}, },
} }
@ -233,6 +223,19 @@ func BuildConfigurationSpec(co ...servingtest.ConfigOption) *servingv1.Configura
return &c.Spec return &c.Spec
} }
// BuildRevisionSpec for provided image
func BuildRevisionSpec(image string) *servingv1.RevisionSpec {
return &servingv1.RevisionSpec{
PodSpec: corev1.PodSpec{
Containers: []corev1.Container{{
Image: image,
}},
EnableServiceLinks: ptr.Bool(false),
},
TimeoutSeconds: ptr.Int64(config.DefaultRevisionTimeoutSeconds),
}
}
// BuildServiceWithOptions returns ksvc with options provided // BuildServiceWithOptions returns ksvc with options provided
func BuildServiceWithOptions(name string, so ...servingtest.ServiceOption) *servingv1.Service { func BuildServiceWithOptions(name string, so ...servingtest.ServiceOption) *servingv1.Service {
svc := servingtest.ServiceWithoutNamespace(name, so...) svc := servingtest.ServiceWithoutNamespace(name, so...)