diff --git a/internal/builder/inspect.go b/internal/builder/inspect.go index 263eb0222..c42a89213 100644 --- a/internal/builder/inspect.go +++ b/internal/builder/inspect.go @@ -79,7 +79,7 @@ func (i *Inspector) Inspect(name string, daemon bool, orderDetectionDepth int) ( stackID, err := labelManager.StackID() if err != nil { - return Info{}, fmt.Errorf("reading image stack id: %w", err) + // TODO log warn } mixins, err := labelManager.Mixins() diff --git a/internal/builder/inspect_test.go b/internal/builder/inspect_test.go index f2cf0301d..38411ba2c 100644 --- a/internal/builder/inspect_test.go +++ b/internal/builder/inspect_test.go @@ -301,7 +301,7 @@ func testInspect(t *testing.T, when spec.G, it spec.S) { }) }) - when("label manager returns an error for `StackID`", func() { + when("label manager does not return an error for `StackID`", func() { it("returns the wrapped error", func() { expectedBaseError := errors.New("label not found") @@ -314,7 +314,7 @@ func testInspect(t *testing.T, when spec.G, it spec.S) { ) _, err := inspector.Inspect(testBuilderName, true, pubbldr.OrderDetectionNone) - assert.ErrorWithMessage(err, "reading image stack id: label not found") + assert.Nil(err) }) }) diff --git a/internal/builder/writer/human_readable.go b/internal/builder/writer/human_readable.go index ab7b677b8..25a339a93 100644 --- a/internal/builder/writer/human_readable.go +++ b/internal/builder/writer/human_readable.go @@ -46,9 +46,9 @@ Created By: {{ end -}} Trusted: {{.Trusted}} - +{{ if ne .Info.Stack "" -}} Stack: - ID: {{ .Info.Stack }} + ID: {{ .Info.Stack }}{{ end -}} {{- if .Verbose}} {{- if ne (len .Info.Mixins) 0 }} Mixins: diff --git a/internal/builder/writer/structured_format.go b/internal/builder/writer/structured_format.go index b50d7b009..66983d080 100644 --- a/internal/builder/writer/structured_format.go +++ b/internal/builder/writer/structured_format.go @@ -38,7 +38,7 @@ type Stack struct { type BuilderInfo struct { Description string `json:"description,omitempty" yaml:"description,omitempty" toml:"description,omitempty"` CreatedBy builder.CreatorMetadata `json:"created_by" yaml:"created_by" toml:"created_by"` - Stack Stack `json:"stack" yaml:"stack" toml:"stack"` + Stack *Stack `json:"stack,omitempty" yaml:"stack,omitempty" toml:"stack,omitempty"` Lifecycle Lifecycle `json:"lifecycle" yaml:"lifecycle" toml:"lifecycle"` RunImages []RunImage `json:"run_images" yaml:"run_images" toml:"run_images"` Buildpacks []dist.ModuleInfo `json:"buildpacks" yaml:"buildpacks" toml:"buildpacks"` @@ -69,7 +69,10 @@ func (w *StructuredFormat) Print( outputInfo := InspectOutput{SharedBuilderInfo: builderInfo} if local != nil { - stack := Stack{ID: local.Stack} + var stack *Stack + if local.Stack != "" { + stack = &Stack{ID: local.Stack} + } if logger.IsVerbose() { stack.Mixins = local.Mixins @@ -93,7 +96,10 @@ func (w *StructuredFormat) Print( } if remote != nil { - stack := Stack{ID: remote.Stack} + var stack *Stack + if remote.Stack != "" { + stack = &Stack{ID: remote.Stack} + } if logger.IsVerbose() { stack.Mixins = remote.Mixins