From 112767dcd06d32094be34d8252920526c95b980e Mon Sep 17 00:00:00 2001 From: Daniel Cooper Date: Fri, 21 Aug 2020 11:21:03 +0100 Subject: [PATCH 1/3] Add supported platform APIs to `pack report` (#810) Signed-off-by: Daniel Cooper --- internal/commands/report.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/commands/report.go b/internal/commands/report.go index 500cdbb0f..350a3dca5 100644 --- a/internal/commands/report.go +++ b/internal/commands/report.go @@ -11,6 +11,7 @@ import ( "github.com/spf13/cobra" + "github.com/buildpacks/pack/internal/build" "github.com/buildpacks/pack/internal/builder" "github.com/buildpacks/pack/internal/config" "github.com/buildpacks/pack/logging" @@ -48,6 +49,8 @@ func generateOutput(writer io.Writer, version string, explicit bool) error { Default Lifecycle Version: {{ .DefaultLifecycleVersion }} +Supported Platform APIs: {{ .SupportedPlatformAPIs }} + Config: {{ .Config -}}`)) @@ -68,11 +71,20 @@ Config: configData = strings.TrimRight(padded.String(), " \n") } + platformAPIs := "" + for _, api := range build.SupportedPlatformAPIVersions { + if len(platformAPIs) > 0 { + platformAPIs += "," + } + platformAPIs = fmt.Sprintf("%s %s", platformAPIs, api) + } + return tpl.Execute(writer, map[string]string{ "Version": version, "OS": runtime.GOOS, "Arch": runtime.GOARCH, "DefaultLifecycleVersion": builder.DefaultLifecycleVersion, + "SupportedPlatformAPIs": platformAPIs, "Config": configData, }) } From 6f55535b885016e5929e360f577d661a7e9565e0 Mon Sep 17 00:00:00 2001 From: Daniel Cooper Date: Fri, 21 Aug 2020 14:44:31 +0100 Subject: [PATCH 2/3] update the acceptance test report output template file Signed-off-by: Daniel Cooper --- acceptance/testdata/pack_fixtures/report_output.txt | 2 ++ internal/commands/report.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/acceptance/testdata/pack_fixtures/report_output.txt b/acceptance/testdata/pack_fixtures/report_output.txt index 1b14e5f95..66cf032d8 100644 --- a/acceptance/testdata/pack_fixtures/report_output.txt +++ b/acceptance/testdata/pack_fixtures/report_output.txt @@ -4,5 +4,7 @@ Pack: Default Lifecycle Version: 0.9.1 +Supported Platform APIs: 0.3, 0.4 + Config: default-builder-image = "{{ .DefaultBuilder }}" diff --git a/internal/commands/report.go b/internal/commands/report.go index 350a3dca5..35ae678b2 100644 --- a/internal/commands/report.go +++ b/internal/commands/report.go @@ -74,9 +74,9 @@ Config: platformAPIs := "" for _, api := range build.SupportedPlatformAPIVersions { if len(platformAPIs) > 0 { - platformAPIs += "," + platformAPIs += ", " } - platformAPIs = fmt.Sprintf("%s %s", platformAPIs, api) + platformAPIs = fmt.Sprintf("%s%s", platformAPIs, api) } return tpl.Execute(writer, map[string]string{ From 1a41c23f5f6155d48ab32287914c128b45237892 Mon Sep 17 00:00:00 2001 From: Daniel Cooper Date: Tue, 25 Aug 2020 09:50:58 +0100 Subject: [PATCH 3/3] Format supported platform APIs using string join Signed-off-by: Daniel Cooper --- internal/commands/report.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/commands/report.go b/internal/commands/report.go index 35ae678b2..c3cc76608 100644 --- a/internal/commands/report.go +++ b/internal/commands/report.go @@ -71,13 +71,7 @@ Config: configData = strings.TrimRight(padded.String(), " \n") } - platformAPIs := "" - for _, api := range build.SupportedPlatformAPIVersions { - if len(platformAPIs) > 0 { - platformAPIs += ", " - } - platformAPIs = fmt.Sprintf("%s%s", platformAPIs, api) - } + platformAPIs := strings.Join(build.SupportedPlatformAPIVersions.AsStrings(), ", ") return tpl.Execute(writer, map[string]string{ "Version": version,