From 9280dc38af362cf6da13f5329dbff2ce48147306 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 7 Aug 2024 08:42:35 +1000 Subject: [PATCH] fix: nil pointer check for get/list projects --- cmd/get.go | 6 +++++- cmd/list.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 8e378078..6e984658 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -102,7 +102,11 @@ var getProjectCmd = &cobra.Command{ returnNonEmptyString(fmt.Sprintf("%v", project.GitURL)), returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), returnNonEmptyString(fmt.Sprintf("%v", productionRoute)), - returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, *project.DevelopmentEnvironmentsLimit)), + } + if project.DevelopmentEnvironmentsLimit != nil { + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, *project.DevelopmentEnvironmentsLimit))) + } else { + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, 0))) } projHeader := []string{"ID", "ProjectName", "GitUrl", "ProductionEnvironment", "ProductionRoute", "DevEnvironments"} if wide { diff --git a/cmd/list.go b/cmd/list.go index 93d2b4f1..4dab14b9 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -75,7 +75,11 @@ var listProjectsCmd = &cobra.Command{ returnNonEmptyString(fmt.Sprintf("%v", project.GitURL)), returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), returnNonEmptyString(fmt.Sprintf("%v", productionRoute)), - returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, *project.DevelopmentEnvironmentsLimit)), + } + if project.DevelopmentEnvironmentsLimit != nil { + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, *project.DevelopmentEnvironmentsLimit))) + } else { + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, 0))) } // if wide { // projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", project.AutoIdle)))