Commit Graph

947 Commits

Author SHA1 Message Date
Tejal Desai 5cbf34b67e
Update pkg/util/groupids_fallback.go 2020-05-03 21:04:22 -07:00
Tejal Desai d37896b94f
Merge branch 'master' into experiment 2020-05-03 21:02:41 -07:00
Tejal Desai 94ee809e1c
Merge branch 'master' into log-timestamp-v0.19.0 2020-05-03 20:58:34 -07:00
Tejal Desai fe0500f8e6
Merge pull request #1196 from yw-liu/master
Add http support for git repository context
2020-05-03 20:53:43 -07:00
Tejal Desai ae11db43d7
Merge pull request #1193 from tp-tc/dangling-symlink
Ignore the target of dangling symlinks.
2020-05-03 20:47:12 -07:00
Tejal Desai a2af3272cf
Merge pull request #1192 from tp-tc/snapshot-maintainers
Handle `MAINTAINERS` when passing `--single-snapshot`.
2020-05-03 20:45:48 -07:00
Tejal Desai 095ea2991a
remove unused command 2020-05-03 20:40:41 -07:00
Tejal Desai 5090baafda fix single snapshot 2020-05-03 20:23:07 -07:00
Tejal Desai db7687dbce wip 2020-05-03 18:37:45 -07:00
Tejal Desai 75864d5c85 flip the flag 2020-05-01 23:41:06 -07:00
Tejal Desai 7d32139a13 fix a bug where file check nil is insufficient 2020-05-01 22:38:14 -07:00
Tejal Desai 32e3336d4c add a new method to indicate if the command provides files to snapshot 2020-05-01 15:50:46 -07:00
Tejal Desai 36748facc5
Merge pull request #1203 from dani29/cache
Set very large logs to Trace level
2020-05-01 10:35:15 -07:00
Tejal Desai 7ccf05fae3
Merge pull request #1165 from JordanGoasdoue/multistage-now-respects-dependencies
feat: multistages now respect dependencies without building unnecessary stages
2020-05-01 10:34:47 -07:00
Tejal Desai 7eb2458ba4
Merge pull request #1166 from gilbsgilbs/snapshot-directories
Always add parent directories of files to snapshots.
2020-05-01 10:25:25 -07:00
Tejal Desai 8a780be748
Merge pull request #1139 from JordanGoasdoue/allow-injecting-context-tar-gz
feat: allow injecting through stdin tar.gz on kaniko
2020-05-01 10:24:05 -07:00
Tejal Desai 6c627645ad
Merge pull request #1194 from tp-tc/greedy-cache-substitution
Don't generate cache key, if not caching builds.
2020-05-01 10:21:44 -07:00
Tejal Desai 2e1ca5f19d
remove log added for debugging 2020-05-01 09:40:39 -07:00
Ben Einaudi d763b7e961 fix previous name checking in 'executor.build.fetchExtraStages' 2020-05-01 16:45:01 +02:00
Tejal Desai 8b3ff95b09 fmt 2020-04-30 17:07:18 -07:00
Tejal Desai 44b35b28eb remove read succesS 2020-04-30 15:18:39 -07:00
Tejal Desai 8fb17f60d9 Defer initial snapshot. Remove ReadSuccess() 2020-04-30 13:25:22 -07:00
Tejal Desai 691acd094a try different root dir 2020-04-29 22:42:33 -07:00
Jon Henrik Bjørnstad 41a95fe4bd Add timestamp to logs 2020-04-23 13:40:47 +02:00
Dani Raznikov 04888f2690 Set loud logs to trace level 2020-04-18 20:27:25 +03:00
Jordan Goasdoué 8cbc7a8ca2 feat: multistages is now built without unusued stages 2020-04-17 09:59:56 +02:00
yw-liu 73eb47c752 replace string literal with constant 2020-04-17 09:07:38 +08:00
yw-liu 2e90173238 fix boilerplate 2020-04-17 00:37:12 +08:00
yw-liu c9fc6b5bcf fix golint problem 2020-04-17 00:21:48 +08:00
yw-liu 0fc311a8b7 make string var as constant 2020-04-17 00:00:24 +08:00
yw-liu 7912e4c87b modify unit-test 2020-04-16 23:48:43 +08:00
yw-liu d8b8e811dd modify code format and unit-test 2020-04-16 23:44:37 +08:00
yw-liu 4f8d074e00
add unit-test 2020-04-16 22:21:09 +08:00
Dani Raznikov 8d6a75a745 merge conflict fixes 2020-04-15 16:10:45 +03:00
Dani Raznikov e8323441ab resolve conflict with PR #1160 2020-04-15 15:58:43 +03:00
Tejal Desai 2270ac03d2
Merge pull request #1160 from JordanGoasdoue/can-now-resolve-args-from-stage
feat: can now resolves args from all stages
2020-04-14 14:18:09 -07:00
yw-liu 34a6ec250f
add http support for git pull
usage: set the GIT_PULL_METHOD env var to http or https for starting the container
2020-04-14 20:25:20 +08:00
Tom Prince c520218cec Don't generate cache key, if not caching builds.
The cache key generation does environment subsitution in places that running
the commands doesn't. This causes issues if a command uses complex shell
substitutions. The cache key is generated even if caching isn't enabled.

