Skip to content

Commit

Permalink
Fix output of acorn apps to show image names properly for Nested an…
Browse files Browse the repository at this point in the history
…d Service Acorns (acorn-io#1774) (acorn-io#1851)

Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville authored and cloudnautique committed Sep 28, 2023
1 parent 025256a commit f73e460
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pkg/cli/builder/table/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
adminv1 "github.com/acorn-io/runtime/pkg/apis/internal.admin.acorn.io/v1"
"github.com/acorn-io/runtime/pkg/labels"
"github.com/acorn-io/runtime/pkg/tags"
"github.com/rancher/wrangler/pkg/data/convert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -40,6 +41,7 @@ var (
"memoryToRange": MemoryToRange,
"defaultMemory": DefaultMemory,
"ownerName": OwnerReferenceName,
"imageName": ImageName,
}
)

Expand Down Expand Up @@ -292,3 +294,15 @@ func OwnerReferenceName(obj metav1.Object) string {

return owners[0].Name
}

func ImageName(obj metav1.Object) string {
app, ok := obj.(*apiv1.App)
if !ok {
return ""
}

if original, exists := app.ObjectMeta.Annotations[labels.AcornOriginalImage]; exists {
return original
}
return app.Status.AppImage.Name
}
2 changes: 1 addition & 1 deletion pkg/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (

App = [][]string{
{"Name", "{{ . | name }}"},
{"Image", "{{ trunc .Status.AppImage.Name }}"},
{"Image", "{{ . | imageName | trunc }}"},
{"Healthy", "Status.Columns.Healthy"},
{"Up-To-Date", "Status.Columns.UpToDate"},
{"Created", "{{ago .CreationTimestamp}}"},
Expand Down

0 comments on commit f73e460

Please sign in to comment.