Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Add the docker app version in the bundle
Browse files Browse the repository at this point in the history
This will help us track what we can or not do with the bundle we are
dealing with.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
  • Loading branch information
rumpl committed Oct 14, 2019
1 parent 3e97bfd commit 4509275
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const (
// DockerInspectFormatEnvVar is the environment variable set by the CNAB runtime to select
// the inspect output format.
DockerInspectFormatEnvVar = "DOCKER_INSPECT_FORMAT"

// CustomDockerAppVersionName is the custom variable set by Docker App to
// save the version of Docker App that built the bundle.
CustomDockerAppVersionName = Namespace + "version"
)

var (
Expand Down
3 changes: 3 additions & 0 deletions internal/packager/cnab.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func ToCNAB(app *types.App, invocationImageName string) (*bundle.Bundle, error)

bndl := &bundle.Bundle{
SchemaVersion: CNABVersion1_0_0,
Custom: map[string]interface{}{
internal.CustomDockerAppVersionName: internal.Version,
},
Credentials: map[string]bundle.Credential{
internal.CredentialDockerContextName: {
Location: bundle.Location{
Expand Down
7 changes: 6 additions & 1 deletion internal/packager/cnab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package packager

import (
"encoding/json"
"fmt"
"testing"

"github.com/docker/app/internal"

"gotest.tools/golden"

"github.com/docker/app/types"
Expand All @@ -17,5 +20,7 @@ func TestToCNAB(t *testing.T) {
assert.NilError(t, err)
actualJSON, err := json.MarshalIndent(actual, "", " ")
assert.NilError(t, err)
golden.Assert(t, string(actualJSON), "bundle-json.golden")
s := golden.Get(t, "bundle-json.golden")
expected := fmt.Sprintf(string(s), internal.Version)
assert.Equal(t, string(actualJSON), expected)
}
3 changes: 3 additions & 0 deletions internal/packager/testdata/bundle-json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,8 @@
"default": "foo",
"type": "string"
}
},
"custom": {
"com.docker.app.version": "%s"
}
}

0 comments on commit 4509275

Please sign in to comment.