This disables the cache key generation if caching is not enabled. This doesn't
fix the underlying issue, but limits it to when the cache is being used.
2020-04-13 16:50:13 -06:00
Tom Prince 5061b72e42 Ignore the target of dangling symlinks. 2020-04-13 16:26:19 -06:00
Tom Prince 484d03550c Handle `MAINTAINERS` when passing `--single-snapshot`. 2020-04-13 15:54:27 -06:00
Dani Raznikov f720c817c7 add unit tests 2020-04-12 20:17:40 +03:00
Dani Raznikov 961e634366 calculate dependency for onbuild 2020-04-10 18:49:34 +03:00
Dani Raznikov 70eb7ebcfa suport multistage onbuild 2020-04-10 18:30:25 +03:00
Dani Raznikov 6b44ed4477 calculateDepdencies on a copy of envvars 2020-04-04 23:27:15 +03:00
Dani Raznikov 3ab6524fe5 optimize: don't parse Dockerfile twice and just reuse stages 2020-04-03 18:53:22 +03:00
Dani Raznikov a3ce1cebf3 optimize: don't parse Dockerfile twice and just reuse stages 2020-04-03 17:39:59 +03:00
Gilbert Gilb's 14170aa455 Fix sorting of parent directories.
This refactoring reversed the order of the "ParentDirectories" function: ffc372a63b (diff-d36eb675aa49a7b471e3a2be77005b18R465)

As a side-effect, parent directories weren't added in lexicographical
order, which broke some tests. We now ensure in unit test that the order
of the ParentDirectories function is stable.
2020-03-31 20:18:24 +02:00
Gilbert Gilb's fd8a2d6dd8 Merge branch 'master' into snapshot-directories 2020-03-31 14:25:04 +02:00
Tejal Desai 0fe0a64113
Merge pull request #1168 from PhoenixMage/32bit-overflow-fix
32bit overflow fix
2020-03-30 10:23:31 -07:00
Tejal Desai 8dc64549a1
Merge pull request #1155 from tejal29/fix_multi_stage_symlinks
Refactor Kaniko to test across multistages
2020-03-30 10:21:51 -07:00
PhoenixMage aa6a3de316
Fix 32bit overflow
math.UaxUint32 will actually overflow on a 32 bit platform (tested on armv7)

This will resolve that issue.
2020-03-30 23:37:34 +11:00
Gilbert Gilb's e5585fded8 Always add parent directories of files to snapshots.
During a snapshot, when a file changed and not its parent directories,
the parent directories weren't added to the layer. This is inconsistent
with Docker's behavior which always add parent directories to the layer.
In some edge-cases, it could lead to problems with docker considering
that parent directories where owned by root in forthcoming layers
although they shouldn't (see #1163).

Also, Docker seems to be POSIX compliant regarding the name of
directories in the archive, which always have a slash appended. This
commit also fixes this.

