Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added interpolation to docker option in manifest.yaml #1100

Merged
merged 8 commits into from
Aug 21, 2020
5 changes: 3 additions & 2 deletions parsers/manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (

"gopkg.in/yaml.v2"

"net/url"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better ordering of dependencies


"github.com/apache/openwhisk-client-go/whisk"
"github.com/apache/openwhisk-wskdeploy/conductor"
"github.com/apache/openwhisk-wskdeploy/dependencies"
Expand All @@ -40,7 +42,6 @@ import (
"github.com/apache/openwhisk-wskdeploy/wski18n"
"github.com/apache/openwhisk-wskdeploy/wskprint"
yamlHelper "github.com/ghodss/yaml"
"net/url"
)

const (
Expand Down Expand Up @@ -796,7 +797,7 @@ func (dm *YAMLParser) composeActionExec(manifestFilePath string, manifestFileNam
if action.Native {
exec.Image = NATIVE_DOCKER_IMAGE
} else {
exec.Image = action.Docker
exec.Image = wskenv.InterpolateStringWithEnvVar(action.Docker).(string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interpolation feature in 1 line! Nice!

}
}

Expand Down
9 changes: 8 additions & 1 deletion parsers/manifest_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ func TestComposeActionsForFunctionWithRemoteDir(t *testing.T) {

// validate manifest_parser.ComposeActions() method
func TestComposeActionsForDocker(t *testing.T) {

os.Setenv("image_name", "environmental_variable/image")
file := "../tests/dat/manifest_data_compose_actions_for_docker.yaml"
actionFile := "../tests/src/integration/docker/actions/exec.zip"

Expand Down Expand Up @@ -960,8 +960,15 @@ func TestComposeActionsForDocker(t *testing.T) {
assert.NotNil(t, action.Action.Exec.Code, TEST_MSG_ACTION_CODE_MISSING)
assert.Equal(t, runtimes.BLACKBOX, action.Action.Exec.Kind, fmt.Sprintf(TEST_MSG_ACTION_DOCKER_KIND_MISMATCH, action.Action.Exec.Kind))
assert.Equal(t, "mydockerhub/myimage", action.Action.Exec.Image, TEST_MSG_ACTION_DOCKER_IMAGE_MISMATCH)
case "CustomDockerAction6":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a unit test

println(action.Action.Exec.Image)
assert.NotNil(t, action.Action.Exec.Code, TEST_MSG_ACTION_CODE_MISSING)
assert.Equal(t, runtimes.BLACKBOX, action.Action.Exec.Kind, fmt.Sprintf(TEST_MSG_ACTION_DOCKER_KIND_MISMATCH, action.Action.Exec.Kind))
assert.Equal(t, os.Getenv("image_name"), action.Action.Exec.Image, TEST_MSG_ACTION_DOCKER_IMAGE_MISMATCH)
}
}

os.Unsetenv("image_name")
}

func TestComposeActionsForEnvVariableInFunction(t *testing.T) {
Expand Down
44 changes: 23 additions & 21 deletions tests/dat/manifest_data_compose_actions_for_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@

packages:
IntegrationTestDocker:
actions:
OpenWhiskSkeleton:
docker: openwhisk/skeleton
OpenWhiskSkeletonWithNative:
native: true
CustomDockerAction1:
function: ../src/integration/docker/actions/exec.zip
docker: openwhisk/skeleton
CustomDockerAction2:
function: ../src/integration/docker/actions/exec.zip
native: true
CustomDockerAction3:
function: ../src/integration/docker/actions/bash
native: true
CustomDockerAction4:
function: ../src/integration/docker/actions/go
native: true
CustomDockerAction5:
function: ../src/integration/docker/actions/go
docker: mydockerhub/myimage

actions:
OpenWhiskSkeleton:
docker: openwhisk/skeleton
OpenWhiskSkeletonWithNative:
native: true
CustomDockerAction1:
function: ../src/integration/docker/actions/exec.zip
docker: openwhisk/skeleton
CustomDockerAction2:
function: ../src/integration/docker/actions/exec.zip
native: true
CustomDockerAction3:
function: ../src/integration/docker/actions/bash
native: true
CustomDockerAction4:
function: ../src/integration/docker/actions/go
native: true
CustomDockerAction5:
function: ../src/integration/docker/actions/go
docker: mydockerhub/myimage
CustomDockerAction6:
function: ../src/integration/docker/actions/go
docker: ${image_name}