From b6f8aa7beac5a43c54bc996631497e7fbbde630f Mon Sep 17 00:00:00 2001 From: Sean Lin Date: Fri, 6 Aug 2021 10:43:13 -0700 Subject: [PATCH] Add additional nil check (#156) Signed-off-by: Sean Lin --- flytectl/cmd/get/launch_plan.go | 12 +++++++----- flytectl/cmd/get/task.go | 16 +++++++++++----- flytectl/cmd/get/workflow.go | 18 +++++++++++++----- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/flytectl/cmd/get/launch_plan.go b/flytectl/cmd/get/launch_plan.go index 34bf10cf1a..f146740bd7 100644 --- a/flytectl/cmd/get/launch_plan.go +++ b/flytectl/cmd/get/launch_plan.go @@ -128,11 +128,13 @@ func LaunchplanToTableProtoMessages(l []*admin.LaunchPlan) []proto.Message { messages := make([]proto.Message, 0, len(l)) for _, m := range l { m := proto.Clone(m).(*admin.LaunchPlan) - if m.Closure.ExpectedInputs != nil { - printer.FormatParameterDescriptions(m.Closure.ExpectedInputs.Parameters) - } - if m.Closure.ExpectedOutputs != nil { - printer.FormatVariableDescriptions(m.Closure.ExpectedOutputs.Variables) + if m.Closure != nil { + if m.Closure.ExpectedInputs != nil { + printer.FormatParameterDescriptions(m.Closure.ExpectedInputs.Parameters) + } + if m.Closure.ExpectedOutputs != nil { + printer.FormatVariableDescriptions(m.Closure.ExpectedOutputs.Variables) + } } messages = append(messages, m) } diff --git a/flytectl/cmd/get/task.go b/flytectl/cmd/get/task.go index 9f9a7b9861..a9f0859d58 100644 --- a/flytectl/cmd/get/task.go +++ b/flytectl/cmd/get/task.go @@ -116,11 +116,17 @@ func TaskToTableProtoMessages(l []*admin.Task) []proto.Message { messages := make([]proto.Message, 0, len(l)) for _, m := range l { m := proto.Clone(m).(*admin.Task) - if m.Closure.CompiledTask.Template.Interface.Inputs != nil { - printer.FormatVariableDescriptions(m.Closure.CompiledTask.Template.Interface.Inputs.Variables) - } - if m.Closure.CompiledTask.Template.Interface.Outputs != nil { - printer.FormatVariableDescriptions(m.Closure.CompiledTask.Template.Interface.Outputs.Variables) + if m.Closure != nil && m.Closure.CompiledTask != nil { + if m.Closure.CompiledTask.Template != nil { + if m.Closure.CompiledTask.Template.Interface != nil { + if m.Closure.CompiledTask.Template.Interface.Inputs != nil { + printer.FormatVariableDescriptions(m.Closure.CompiledTask.Template.Interface.Inputs.Variables) + } + if m.Closure.CompiledTask.Template.Interface.Outputs != nil { + printer.FormatVariableDescriptions(m.Closure.CompiledTask.Template.Interface.Outputs.Variables) + } + } + } } messages = append(messages, m) } diff --git a/flytectl/cmd/get/workflow.go b/flytectl/cmd/get/workflow.go index 704f7a0519..28c4372628 100644 --- a/flytectl/cmd/get/workflow.go +++ b/flytectl/cmd/get/workflow.go @@ -104,11 +104,19 @@ func WorkflowToTableProtoMessages(l []*admin.Workflow) []proto.Message { messages := make([]proto.Message, 0, len(l)) for _, m := range l { m := proto.Clone(m).(*admin.Workflow) - if m.Closure.CompiledWorkflow.Primary.Template.Interface.Inputs != nil { - printer.FormatVariableDescriptions(m.Closure.CompiledWorkflow.Primary.Template.Interface.Inputs.Variables) - } - if m.Closure.CompiledWorkflow.Primary.Template.Interface.Outputs != nil { - printer.FormatVariableDescriptions(m.Closure.CompiledWorkflow.Primary.Template.Interface.Outputs.Variables) + if m.Closure != nil && m.Closure.CompiledWorkflow != nil { + if m.Closure.CompiledWorkflow.Primary != nil { + if m.Closure.CompiledWorkflow.Primary.Template != nil { + if m.Closure.CompiledWorkflow.Primary.Template.Interface != nil { + if m.Closure.CompiledWorkflow.Primary.Template.Interface.Inputs != nil { + printer.FormatVariableDescriptions(m.Closure.CompiledWorkflow.Primary.Template.Interface.Inputs.Variables) + } + if m.Closure.CompiledWorkflow.Primary.Template.Interface.Outputs != nil { + printer.FormatVariableDescriptions(m.Closure.CompiledWorkflow.Primary.Template.Interface.Outputs.Variables) + } + } + } + } } messages = append(messages, m) }