mirror of https://github.com/knative/client.git
add serviceaccount to service describe (#472)
This commit is contained in:
parent
44dafbd780
commit
c5b3f7af0d
|
|
@ -199,6 +199,9 @@ func writeService(dw printers.PrefixWriter, service *v1alpha1.Service) {
|
|||
url := service.Status.Address.GetURL()
|
||||
dw.WriteAttribute("Address", url.String())
|
||||
}
|
||||
if (service.Spec.Template != nil) && (service.Spec.Template.Spec.ServiceAccountName != "") {
|
||||
dw.WriteAttribute("ServiceAccount", service.Spec.Template.Spec.ServiceAccountName)
|
||||
}
|
||||
}
|
||||
|
||||
// Write out revisions associated with this service. By default only active
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func TestServiceDescribeBasic(t *testing.T) {
|
|||
// Recording:
|
||||
r := client.Recorder()
|
||||
// Prepare service
|
||||
expectedService := createTestService("foo", []string{"rev1"}, goodConditions())
|
||||
expectedService := createTestServiceWithServiceAccount("foo", []string{"rev1"}, "default-sa", goodConditions())
|
||||
|
||||
// Get service & revision
|
||||
r.GetService("foo", &expectedService, nil)
|
||||
|
|
@ -69,6 +69,7 @@ func TestServiceDescribeBasic(t *testing.T) {
|
|||
assert.Assert(t, cmp.Regexp(`(?m)\s*Annotations:.*\.\.\.$`, output))
|
||||
assert.Assert(t, util.ContainsAll(output, "Labels:", "label1=lval1, label2=lval2\n"))
|
||||
assert.Assert(t, util.ContainsAll(output, "[1]"))
|
||||
assert.Assert(t, cmp.Regexp("ServiceAccount: \\s+default-sa", output))
|
||||
|
||||
assert.Equal(t, strings.Count(output, "rev1"), 1)
|
||||
|
||||
|
|
@ -546,6 +547,26 @@ func createTestService(name string, revisionNames []string, conditions duckv1.Co
|
|||
}
|
||||
service.Status.Traffic = trafficTargets
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
||||
|
||||
func createTestServiceWithServiceAccount(name string, revisionNames []string, serviceAccountName string, conditions duckv1.Conditions) v1alpha1.Service {
|
||||
service := createTestService(name, revisionNames, conditions)
|
||||
|
||||
if serviceAccountName != "" {
|
||||
template := v1alpha1.RevisionTemplateSpec{
|
||||
Spec: v1alpha1.RevisionSpec{
|
||||
RevisionSpec: servingv1.RevisionSpec{
|
||||
PodSpec: v1.PodSpec{
|
||||
ServiceAccountName: serviceAccountName,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
service.Spec.Template = &template
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue