diff options
author | Dan Duvall <dduvall@wikimedia.org> | 2018-08-06 10:40:03 -0700 |
---|---|---|
committer | Dan Duvall <dduvall@wikimedia.org> | 2018-08-14 09:01:06 -0700 |
commit | 374976d445b605f2ea1618cc6d2c5006d046fa28 (patch) | |
tree | affd3e67b38463d15e7fc00bfc400130974732b8 /config/python_test.go | |
parent | e7ce38ca630ae04b748308a2a0986393d6555ffc (diff) | |
download | blubber-374976d445b605f2ea1618cc6d2c5006d046fa28.tar.gz |
Refactor builder to support file requirements and run pre-install
The builder configuration has proven useful for supporting generic
pre-entrypoint commands such as dependency managers not otherwise
supported by specific Blubber configuration. Adding additional
`builder.requirements` config expands support for such commands by
allowing the user to specify files that should be copied into the image
before the builder command runs.
To support this extra configuration, `builder` had to be changed from a
simple string to a mapping. The builder command must now by given as
`builder.command`.
The pattern of creating parent directories, copying files, and executing
one or more commands prior to the entrypoint has become a common
one. Some of the implementation of this pattern was moved from
`PythonConfig` into shared build macros `build.SortFilesByDir` and
`build.SyncFiles`. All config types that must have requirements files
copied over independently of the entire source tree (`PythonConfig`,
`BuilderConfig`, `NodeConfig`) now delegate to these functions.
Change-Id: I67f33034f22cee2851ec866cfb07ab20c23eba8c
Diffstat (limited to 'config/python_test.go')
-rw-r--r-- | config/python_test.go | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/config/python_test.go b/config/python_test.go index 3eb6e72..03abad0 100644 --- a/config/python_test.go +++ b/config/python_test.go @@ -158,10 +158,8 @@ func TestPythonConfigInstructionsWithRequirements(t *testing.T) { "PIP_WHEEL_DIR": "/opt/lib/python", "PIP_FIND_LINKS": "file:///opt/lib/python", }}, - build.RunAll{[]build.Run{ - {"mkdir -p", []string{"/opt/lib/python"}}, - {"mkdir -p", []string{"docs/"}}, - }}, + build.Run{"mkdir -p", []string{"/opt/lib/python"}}, + build.Run{"mkdir -p", []string{"docs/"}}, build.Copy{[]string{"requirements.txt", "requirements-test.txt"}, "./"}, build.Copy{[]string{"docs/requirements.txt"}, "docs/"}, build.RunAll{[]build.Run{ @@ -196,34 +194,6 @@ func TestPythonConfigInstructionsWithRequirements(t *testing.T) { }) } -func TestPythonConfigRequirementsByDir(t *testing.T) { - cfg := config.PythonConfig{ - Requirements: []string{"foo", "./bar", "./c/c-foo", "b/b-foo", "b/b-bar", "a/a-foo"}, - } - - sortedDirs, reqsByDir := cfg.RequirementsByDir() - - assert.Equal(t, - []string{ - "./", - "a/", - "b/", - "c/", - }, - sortedDirs, - ) - - assert.Equal(t, - map[string][]string{ - "./": []string{"foo", "bar"}, - "c/": []string{"c/c-foo"}, - "b/": []string{"b/b-foo", "b/b-bar"}, - "a/": []string{"a/a-foo"}, - }, - reqsByDir, - ) -} - func TestPythonConfigRequirementsArgs(t *testing.T) { cfg := config.PythonConfig{ Requirements: []string{"foo", "bar", "baz/qux"}, |