Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 8da28ba

Browse files
Merge pull request #1895 from ibuildthecloud/main
Add "completed" to the appStatus
2 parents ebda6a8 + e109c8b commit 8da28ba

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

pkg/apis/internal.acorn.io/v1/appstatus.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type AppStatus struct {
1313

1414
Endpoints []Endpoint `json:"endpoints,omitempty"`
1515
Stopped bool `json:"stopped,omitempty"`
16+
Completed bool `json:"completed,omitempty"`
1617
}
1718

1819
type DependencyNotFound struct {

pkg/cli/apps.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (a *App) Run(cmd *cobra.Command, args []string) error {
5555
}
5656

5757
for _, app := range apps {
58-
if (app.Status.AppStatus.Stopped || inactive(app)) && !a.All {
58+
if (app.Status.AppStatus.Stopped || app.Status.AppStatus.Completed) && !a.All {
5959
continue
6060
}
6161
if len(args) > 0 {
@@ -70,14 +70,6 @@ func (a *App) Run(cmd *cobra.Command, args []string) error {
7070
return out.Err()
7171
}
7272

73-
func inactive(app apiv1.App) bool {
74-
return strings.Contains(app.Name, ".") &&
75-
app.Status.Ready &&
76-
app.Status.Columns.Healthy == "0" &&
77-
app.Status.Columns.UpToDate == "0" &&
78-
app.Status.Columns.Message == "OK"
79-
}
80-
8173
func writeApp(ctx context.Context, app *apiv1.App, out table.Writer, c client.Client) {
8274
image, err := c.ImageGet(ctx, strings.TrimPrefix(app.Status.AppImage.Digest, "sha256:"))
8375
if err != nil {

pkg/controller/appstatus/cli_status.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ func CLIStatus(req router.Request, resp router.Response) (err error) {
1717
app.Status.Columns.Healthy = healthy(app)
1818
app.Status.Columns.Message = message(app)
1919
app.Status.Columns.Endpoints, err = endpoints(req, app)
20+
21+
// There's clearly a better way to do this, but it works and I'm lazy. The intention is that we want
22+
// to detect that the acorn doesn't have any running containers (or needs to run containers) and has
23+
// produced whatever it needs to and the status is not really helpful anymore, because it's done.
24+
app.Status.AppStatus.Completed = strings.Contains(app.Name, ".") &&
25+
app.Status.Ready &&
26+
app.Status.Columns.Healthy == "0" &&
27+
app.Status.Columns.UpToDate == "0" &&
28+
app.Status.Columns.Message == "OK" &&
29+
app.Status.Columns.Endpoints == ""
30+
2031
resp.Objects(app)
2132
return
2233
}

pkg/openapi/generated/openapi_generated.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)