mirror of https://github.com/knative/client.git
Show envFrom when running describe service or revision (#630)
Fixes #626 Show envFrom when running describe service or revison. The result like: EnvFrom: cm:test1, cm:test2
This commit is contained in:
parent
0e5d1a86c8
commit
d82d55731c
|
|
@ -14,6 +14,16 @@
|
||||||
////
|
////
|
||||||
|
|
||||||
|
|
||||||
|
## v0.13.0 (unreleased)
|
||||||
|
|
||||||
|
[cols="1,10,3", options="header", width="100%"]
|
||||||
|
|===
|
||||||
|
| | Description | PR
|
||||||
|
|
||||||
|
| 🐛
|
||||||
|
| Show envFrom when running describe service or revision
|
||||||
|
| https://github.com/knative/client/pull/630
|
||||||
|
|
||||||
## v0.12.0 (2020-01-29)
|
## v0.12.0 (2020-01-29)
|
||||||
|
|
||||||
[cols="1,10,3", options="header", width="100%"]
|
[cols="1,10,3", options="header", width="100%"]
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ func describe(w io.Writer, revision *v1alpha1.Revision, service *v1alpha1.Servic
|
||||||
WriteImage(dw, revision)
|
WriteImage(dw, revision)
|
||||||
WritePort(dw, revision)
|
WritePort(dw, revision)
|
||||||
WriteEnv(dw, revision, printDetails)
|
WriteEnv(dw, revision, printDetails)
|
||||||
|
WriteEnvFrom(dw, revision, printDetails)
|
||||||
WriteScale(dw, revision)
|
WriteScale(dw, revision)
|
||||||
WriteConcurrencyOptions(dw, revision)
|
WriteConcurrencyOptions(dw, revision)
|
||||||
WriteResources(dw, revision)
|
WriteResources(dw, revision)
|
||||||
|
|
@ -190,6 +191,13 @@ func WriteEnv(dw printers.PrefixWriter, revision *v1alpha1.Revision, printDetail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WriteEnvFrom(dw printers.PrefixWriter, revision *v1alpha1.Revision, printDetails bool) {
|
||||||
|
envFrom := stringifyEnvFrom(revision)
|
||||||
|
if envFrom != nil {
|
||||||
|
commands.WriteSliceDesc(dw, envFrom, "EnvFrom", printDetails)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WriteScale(dw printers.PrefixWriter, revision *v1alpha1.Revision) {
|
func WriteScale(dw printers.PrefixWriter, revision *v1alpha1.Revision) {
|
||||||
// Scale spec if given
|
// Scale spec if given
|
||||||
scale, err := clientserving.ScalingInfo(&revision.ObjectMeta)
|
scale, err := clientserving.ScalingInfo(&revision.ObjectMeta)
|
||||||
|
|
@ -274,3 +282,21 @@ func stringifyEnv(revision *v1alpha1.Revision) []string {
|
||||||
}
|
}
|
||||||
return envVars
|
return envVars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stringifyEnvFrom(revision *v1alpha1.Revision) []string {
|
||||||
|
container, err := clientserving.ContainerOfRevisionSpec(&revision.Spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var result []string
|
||||||
|
for _, envFromSource := range container.EnvFrom {
|
||||||
|
if envFromSource.ConfigMapRef != nil {
|
||||||
|
result = append(result, "cm:"+envFromSource.ConfigMapRef.Name)
|
||||||
|
}
|
||||||
|
if envFromSource.SecretRef != nil {
|
||||||
|
result = append(result, "secret:"+envFromSource.SecretRef.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ func TestDescribeRevisionBasic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Assert(t, util.ContainsAll(data, "Image:", "gcr.io/test/image", "++ Ready", "Port:", "8080"))
|
assert.Assert(t, util.ContainsAll(data, "Image:", "gcr.io/test/image", "++ Ready", "Port:", "8080"))
|
||||||
|
assert.Assert(t, util.ContainsAll(data, "EnvFrom:", "cm:test1, cm:test2"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestRevision(revision string, gen int64) v1alpha1.Revision {
|
func createTestRevision(revision string, gen int64) v1alpha1.Revision {
|
||||||
|
|
@ -153,6 +154,10 @@ func createTestRevision(revision string, gen int64) v1alpha1.Revision {
|
||||||
{Name: "env1", Value: "eval1"},
|
{Name: "env1", Value: "eval1"},
|
||||||
{Name: "env2", Value: "eval2"},
|
{Name: "env2", Value: "eval2"},
|
||||||
},
|
},
|
||||||
|
EnvFrom: []v1.EnvFromSource{
|
||||||
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test1"}}},
|
||||||
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test2"}}},
|
||||||
|
},
|
||||||
Ports: []v1.ContainerPort{
|
Ports: []v1.ContainerPort{
|
||||||
{ContainerPort: 8080},
|
{ContainerPort: 8080},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ func writeRevisions(dw printers.PrefixWriter, revisions []*revisionDesc, printDe
|
||||||
if printDetails {
|
if printDetails {
|
||||||
revision.WritePort(section, revisionDesc.revision)
|
revision.WritePort(section, revisionDesc.revision)
|
||||||
revision.WriteEnv(section, revisionDesc.revision, printDetails)
|
revision.WriteEnv(section, revisionDesc.revision, printDetails)
|
||||||
|
revision.WriteEnvFrom(section, revisionDesc.revision, printDetails)
|
||||||
revision.WriteScale(section, revisionDesc.revision)
|
revision.WriteScale(section, revisionDesc.revision)
|
||||||
revision.WriteConcurrencyOptions(section, revisionDesc.revision)
|
revision.WriteConcurrencyOptions(section, revisionDesc.revision)
|
||||||
revision.WriteResources(section, revisionDesc.revision)
|
revision.WriteResources(section, revisionDesc.revision)
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,8 @@ func TestServiceDescribeVerbose(t *testing.T) {
|
||||||
|
|
||||||
assert.Assert(t, cmp.Regexp("Cluster:\\s+http://foo.default.svc.cluster.local", output))
|
assert.Assert(t, cmp.Regexp("Cluster:\\s+http://foo.default.svc.cluster.local", output))
|
||||||
assert.Assert(t, util.ContainsAll(output, "Image", "Name", "gcr.io/test/image (at 123456)", "50%", "(0s)"))
|
assert.Assert(t, util.ContainsAll(output, "Image", "Name", "gcr.io/test/image (at 123456)", "50%", "(0s)"))
|
||||||
assert.Assert(t, util.ContainsAll(output, "Env:", "label1=lval1\n", "label2=lval2\n"))
|
assert.Assert(t, util.ContainsAll(output, "Env:", "env1=eval1\n", "env2=eval2\n"))
|
||||||
|
assert.Assert(t, util.ContainsAll(output, "EnvFrom:", "cm:test1\n", "cm:test2\n"))
|
||||||
assert.Assert(t, util.ContainsAll(output, "Annotations:", "anno1=aval1\n", "anno2=aval2\n"))
|
assert.Assert(t, util.ContainsAll(output, "Annotations:", "anno1=aval1\n", "anno2=aval2\n"))
|
||||||
assert.Assert(t, util.ContainsAll(output, "Labels:", "label1=lval1\n", "label2=lval2\n"))
|
assert.Assert(t, util.ContainsAll(output, "Labels:", "label1=lval1\n", "label2=lval2\n"))
|
||||||
assert.Assert(t, util.ContainsAll(output, "[1]", "[2]"))
|
assert.Assert(t, util.ContainsAll(output, "[1]", "[2]"))
|
||||||
|
|
@ -636,6 +637,10 @@ func createTestRevision(revision string, gen int64) v1alpha1.Revision {
|
||||||
{Name: "env1", Value: "eval1"},
|
{Name: "env1", Value: "eval1"},
|
||||||
{Name: "env2", Value: "eval2"},
|
{Name: "env2", Value: "eval2"},
|
||||||
},
|
},
|
||||||
|
EnvFrom: []v1.EnvFromSource{
|
||||||
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test1"}}},
|
||||||
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test2"}}},
|
||||||
|
},
|
||||||
Ports: []v1.ContainerPort{
|
Ports: []v1.ContainerPort{
|
||||||
{ContainerPort: 8080},
|
{ContainerPort: 8080},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue