Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 5633f15

Browse files
Add status command to query the status of a CNAB installation.
For a Docker Application Package, it will run a "docker stack services" on the deployed stack. Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent bd3b894 commit 5633f15

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

cmd/docker-app/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
4747
installCmd(dockerCli),
4848
upgradeCmd(dockerCli),
4949
uninstallCmd(dockerCli),
50+
statusCmd(dockerCli),
5051
initCmd(),
5152
inspectCmd(dockerCli),
5253
mergeCmd(dockerCli),

cmd/docker-app/status.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package main
2+
3+
import (
4+
"github.com/deislabs/duffle/pkg/action"
5+
"github.com/deislabs/duffle/pkg/claim"
6+
"github.com/deislabs/duffle/pkg/credentials"
7+
"github.com/deislabs/duffle/pkg/utils/crud"
8+
"github.com/docker/cli/cli"
9+
"github.com/docker/cli/cli/command"
10+
"github.com/spf13/cobra"
11+
)
12+
13+
func statusCmd(dockerCli command.Cli) *cobra.Command {
14+
var opts uninstallOptions
15+
16+
cmd := &cobra.Command{
17+
Use: "status <installation-name>",
18+
Short: "Get an application status",
19+
Args: cli.ExactArgs(1),
20+
RunE: func(cmd *cobra.Command, args []string) error {
21+
return runStatus(dockerCli, args[0], opts)
22+
},
23+
}
24+
25+
cmd.Flags().StringVar(&opts.targetContext, "target-context", "", "Context on which to request the application status")
26+
cmd.Flags().StringArrayVarP(&opts.credentialsets, "credential-set", "c", []string{}, "Use a duffle credentialset (either a YAML file, or a credential set present in the duffle credential store)")
27+
28+
return cmd
29+
}
30+
31+
func runStatus(dockerCli command.Cli, claimName string, opts uninstallOptions) error {
32+
muteDockerCli(dockerCli)
33+
h := duffleHome()
34+
35+
claimStore := claim.NewClaimStore(crud.NewFileSystemStore(h.Claims(), "json"))
36+
c, err := claimStore.Read(claimName)
37+
if err != nil {
38+
return err
39+
}
40+
targetContext := getTargetContext(opts.targetContext)
41+
42+
driverImpl, err := prepareDriver(dockerCli)
43+
if err != nil {
44+
return err
45+
}
46+
creds, err := prepareCredentialSet(targetContext, dockerCli.ContextStore(), c.Bundle, opts.credentialsets)
47+
if err != nil {
48+
return err
49+
}
50+
if err := credentials.Validate(creds, c.Bundle.Credentials); err != nil {
51+
return err
52+
}
53+
status := &action.Status{
54+
Driver: driverImpl,
55+
}
56+
return status.Run(&c, creds, dockerCli.Out())
57+
}

0 commit comments

Comments
 (0)