Fixes #1163
2020-03-29 18:25:37 +02:00
Thomas Stromberg a6504769e3 Add secondary group impersonation w/ !cgo support 2020-03-28 22:01:20 -07:00
Thomas Stromberg 3426a24929 Add support for impersonating secondary groups 2020-03-28 12:10:37 -07:00
Jordan Goasdoué ed883b9015 feat: can now resolves args from stage 2020-03-27 18:42:46 +01:00
Tejal Desai 340ca79fbb lint 2020-03-25 11:01:12 -07:00
Tejal Desai 1978f1e08e
Merge pull request #1130 from Vlatombe/set_image_platform
Set image platform for any build
2020-03-25 10:10:41 -07:00
Tejal Desai 9567b755dd fix unit tests 2020-03-25 10:09:33 -07:00
Tejal Desai 2ea28fc7f5 revert back to previous file to save logic 2020-03-25 09:43:59 -07:00
Tejal Desai caaf6c8adf fix tests 2020-03-24 10:50:59 -07:00
Sam Stoelinga 1b662e7834
Merge pull request #1140 from samos123/fix-1122-public-gcr
Add ability to use public GCR repos without being authenticated
2020-03-24 10:31:58 -07:00
Vincent Latombe 336bcd3a9a
Merge branch 'master' into set_image_platform 2020-03-24 09:51:11 +01:00
Tejal Desai 5da32d3f18
Merge pull request #1147 from tejal29/small_perf
small perf optimizing. Only remove whiteout path if it needs to be included in base image
2020-03-23 18:12:39 -07:00
Tejal Desai ffc372a63b refactor to add unit tests 2020-03-23 17:48:49 -07:00
Sam Stoelinga 1fb1eddd8c Test: Remove DockerConf after CheckPushPermission 2020-03-23 10:51:09 -07:00
Shihab Hasan 99b08059c4 Checkout a specific git commit 2020-03-23 12:12:52 +06:00
Sam Stoelinga c2393df7c3 Cleanup push_test CheckPushPermission unit tests 2020-03-22 17:11:08 -07:00
Sam Stoelinga c56f16b163 Create constant for Docker conf location 2020-03-21 16:45:04 -07:00
Sam Stoelinga 8518b37ca1 Add unit tests for CheckPushPermissions 2020-03-21 16:15:34 -07:00
Jordan Goasdoué d08a767454 feat: allow injecting through stdin tar.gz on kaniko 2020-03-18 12:29:49 +01:00
Yoan Blanc 03fcc537c3
Merge remote-tracking branch 'origin/master' into fix-chown 2020-03-18 09:01:15 +01:00
Tejal Desai 67db51810b small perf optimizing. Only remove whiteout path if it needs to be included in the tar 2020-03-18 00:43:55 -07:00
Tejal Desai 0302e5150c
Merge pull request #1085 from tejal29/rm_buildargs_from_cache_key
remove build args from composite key and replace all build args
2020-03-17 16:02:59 -07:00
Tejal Desai a173bf020b
Merge pull request #1115 from JordanGoasdoue/allow-build-context-from-local-targz
feat: add support of local '.tar.gz' file inside the kaniko container
2020-03-17 15:24:10 -07:00
Tejal Desai 0185818bd8
Merge pull request #1134 from dani29/master
Add support to --chown flag to ADD command (Issue #57)
2020-03-17 15:07:02 -07:00
Sam Stoelinga e1e6c55386
Merge pull request #1128 from zhangyuheng/fix/typo
fix: credential typo
2020-03-17 11:26:36 -07:00
Sam Stoelinga 66268690b3 Add comments 2020-03-17 09:11:50 -07:00
Sam Stoelinga 8a020010b7 Add ability to use public GCR image
Kaniko by default used to configure the GCR credential helper however
this caused Kaniko to fail when trying to use a base image from a public
GCR image. This patch makes it possible to use public GCR images as base
image when using docker even when you're not authenticated to GCR.

Co-authored-by: Nate Williams <nate.williams@files.com>
2020-03-17 09:09:41 -07:00
Yoan Blanc 3ff2ee3ba5
copy: unit test for chown
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-17 15:19:00 +01:00
Dani Raznikov c136f886a9 Add support to --chown flag to ADD command 2020-03-14 16:24:40 +02:00
Jordan GOASDOUE fda7ed4f74 feat: add support of local '.tar.gz' file inside the kaniko container 2020-03-12 22:51:30 +01:00
Tejal Desai 32decf5798
Merge pull request #1075 from greut/label-flag
executor: add --label flag
2020-03-12 13:47:01 -07:00
Tejal Desai 18de5d6d2d
Merge pull request #1037 from antechrestos/feature/add_option_to_import_registry_certificate
Allow user to provide registry certificate
2020-03-12 12:56:40 -07:00
Vincent Latombe 4d26c1f51e
Set OS/ARCH when assembling image 2020-03-12 10:41:32 +01:00
Yuheng Zhang 8eef58939b fix: credential typo 2020-03-12 14:31:15 +08:00
Tejal Desai 9592f2640f more tests similar to docker cp 2020-03-09 15:54:35 -07:00
Ben Einaudi b73c2c10c8 Allow user to provide registry certificate
Fixes #1100
Fixes #1101
2020-03-08 18:17:50 +01:00
Tejal Desai 2181c5e6f5 create correct link across Multistage builds 2020-03-07 11:28:16 -08:00
Yoan Blanc 53326fa0bf
executor: add --label flag
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-07 18:17:26 +01:00
Tejal Desai c523c691eb revert back to old 0.17.1 behavior 2020-03-06 23:48:31 -08:00
Tejal Desai 8f87267002 fix lint error 2020-03-06 21:37:00 -08:00
Tejal Desai 6c14d202a3 better error wrapping and add more tests for copy 2020-03-06 17:18:36 -08:00
Tejal Desai b4b70d040a wip 2020-03-06 13:08:02 -08:00
Tejal Desai 3cc8aa2a9c fix resolve link for dirs with trailing / 2020-03-06 09:38:00 -08:00
Yoan Blanc fc668cd2b5
fixup! fixup! fixup! run: user LookupId
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-05 17:26:04 +01:00
Yoan Blanc bd77f131fd
fixup! fixup! run: user LookupId
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-05 17:00:14 +01:00
Yoan Blanc 67fbdef360
fixup! run: user LookupId
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-05 16:49:13 +01:00
Yoan Blanc c7028c6d2f
run: user LookupId
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-05 16:44:55 +01:00
Yoan Blanc c553184416
user_test: docker doesn't care about group really
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-05 16:34:06 +01:00
Tejal Desai 579ec52a30 add more tests for stageBuilder_build 2020-03-04 17:04:42 -08:00
Tejal Desai b9f4c4bab5 add more tests for stageBuilder_build 2020-03-04 16:57:26 -08:00
Tejal Desai 9e83210b07 Rebase over 1105 2020-03-04 14:16:24 -08:00
Yoan Blanc 3d9bb21f75 user: keep existing HOME env
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-04 14:14:25 -08:00
Yoan Blanc fec7c126f9 run: set userStr
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-04 14:14:10 -08:00
Yoan Blanc 52acd798f8 run: unset any HOME variable after USER ran
Running USER didn't reset HOME which had to be explicitly set.

Closes #1082

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-04 14:12:42 -08:00
Tejal Desai c1e3f42625 fix user metadata string 2020-03-04 13:08:38 -08:00
Tejal Desai dd5d2e6661 ignore errors while deleting 2020-02-28 04:48:22 -08:00
Tejal Desai 17f808da8a check for filepath.Walk error everywhere 2020-02-28 04:23:27 -08:00
Tejal Desai ae5a7bf158 fix tests 2020-02-28 02:53:42 -08:00
Tejal Desai 58c0d47fa6 fix npe 2020-02-28 02:44:43 -08:00
Tejal Desai 2ba7d25090 remove build args from composite key and replace all build args before adding command to the cache 2020-02-28 01:51:31 -08:00
Tejal Desai a1af057f99
Merge pull request #1069 from cvgw/u/cgwippern/implement-filepath-resolver
Resolve filepaths before scanning for changes
2020-02-25 00:19:38 -08:00
cvgw 60e2187d85 Fix #1020 os.Chtimes invalid arg
The zero value of time.Time is not a valid argument to os.Chtimes
because of the syscall that os.Chtimes calls. Instead we update the zero
value of time.Time to the zero value of Unix Epoch
2020-02-24 08:29:19 -08:00
cvgw 965b606720 remove cruft and unneeded loop 2020-02-23 13:38:08 -08:00
cvgw 01f6aba517 update resolveSymlinkAncestor and add tests 2020-02-22 11:17:39 -08:00
cvgw a675ad998a Resolve filepaths before scanning for changes 2020-02-20 09:45:44 -08:00
Yoan Blanc 474fdcf68d
image: fix registry mirror setup
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-02-16 11:41:51 +01:00
Yoan Blanc edc4eb33f4
Merge remote-tracking branch 'origin/master' into registry-mirror 2020-02-16 09:28:54 +01:00
Tejal Desai 2716557379
Merge pull request #1032 from tinkerborg/consistent-sha
Ensure image SHA stays consistent when layer contents haven't changed
2020-02-13 11:22:27 -08:00
cvgw 7e2009b5e2 More idiomatic logging config
Update logging configuration to be more idiomatic for a Cobra
application
2020-02-07 16:13:03 -08:00
Tejal Desai 8d9e6b8ea5
Merge pull request #1027 from tejal29/small_refacto
refactor copy.chown code and add more tests
2020-02-07 13:48:05 -08:00
Tejal Desai c9dc474031 fix linter 2020-02-07 13:47:17 -08:00
Tejal Desai a17ad8e8e8
Merge pull request #882 from cvgw/u/cvgw/reuse-cached-layer
Do not recompute layers retrieved from cache
2020-02-07 13:37:39 -08:00
Tejal Desai 8b69a13641 fix commut 2020-02-06 15:37:47 -08:00
Tejal Desai 674f5bda5d fix tests 2020-02-06 15:17:09 -08:00
Or Sela 9dd050b892 set log format using a flag 2020-02-07 00:05:59 +02:00
Tejal Desai d94a1ed53b fix linter 2020-02-06 11:40:41 -08:00
Tejal Desai 9dba097a7e refactor and add more tests 2020-02-06 11:40:41 -08:00
tinkerborg 82bce229bd omit uname/gname in tar headers
When using cache, the rootfs may not have been extracted. This prevents uname/gname from resolving
as there is no /etc/password or /etc/group. This makes this layer unnecessarily differ from
a cached layer which does contain this information. Omitting these should be consistent with Docker's
behavior.
2020-02-06 13:36:26 -05:00
tinkerborg cc2c9a0663 sort filesToAdd in TakeSnapshot
filesToAdd is sorted in TakeSnapshotFS, but not here. This makes ordering unpredictable within the layer's tarball,
causing the SHA to differ even if layer contents haven't changed
2020-02-06 13:36:21 -05:00
Tejal Desai 9e17ffd6cb fix unit tests 2020-02-05 15:59:07 -08:00
Tejal Desai 2cd68d2e2f fix flake in copy symlink 2020-02-05 14:40:52 -08:00
Tejal Desai 2e95c3040c update initialWhitelist instead of whitelist 2020-02-04 11:06:26 -08:00
Tejal Desai 31f626cb22 initilize group to 0 2020-02-03 22:15:56 -08:00
Tejal Desai 56125ff464 Rebase from master with some changes 2020-02-03 14:57:10 -08:00
xanonid ac4c80d241 Refactor code, introduce constants for uid/gid = -1 2020-02-03 14:56:23 -08:00
xanonid 517cb50278 Add Unit test for GetUIDAndGIDFromString 2020-02-03 14:56:23 -08:00
xanonid e3b5a7b85d Support COPY --chown flag (Closes: #9) 2020-02-03 14:56:23 -08:00
Tejal Desai 18fec3ba38 fix lint 2020-02-03 11:03:58 -08:00
Tejal Desai db6f6c5ad3 more tests and do not error out if user not found 2020-02-03 10:11:40 -08:00
Tejal Desai 6894be442f remove duplicate code 2020-02-01 15:19:36 -08:00
Tejal Desai 956495784e fix group string being always set to uid in case a user has a gid set 2020-02-01 15:19:36 -08:00
Tejal Desai 0e833e4643 fix test 2020-02-01 09:29:18 -08:00
Tejal Desai 5a4a6c4a17 fix test flake 2020-01-31 15:23:38 -08:00
Tejal Desai 3f73230884
Merge pull request #1000 from tejal29/769
whitelist  /tmp/apt-key-gpghome.* directory
2020-01-31 10:50:26 -08:00
Thomas Bonfort 6b6742fd9d Changle loglevel for whiteouts to debug 2020-01-31 12:02:32 +01:00
Tejal Desai 611ba51c88 fix web editor conflicts resolutions 2020-01-30 11:18:53 -08:00
Tejal Desai 47ab3fe997
Merge branch 'master' into registry-mirror 2020-01-29 11:42:06 -08:00
Tejal Desai 8bdcb4f544
Merge pull request #854 from WanzenBug/ignored-files-invalidate-cache
Fix caching to respect .dockerignore
2020-01-29 11:32:43 -08:00
Cole Wippern 65cd9124d1
Merge pull request #957 from antechrestos/fix/scopes_asked_to_remote_registry
Upgrade go-containerregistry third-party library
2020-01-28 16:00:21 -08:00
Tejal Desai 8b991f6baf Add falg to --whitelist-var-run set to true to preserver default kaniko behaviour of /var/run ignored. Set it to false to add /var/run in destination directory 2020-01-28 10:52:36 -08:00
Tejal Desai d49c198c90 Revert "add option additonal-whitelist"
This reverts commit 72bfed1850.
2020-01-28 08:52:36 -08:00
Tejal Desai c8b19894bb Revert "additional-whitelist"
This reverts commit ac8e123815.
2020-01-28 08:52:29 -08:00
Tejal Desai 0529579db7
Merge pull request #971 from tejal29/915
Fix Symlinks not being copied across stages
2020-01-27 10:58:49 -08:00
Ben Einaudi 03b8922ede Upgrade dependency to go-containerregistry third-party library
By doing so it will fix issues met when mixing source/remote registry

Close #808
2020-01-26 18:55:52 +01:00
Tejal Desai e8fffda7cb
Merge pull request #995 from tejal29/507
Fix home and group set for user command
2020-01-24 22:18:09 -08:00
Tejal Desai e0322042c7 use filepath.Match instead of regex 2020-01-24 22:12:37 -08:00
Tejal Desai 68e8c6e902
Merge pull request #975 from cvgw/u/cgwippern/fix-issue-506
Fix #506 add option additional-whitelist
2020-01-24 16:11:32 -08:00
Tejal Desai 5951d9b0ee add /tmp/apt-key to whitelist for Dockerfiles which use command 2020-01-24 15:54:44 -08:00
Tejal Desai 308137f46d
Merge pull request #994 from wmuizelaar/fix_extracted_verbose_logging
Change loglevel for extractedFiles to debug. Fixes #901
2020-01-24 14:04:50 -08:00
Moritz Wanzenböck bab1c170e8 fix skipping ignored directories if they have whitelisted content 2020-01-24 22:27:56 +01:00
cvgw ac8e123815 additional-whitelist
* update readme
* improve test
* change default
2020-01-24 10:22:20 -08:00
Cole Wippern 72bfed1850 add option additonal-whitelist
Add a new option additonal-whitelist which defaults
to a single entry, "/var/run". This will allow users to
remove "/var/run" from the whitelist or retain the current
behavior with no change.
2020-01-23 16:50:33 -08:00
Cole Wippern cd9be5d513 reuse cached layer 2020-01-23 16:48:26 -08:00
Cole Wippern 782e4916b6 update build and composite cache tests 2020-01-23 15:37:38 -08:00
Moritz Wanzenböck ef692e55f3 composite_cache: add unit tests
Add unit tests that check the behaviour of CompositeCache
on adding filesytem resources. It checks that
* 2 identical directory trees produces the same hash
* an extra file produces a different hash
* an extra directry produces a different hash
* an extra file that is excluded does not alter the hash
* an extra directory that is excluded does not alter the hash
2020-01-23 15:37:37 -08:00
Moritz Wanzenböck 123dcaf83e Fix caching to respect .dockerignore
Previously kaniko would compute the cache key for any copy command by computing
the combined hash of all files in a directory, even if they were listed
as ignored.

With this change, the cache key creation was updated to be aware of ignored
files.

Related issues:
* https://github.com/GoogleContainerTools/kaniko/issues/594
2020-01-23 15:37:37 -08:00
Tejal Desai 048de00c33 Fix home and group set for user command 2020-01-23 15:07:15 -08:00
Cole Wippern a2aae6274d
Merge pull request #973 from cvgw/u/cgwippern/fix-issue-704
Fix issue #704
2020-01-23 13:00:34 -08:00
Wietse Muizelaar 05a316c26c Change loglevel for extractedFiles to debug. Fixes https://github.com/GoogleContainerTools/kaniko/issues/901 2020-01-23 21:37:06 +01:00
Tejal Desai 3e5d0a6334 add unit tests 2020-01-23 11:12:54 -08:00
Tejal Desai 79d226ade0 refactor 2020-01-22 16:32:46 -08:00
Tejal Desai bb129e9c88 code review comments 2020-01-22 16:27:06 -08:00
Tejal Desai b271eb8ab9 fix linter 2020-01-22 15:39:03 -08:00
Tejal Desai 478205e5ca fix adding symlinks to FS which do not exists 2020-01-22 15:27:01 -08:00
Tejal Desai f1f7297478 fix tests 2020-01-22 11:47:10 -08:00
Tejal Desai da7e9928e4 Fix Symlinks not being copies across stages 2020-01-22 11:47:10 -08:00
Tejal Desai 6a6c547811
Merge pull request #980 from PhoenixMage/PR646_rebase_fix
Prefer platform that is currently running for pulling remote images and kaniko binary Makefile target
2020-01-21 16:26:00 -08:00
Tejal Desai 76f0bf44e5 fix hack linter 2020-01-21 15:22:49 -08:00
Tejal Desai d362359314
Merge pull request #981 from cvgw/u/cgwippern/fix-issue-940
Fix #940 set modtime when extracting
2020-01-21 09:59:22 -08:00
Tejal Desai 649a0ed99b
Merge pull request #983 from cvgw/u/cvgw/fix-issue-519
Fix #519 capital letter in stage names
2020-01-21 09:56:06 -08:00
Tejal Desai b1970a3584
Merge pull request #792 from loganprice/FixAddTar
Fix Ability for ADD to unTar a file
2020-01-21 09:55:25 -08:00
Cole Wippern b9b61e2a12
Merge pull request #943 from shortstories/bugfix/copy-with-symlink
Fix #942 COPY or ADD to symlink destination breaks image
2020-01-20 20:55:35 -08:00
ohchang-kwon df767bb195 apply code review results 2020-01-21 12:07:13 +09:00
cvgw e652f815ef Fix #519 capital letter in stage names
update stage code so that when comparing the BaseName of
a stage against the recorded, lowercase version of a Stage name
the BaseName is also lowercased.
2020-01-20 15:57:05 -08:00
Cole Wippern 4e8bdb3947 Fix #940 set modtime when extracting
Certain utilities like Apt depend on modtime
for certain files. Kaniko was not setting modtime when
extracting files and so this broke things like apt.

Kaniko now sets the file mod time to the value from the tar
header.
2020-01-20 09:11:44 -08:00
Anthony Davies ed22afc19b Rebase fix for PR #646
I needed this for my arm64 k8s cluster. I have zero Go experience but
enough experience with other things to fix the rebase (I think!). This
patch is working fine on my cluster.
2020-01-20 13:43:45 +11:00
Yoan Blanc e26bd672f1
fixup! Merge remote-tracking branch 'origin/master' into registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-01-18 09:36:22 +01:00
Yoan Blanc 140879fadd
Merge remote-tracking branch 'origin/master' into registry-mirror 2020-01-18 09:35:56 +01:00
Cole Wippern 96093359c1 rename mock pkg for lint 2020-01-17 14:59:14 -08:00
Cole Wippern f96ea3bbfb hand edit mock license
for some reason hack/boilerplate.sh failed after using `addlicense`
so I copy/pasted the license header from another file
2020-01-17 14:56:12 -08:00
Cole Wippern a9896d5c43 update mocks with license 2020-01-17 14:32:36 -08:00
Cole Wippern 876f24b0c9 update caching run and copy extracted files
Update caching run and copy commands to use the new
GetFSFromLayers method and include the whiteout option so that
whiteout files are extracted and included in extractedFiles
2020-01-17 14:19:58 -08:00
Cole Wippern 71aed35094 GetFSFromLayers
* add util.GetFSFromLayers
* GetFSFromImage delegates to GetFSFromLayers
* add FSOpts and FSConfig for GetFSFromLayers
* add tests for GetFSFromLayers
* add gomock for test support
* add mock_v1 for layers
2020-01-17 13:36:23 -08:00
Cole Wippern e19cc228ba
Merge pull request #941 from stijndehaes/feature/cache-warmer-private-reg-support
Support for private registries in the cache warmer
2020-01-17 08:38:59 -08:00
Tejal Desai e702d75e9c
Merge pull request #964 from samos123/fix-argsescape
Fix bug with docker compatibility ArgsEscaped
2020-01-16 16:13:57 -08:00
Stijn De Haes 3fa8f686db Support for private registries in the cache warmer
Closes #503

Signed-off-by: Stijn De Haes <stijndehaes@gmail.com>
2020-01-15 15:35:42 +01:00
lou-lan da0e7c7bdc Clean code (Condition is always 'false' because 'err' is always 'nil' ). 2020-01-14 15:11:22 +08:00
Sam Stoelinga 64bfc3eabb Fix bug with docker compatibility
ArgsEscaped according to Docker docs should only be set in Windows
environments: https://docs.docker.com/engine/api/v1.30/

It was causing integration test to fail with following message:
```
FAIL: TestRun/test_Dockerfile_test_metadata (8.48s)
           "Diff": {
             "Adds": [
               "ArgsEscaped: true"
             ],
             "Dels": [
               "ArgsEscaped: false"
             ]
```

However docker 18.xx returns ArgsEscaped: true
whereas docker 19.xx returns ArgsEscaped: false
Hence this patch also adds the docker version check to the integration
to ignore ArgsEscaped being different when 18.xx is used.
2020-01-13 21:18:54 -08:00
Cole Wippern 776fa43eb2 refactor cache.Warm and add tests 2020-01-10 12:29:17 -08:00
Cole Wippern b1b0513c05 Fix #926 cache warmer and method signature 2020-01-10 12:29:16 -08:00
ohchang-kwon fb4d1f9c8d add handling when source directory does not have slash suffix 2020-01-03 19:21:29 +09:00
ohchang-kwon 70270a65f0 apply goimports 2020-01-03 17:46:29 +09:00
ohchang-kwon d6fe98aa49 Fixed an issue where the image is broken if there are symlink in the destination path when ADD, COPY 2020-01-03 16:28:12 +09:00
Yoan Blanc 3678b70239
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-22 11:10:15 +01:00
Cole Wippern 328847ffc2 Fix #925 broken insecure pull 2019-12-21 21:50:43 -08:00
Logan.Price 812c66ecc0 chore: add error check 2019-12-21 15:42:00 -08:00
Logan.Price c5a29962f2 chore: add unit test for unTar function 2019-12-21 15:42:00 -08:00
Logan.Price 6a35a84034 fix: update unTar function to actually extract and save the contents of an achieve 2019-12-21 15:42:00 -08:00
Nao YONASHIRO cbba7cec3f chore: fix typo 2019-12-21 14:44:12 -08:00
Nao YONASHIRO 2599c0c69b docs: fix wrong document 2019-12-21 14:42:58 -08:00
Cole Wippern 229820550e
Merge pull request #869 from prary/go_modules
changing to modules from dependencies
2019-12-21 12:56:15 -08:00
Cole Wippern bdabd774fc Update linter and fix errors
* disable linters that are now enabled by default in new version
* fix linter errors
2019-12-21 12:27:14 -08:00
Prashant Arya 976b4265fb changing to modules from dependencies 2019-12-21 12:18:09 -08:00
Prashant Arya 85f1a5db00 Merge branch 'master' of https://github.com/GoogleContainerTools/kaniko into log 2019-12-19 03:20:56 +00:00
Cole Wippern 9e9b8a6e71 Fix #899 cached copy results in inconsistent key
* Update cached copy command to return the same result for
files used from context so that cached and uncached copy
commands produce the same cache key
* Update tests for fix
* Add test for cached run command key consistency
2019-12-15 10:23:31 -08:00
Cole Wippern 2aa481c15e add unit tests for caching run and copy 2019-12-10 09:29:10 -08:00
Cole Wippern b19214ad1e Use cachekey not digest for COPY --from src
* use the cachekey of the src stage rather than the digest
for COPY --from commands as they are reproducible unlike digests
* track digest to cache keys and stage indexes to digest
* add extra debug logging for troubleshooting cachekey building issues
* convert Sha256 hashes to hex encoded strings rather than plain strings
for easier human reading
2019-12-10 08:45:13 -08:00
Cole Wippern 7b4b768edf Update copy command cache key logic
Include the digest of the stage specified in the --from argument for
COPY commands which use --from
2019-12-09 16:48:20 -08:00
Tejal Desai fbdb8f39c8
Merge branch 'master' into registry-mirror 2019-12-09 15:40:56 -08:00
Tejal Desai acb5b9f7c9
Merge pull request #839 from antechrestos/fix/upcase_for_from_stage_name
Fix failure when using capital letters in image alias in 'FROM ... AS…' instruction
2019-12-09 15:39:39 -08:00
Tejal Desai 03b1b1ce4c
Merge pull request #905 from poy/fixes/904
when copying, skip files with the same name
2019-12-09 13:07:13 -08:00
Tejal Desai 56f92e74af
Merge pull request #849 from wripley/master
Modified error message for writing image with digest file
2019-12-09 12:57:33 -08:00
poy 0a2f2957ec when copying, skip files with the same name
When using the COPY command, if the source and destination have the same
the file should be skipped rather than copied. This is to prevent the
file from being overwritten and therefore producing an empty file.

fixes #904
2019-12-08 00:57:27 -07:00
Yoan Blanc 6e331de346
fixup! Merge remote-tracking branch 'origin/master' into registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-12-06 20:10:35 +01:00
Ben Einaudi d22a7608c2 Fix failure when using capital letters in image alias in 'FROM ... AS' instruction
The third library moby/buildkit lowers the image alias used in 'FROM .. AS' instruction.
This change fixes this issue by making the resolve of dependencies agnostic to case.

Fixes #592
Fixes #770
2019-12-06 12:04:26 +01:00
Yoan Blanc 980c87ac17
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-05 19:12:47 +01:00
Cole Wippern 7ba65daf7f cleanup executor/build_test.go 2019-11-28 09:36:39 -08:00
Cole Wippern 828e764b95 add boilerplate for composite_cache_test 2019-11-28 09:18:58 -08:00
Cole Wippern 6d0c8da90e more stagebuilder caching tests 2019-11-28 08:42:13 -08:00
Cole Wippern 33f3191b17 Don't hardcode hashes for stagebuilder tests 2019-11-27 21:47:00 -08:00
Cole Wippern 697037cbcf Add unit tests for compositecache and stagebuilder
* add mock types for testing
* enhance error messaging
* add tests
2019-11-27 21:47:00 -08:00
Cole Wippern 54635c3d39 don't exit optimize early so we record cache keys 2019-11-27 17:09:00 -08:00
Cole Wippern 2755ae4470 Final cachekey for stage
Store the last cachekey generated for each stage
If the base image for a stage is present in the map of digest
and cachekeys use the retrieved cachekey instead of the base image
digest in the compositecache
2019-11-27 14:40:05 -08:00
Prashant Arya 857715012f changing log level 2019-11-26 17:52:11 +00:00
Cole Wippern bfd8562855
Merge pull request #879 from cvgw/u/cvgw/update_error_handling_and_logging_for_cache_retrieve
Update error handling and logging for cache
2019-11-23 10:20:40 -08:00
Cole Wippern a6e458caf1 Update error handling and logging for cache
Previously we returned a low level file system error when checking for
a cached image. By adding a more human friendly log message and explicit
error handling we improve upon the user experience.
2019-11-22 14:54:38 -08:00
Cole Wippern b057776849
Merge pull request #857 from cvgw/u/cgwippern/symlink-bug
Resolve symlink targets to abs path before copying
2019-11-22 10:02:58 -08:00
Cole Wippern 2b26dfea61 Add unit tests for resolveIfSymlink 2019-11-15 11:23:15 -08:00
Cole Wippern 2c13842451 Resolve symlink paths 2019-11-15 11:23:15 -08:00
Cole Wippern 50f1373837 Update Add command RequiresUnpackedFS 2019-11-15 11:23:15 -08:00
Yoan Blanc 6e2287c969
readme: add --registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-11-10 12:55:31 +01:00
Cole Wippern 006b4996cb Fix quote strip behavior for ARG values
* fixes issue 847
* previous implementation did not properly parse blank
values which were enclosed in quotes
2019-11-08 14:28:31 -08:00
Will Ripley f6aa8f709b Modified error message for writing image with digest file 2019-11-08 12:59:25 -06:00
Tejal Desai 1d5e294f27
Merge pull request #841 from wripley/master
Added --image-name-with-digest flag
2019-11-08 08:24:26 -08:00
Yoan Blanc 73f7ea0d2c
fixup! integration: build using registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-11-08 16:17:00 +01:00
Tejal Desai b04d15db82 fix the issue now 2019-11-07 15:29:56 -08:00
Tejal Desai f36dd4013c only add tests 2019-11-07 15:17:25 -08:00
Tejal Desai 334f0c70d6 fix golint 2019-11-07 15:11:29 -08:00
Tejal Desai b29431227a fix tests for default home 2019-11-07 15:07:50 -08:00
Tejal Desai 5bbb40e4f0
Merge pull request #834 from cvgw/u/cgwippern/ISSUE_439_strip_arg_quotes
Issue #439 Strip out double quotes in ARG value
2019-11-07 10:54:17 -08:00
Don McCasland 5716c44ab8
Merge branch 'master' into bug-742-2 2019-11-04 09:25:25 -08:00
Will Ripley c8f089fdbb Fixed formatting errors with push.go and push_test.go 2019-10-29 13:09:27 -05:00
Will Ripley a0651436b5 Changed image name to be full image name minus tag. Also added test for new ImageNameDigestFile flag 2019-10-29 12:55:50 -05:00
Will Ripley c2faa4e5e6 Fixed spacing issue in config 2019-10-29 11:04:33 -05:00
Will Ripley 08d0948510 Merge remote-tracking branch 'upstream/master' 2019-10-29 11:02:16 -05:00
Will Ripley f38c47daa0 Made changes to --image-name-with-digest-file to support multiple destinations 2019-10-29 10:55:49 -05:00
Cole Wippern 0ce287d95c ISSUE #439 ci lint 2019-10-25 16:27:14 -07:00
Cole Wippern ec2e7705c8 Issue #439 add additional tests for quotes
Add additional tests to ensure that ARG values with quotes
are handled properly
2019-10-25 16:08:57 -07:00
Tejal Desai c5bc179c85
Merge pull request #816 from yangtaokm/azure-blobstorage-https
[WIP] Add support to download context file from Azure Blob Storage
2019-10-25 10:51:50 -07:00
Yoan Blanc 235fc4a61f
util: add test to RegistryMirror option
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-10-25 13:07:03 +02:00
Yoan Blanc 3873aa05e3
root: add --registry-mirror flag
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-10-25 11:34:49 +02:00
Cole Wippern 79649a1614 Issue #439 double quotes in ARG value
* Strip out double quotes enclosing ARG value after parsing
dockerfile
2019-10-24 16:30:25 -07:00
yangtaokm aa881d59cb fix gofmt 2019-10-22 17:10:08 +08:00
yangtaokm 45c43a2c89 refactory the code and add CreateTargetTarfile in fs_util.go 2019-10-22 16:44:51 +08:00
Will Ripley 4c9a800e12 Added image digest file path 2019-10-21 11:55:55 -05:00
Tao Yang a86ffc8c57
Apply suggestions from code review
fix formatting based on review

Co-Authored-By: Tejal Desai <tejal29@gmail.com>
2019-10-21 10:19:32 +08:00
Prashant fa162e3005 changing debug to trace 2019-10-18 19:03:11 +05:30
yangtaokm 78e9974694 Add more test case for azureblob_util.go 2019-10-14 13:55:03 +08:00
yangtaokm 3e6a24b152 Initial commit for Azure Blob Storage SupportX 2019-10-13 20:52:19 +08:00
Don McCasland 27020f23b9
Resolving comments 2019-10-08 12:19:20 -07:00
Don McCasland 2b6965b294
addressing lint issues 2019-10-07 13:11:09 -07:00
Don McCasland 2d73c2d996
addressing lint issues 2019-10-07 13:06:40 -07:00
Don McCasland 2eace1d511
Refactoring to add use of a tempdir 2019-10-07 12:56:34 -07:00
Don McCasland 4e1639c030
Addressing review comments 2019-10-07 10:46:28 -07:00
Tejal Desai 529bc4f20e
Merge pull request #805 from tejal29/fix_720
add debug level info what is the layer type
2019-10-04 16:19:49 -07:00
Tejal Desai 1a88d7ae9c better logging 2019-10-04 16:04:12 -07:00
Tejal Desai 3ad9255806 add debug level info what is the layer type 2019-10-04 15:51:05 -07:00
Tejal Desai 1c821d050c
Merge pull request #796 from prary/version
Kaniko version
2019-10-04 14:32:14 -07:00
Tejal Desai b57160198e fix bad merge 2019-10-04 11:20:41 -07:00
Tejal Desai f206e3f425
Merge branch 'master' into output 2019-10-04 08:43:02 -07:00
Tejal Desai 9eb4a1c1ff
Merge pull request #801 from victornoel/776-dockerignore-relative
Support Dockerfile.dockerignore
2019-10-04 01:56:40 -07:00
Victor Noel ff7abba47b Fix integration tests for #776 2019-10-04 10:31:40 +02:00
Tejal Desai 22188595f0
Merge pull request #768 from N4rm0/fix-envar-replacement-for-url
Fix #691 - ADD does not understand ENV variables
2019-10-04 01:17:22 -07:00
Victor Noel 5700de039d Add more tests for #776 2019-10-04 10:08:39 +02:00
Tejal Desai 865d49c631
Merge pull request #694 from orisano/feat-optimize-build
feat: optimize build
2019-10-04 00:51:23 -07:00
Prashant f9424d43e7 fixing lint and minor fix 2019-10-03 21:29:40 +05:30
Victor Noel db12a77e6c Fix #776 2019-10-03 17:53:14 +02:00
Don McCasland dbabcb1f5f
Adding CachingCopy command 2019-09-26 15:32:40 -07:00
Don McCasland e58ee0967a
Fixing logic for Copy command. The problem was not that tar files were being unpacked in wrong order. The problem was that the COPY command requires the FS to be unpacked before it does its work. 2019-09-26 11:29:53 -07:00
jonjohnsonjr 51734fc3a3
Merge pull request #765 from Onlinehead/fix/filesystem-delete-fix
Fix SIGSEGV on file system deletion while building
2019-09-25 11:47:35 -07:00
Monard Vong 019b26e9a0 Simplify logic 2019-09-22 01:09:36 +02:00
Don McCasland ccd99fbeec
Merge pull request #685 from tralexa/master
insecure flag not honored in cache
2019-09-20 13:32:19 -07:00
Антон Костенко a21129f889 Fix typo and run go fmt over fs_util 2019-09-18 10:43:26 +02:00
Nao YONASHIRO 38fa3608ce chore: fix megacheck 2019-09-18 17:19:15 +09:00
Nao YONASHIRO d9d865c74a test: add BenchmarkHasFilepathPrefix 2019-09-18 17:19:15 +09:00
Nao YONASHIRO 02d1ce5e1b feat: optimize HasFilepathPrefix 2019-09-18 17:19:15 +09:00
Nao YONASHIRO c87d2dba9c feat: replace md5 to highwayhash 2019-09-18 17:19:15 +09:00
Tejal Desai e048b87222
Merge pull request #671 from abergmeier/fix_comment
Correct CheckPushPermission comment.
This is a typo fix.
2019-09-17 10:44:54 -07:00
Don McCasland 1bb5a41d7d
Fixing lint issues. Adding tests for COPY command. Fixing issue with copying files out of snapshots 2019-09-16 10:48:31 -07:00