Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

kubeless function describe panic #839

Merged
merged 1 commit into from Jun 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions cmd/kubeless/function/describe.go
Expand Up @@ -79,18 +79,24 @@ func print(f kubelessApi.Function, name, output string) error {
if err != nil {
return err
}
env, err := json.Marshal(f.Spec.Deployment.Spec.Template.Spec.Containers[0].Env)
if err != nil {
return err
var env, memory string
if len(f.Spec.Deployment.Spec.Template.Spec.Containers) != 0 {
b, err := json.Marshal(f.Spec.Deployment.Spec.Template.Spec.Containers[0].Env)
if err != nil {
return err
}
env = string(b)
memory = f.Spec.Deployment.Spec.Template.Spec.Containers[0].Resources.Requests.Memory().String()
}

table.AddRow("Name:", name)
table.AddRow("Namespace:", fmt.Sprintf(f.ObjectMeta.Namespace))
table.AddRow("Handler:", fmt.Sprintf(f.Spec.Handler))
table.AddRow("Runtime:", fmt.Sprintf(f.Spec.Runtime))
table.AddRow("Label:", fmt.Sprintf(string(label)))
table.AddRow("Envvar:", fmt.Sprintf(string(env)))
table.AddRow("Memory:", fmt.Sprintf(f.Spec.Deployment.Spec.Template.Spec.Containers[0].Resources.Requests.Memory().String()))
table.AddRow("Dependencies:", fmt.Sprintf(f.Spec.Deps))
table.AddRow("Namespace:", f.ObjectMeta.Namespace)
table.AddRow("Handler:", f.Spec.Handler)
table.AddRow("Runtime:", f.Spec.Runtime)
table.AddRow("Label:", string(label))
table.AddRow("Envvar:", env)
table.AddRow("Memory:", memory)
table.AddRow("Dependencies:", f.Spec.Deps)
fmt.Println(table)
case "json":
b, err := json.MarshalIndent(f, "", " ")
Expand Down