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

Commit 5b2a129

Browse files
authored
Merge pull request #463 from silvin-lubecki/namespaced-custom-action
Introduce namespaced custom actions for inspect and status.
2 parents c1d0527 + aa85d3a commit 5b2a129

File tree

9 files changed

+22
-12
lines changed

9 files changed

+22
-12
lines changed

cmd/cnab-run/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"errors"
55
"fmt"
66
"os"
7+
8+
"github.com/docker/app/internal"
79
)
810

911
type cnabAction string
@@ -12,8 +14,8 @@ const (
1214
cnabActionInstall = cnabAction("install")
1315
cnabActionUninstall = cnabAction("uninstall")
1416
cnabActionUpgrade = cnabAction("upgrade")
15-
cnabActionStatus = cnabAction("status")
16-
cnabActionInspect = cnabAction("inspect")
17+
cnabActionStatus = cnabAction(internal.Namespace + "status")
18+
cnabActionInspect = cnabAction(internal.Namespace + "inspect")
1719
)
1820

1921
type cnabOperation struct {

cmd/docker-app/inspect.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"github.com/deislabs/duffle/pkg/action"
55
"github.com/deislabs/duffle/pkg/claim"
6+
"github.com/docker/app/internal"
67
"github.com/docker/cli/cli"
78
"github.com/docker/cli/cli/command"
89
"github.com/pkg/errors"
@@ -43,7 +44,7 @@ func inspectCmd(dockerCli command.Cli) *cobra.Command {
4344
c.Parameters = parameters
4445

4546
a := &action.RunCustom{
46-
Action: "inspect",
47+
Action: internal.Namespace + "inspect",
4748
Driver: driverImpl,
4849
}
4950
err = a.Run(c, map[string]string{"docker.context": ""}, dockerCli.Out())

cmd/docker-app/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/deislabs/duffle/pkg/claim"
66
"github.com/deislabs/duffle/pkg/credentials"
77
"github.com/deislabs/duffle/pkg/utils/crud"
8+
"github.com/docker/app/internal"
89
"github.com/docker/cli/cli"
910
"github.com/docker/cli/cli/command"
1011
"github.com/pkg/errors"
@@ -50,7 +51,7 @@ func runStatus(dockerCli command.Cli, claimName string, opts credentialOptions)
5051
return err
5152
}
5253
status := &action.RunCustom{
53-
Action: "status",
54+
Action: internal.Namespace + "status",
5455
Driver: driverImpl,
5556
}
5657
err = status.Run(&c, creds, dockerCli.Out())

e2e/testdata/cnab-with-status/bundle.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
],
1010
"actions": {
11-
"status": {
11+
"com.docker.app.status": {
1212
"modifies": false
1313
}
1414
}

e2e/testdata/cnab-with-status/cnab/app/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ case $action in
1313
upgrade)
1414
echo "Upgrade action"
1515
;;
16-
status)
16+
com.docker.app.status)
1717
echo "Status action"
1818
;;
1919
*)

e2e/testdata/simple-bundle.json.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
}
4242
},
4343
"actions": {
44-
"inspect": {
44+
"com.docker.app.inspect": {
4545
"Modifies": false
4646
},
47-
"status": {
47+
"com.docker.app.status": {
4848
"Modifies": false
4949
}
5050
},

internal/names.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const (
2121

2222
// DeprecatedSettingsFileName is the deprecated settings file name (replaced by ParametersFileName)
2323
DeprecatedSettingsFileName = "settings.yml"
24+
25+
// Namespace is the reverse DNS namespace used with labels and CNAB custom actions.
26+
Namespace = "com.docker.app."
2427
)
2528

2629
var (

internal/packager/cnab.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/deislabs/duffle/pkg/bundle"
7+
"github.com/docker/app/internal"
78
"github.com/docker/app/internal/compose"
89
"github.com/docker/app/types"
910
)
@@ -85,10 +86,10 @@ func ToCNAB(app *types.App, invocationImageName string) (*bundle.Bundle, error)
8586
Version: app.Metadata().Version,
8687
Parameters: parameters,
8788
Actions: map[string]bundle.Action{
88-
"inspect": {
89+
internal.Namespace + "inspect": {
8990
Modifies: false,
9091
},
91-
"status": {
92+
internal.Namespace + "status": {
9293
Modifies: false,
9394
},
9495
},

internal/packager/cnab_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package packager
33
import (
44
"testing"
55

6+
"github.com/docker/app/internal"
7+
68
"github.com/deislabs/duffle/pkg/bundle"
79
"github.com/docker/app/types"
810
"gotest.tools/assert"
@@ -69,10 +71,10 @@ func TestToCNAB(t *testing.T) {
6971
},
7072
},
7173
Actions: map[string]bundle.Action{
72-
"inspect": {
74+
internal.Namespace + "inspect": {
7375
Modifies: false,
7476
},
75-
"status": {
77+
internal.Namespace + "status": {
7678
Modifies: false,
7779
},
7880
},

0 commit comments

Comments
 (0)