Commit Graph

40 Commits

Author SHA1 Message Date
Matthias Schneider a9062b97f7
feat: Added --chmod for ADD and COPY command. Fixes #2850 (#3119) 2024-04-22 09:28:37 -07:00
Prima Adi Pradana 02f488a694
Fix #3032: Remove query parameters in ADD command when the destinatio… (#3053)
* Fix #3032: Remove query parameters in ADD command when the destination is a directory

* fixing linter URL sorry forget to lint

* add error in extractFilename and realize that ResolveEnvironmentReplacement better execute before getting the filename
2024-03-21 19:32:40 -07:00
Vishal Khot 2a1b29a9f1
Remove fallbackToUID bool option from Kaniko code (#2767) 2023-10-02 17:36:15 -07:00
Diego Gonzalez 2b6b5948da
Avoid returning the UID when resolving the GIDs. (#2689)
* Fix GetUIDAndGIDFromString test.

* Avoid returning by default the UID when resolving the GIDs.
2023-08-31 18:05:27 -07:00
Angus Williams de3032f982
Refactors IsSrcRemoteFileURL to only validate the URL is valid (#2563)
`IsSrcRemoteFileURL` was doing a `http.Get` call to make sure the URL was valid, but not surfacing any errors.
Because the error from the http.Get call is not handled, some useful information can be buried.
It also means kaniko will download the file twice during a build, once to validate, and once to actually add the file
to the image.
Removing the http.Get call and validating the URL is valid, and has the correct schema and hostname will stop
the double handling, and allow any errors to be surfaced through the error handing in the file download function.

Fixes #1590

Signed-off-by: Angus Williams <anguswilliams@gmail.com>
2023-06-14 10:20:28 -07:00
Joe Kimmel 906cc96b59
Upgrade docker (#2440)
* somehow now the only thing that doesnt work is devices.Device

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* this gets rid of all the compiler errors in the vendored code

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* fixed some things but a bunch of tests and maybe some compiler steps are still failing

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* all the things i figured out how to fix so far

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* guess i had to redo go mods after rebasing again

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* update docker constants to be SHOUTY CASE now

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* include DestPath in resolveEnv

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* fix one mistake in Docker lib upgrade and some typos/deprecations in the file

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* last changes (hopefully) to update to new docker libs

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-03-23 20:34:25 -04:00
Lukas aad03dc285
fix: getUIDandGID is able to resolve non-existing users and groups (#2106)
* fix: getUIDandGID is able to resolve non-existing users and groups

A common pattern in dockerfiles is to provide a plain uid and gid number, which doesn't neccesarily exist inside the os.

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* test: add chown dockerfile

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* chore: format

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* chore: add comment

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* tests: fix chown dockerfile

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* refactor: split up getIdsFromUsernameAndGroup func

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* fix: implement raw uid logic for LookupUser

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* test: add dockerfiles for integration test

* fix: lookup user error message

* test: add dockerfiles for non-existing user testcase

* fix: forgot error check

* tests: fix syscall credentials test

* chore: add debug output for copy command

* tests: set specific gid for integration dockerfile

* tests: fix syscall credentials test

github runner had the exact uid that i was testing on, so the groups were not empty

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* tests: fix test script

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* chore: apply golangci lint checks

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* fix: reset file ownership in createFile if not root owned

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* chore: logrus.Debugf missed format variable

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* chore(test-script): remove go html coverage

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* test(k8s): increase wait timeout

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>
2022-07-12 10:21:37 -04:00
nihilo 682191f523
Bugfix/trailing path separator (#1683)
* Test_EnvReplacement: env of path ends in a slash

* Fix trailing path separator
2021-07-08 12:06:52 -07:00
Tinjo Schöni 5f4e2f1366
Fix .dockerignore for build context copies in later stages (#1447)
* Extend .dockerignore integration test with copies in later stages

.dockerignore should continue to apply when copying from the build context in later stages, but it currently doesn't

* Replace excluded global with passed along FileContext struct

This new FileContext struct allows much cleaner handling of context specific file exclusions.
The global excluded file state is no longer needed.

Additionally this also fixes the issue where excluded files aren't being applied for build context copies in later build stages.
2020-10-08 12:47:14 -07:00
Dani Raznikov 6b44ed4477 calculateDepdencies on a copy of envvars 2020-04-04 23:27:15 +03:00
Dani Raznikov c136f886a9 Add support to --chown flag to ADD command 2020-03-14 16:24:40 +02:00
Tejal Desai 31f626cb22 initilize group to 0 2020-02-03 22:15:56 -08:00
xanonid 517cb50278 Add Unit test for GetUIDAndGIDFromString 2020-02-03 14:56:23 -08: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
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 db12a77e6c Fix #776 2019-10-03 17:53:14 +02:00
Monard Vong 13b8fb6345 remove trailing whitespace 2019-09-15 23:29:54 +02:00
Monard Vong 38474fad11 Fix #691 - ADD does not understand ENV variables 2019-09-15 23:08:44 +02:00
dlorenc 246cc92a33
Optimize file copying and stage saving between stages. (#605)
This change calculates the exact files and directories needed between
stages used in the COPY command. Instead of saving the entire
stage as a tarball, we now save only the necessary files.
2019-03-13 07:47:28 -07:00
dlorenc 2abe109eb2
Environment variables should be replaced in URLs in ADD commands. (#580)
We were previously explicitly skipping this for some reason, but Docker
seems to expand these in URLs so we should too.
2019-02-25 10:42:34 -06:00
Priya Wadhwa 7fd164deab Only parse .dockerignore once 2018-12-11 13:31:51 -08:00
Priya Wadhwa b0b36ed85a Re-add support for .dockerignore file
This PR adds support for the dockerignore file. Previously when kaniko
had support for the dockerignore file, kaniko first went through the
build context and deleted files that were meant to be ignored. This
resulted in a really bad bug where files in user mounted volumes would
be deleted (my bad).

This time around, instead of modifying the build context at all, kaniko
will check if a file should be excluded when executing ADD/COPY
commands. If a file should be excluded (based on the .dockerignore) it
won't be copied over from the buildcontext and shouldn't end up in the
final image.

I also added a .dockerignore file and Dockerfile as an integration test,
which should fail if the dockerignore is not being processed correctly or if files aren't being excluded correctly.
Also, I removed all the integration testing from the previous version of the
dockerignore support.
2018-12-10 15:20:25 -08:00
Priya Wadhwa 99ab68e7f4 Replace gometalinter with GolangCI-Lint
gometalinter is broken @ HEAD, and I looked into why that was. During
that process, I remembered that we took the linting scripts from
skaffold, and found that in skaffold gometalinter was replaced with
GolangCI-Lint:

https://github.com/GoogleContainerTools/skaffold/pull/619

The change made linting in skaffold faster, so I figured instead of
fixing gometalinter it made more sense to remove it and replace it with
GolangCI-Lint for kaniko as well.
2018-09-11 13:30:42 -07:00
Priya Wadhwa 1513295103 Make sure paths are absolute before matching files to wildcard sources
The bug in #329 occurred because of a bug in matchSources, where the
filepath wasn't absolute, so the source "/kaniko-bug/*" wasn't being
matched to the file "kaniko-bug/test-file"

To fix this, I added logic for making filepaths absolute and added to
the unit test for the function to test that it works.
2018-08-31 11:57:20 -07:00
priyawadhwa 52e9863810
fix add command bug when adding remote URLs (#277) 2018-08-07 17:10:27 -07:00
dlorenc 8716936977
Switch the valid URL to https://google.com. (#242)
It appears sometimes Github goes down :)
2018-07-18 09:43:12 -07:00
Christie Wilson 5f9fb2cb8d Fix remote URL test (#237)
When this test was originally created, an HTTP get to
`https://url.com/something/not/real` probably failed, but now it
will return a `503`, i.e. the `http.Get` call will succeed.

This test will now use a URL which should not reasonable ever
succeed (famous last words). Alternatively we could use dependency
injection and mock `http.Get` but it doesn't seem worth it.

This commit also updates the test to use `Run` to run each test
in the table test as a separate test so we can get a clear indication
which cases fail and which succeed.
2018-07-17 17:21:51 -07:00
Sharif Elgamal f8aa88b119
Integration test refactoring (#126)
* integration test refactoring

* config file cleanup

* more test refactoring

* remove debug file

* moving around more files

* fixing up integration tests

* integration tests work

* some housekeeping

* fixing tests

* addressing comments

* debugging

* debugging

* actual debugging

* skip integration tests for travis

* install container-diff before integration tests

* syntax

* make test failures less noisy

* fixing tests

* hopefully fixing CI?

* fixes

* more fixes

* let's actually fix CI

* more testing

* testing

* proper auth

* typos

* adding support for args in integration tests

* formatting

* formatting

* adding support for testing bucket context

* adding bucket test dockerfile

* addressing comments

* syntax
2018-05-15 13:42:35 -07:00
Priya Wadhwa be38696c7d Updated unit tests after refactor 2018-04-19 20:39:29 -07:00
Matt Rickard cff201dee6 org rename from GoogleCloudPlatform to GoogleContainerTools 2018-04-17 11:45:39 -07:00
Priya Wadhwa ec510a161b
change imports from k8s-container-builder to kaniko 2018-04-12 15:35:54 -07:00
Priya Wadhwa 89400b7410
Add command with unit tests 2018-03-28 13:34:00 -07:00
Priya Wadhwa b64f23b078
Use default token for parsing 2018-03-27 09:44:51 -07:00
Priya Wadhwa dbb0774778
Environment replacement 2018-03-21 15:01:21 -07:00
Priya Wadhwa cf24231121
WIP 2018-03-20 17:15:09 -07:00
Priya Wadhwa 58e70d8b77
Environment replacement 2018-03-20 15:56:31 -07:00
Priya Wadhwa cc0c672697
Add support for dest = '.' and additional DestinationFilepath test 2018-03-20 14:10:13 -07:00
Priya Wadhwa de8cc1a285
Fixed check srcs function and create file with correct permissions 2018-03-16 14:11:06 -07:00
Priya Wadhwa 5ebf156d94
Fixed relative filepath and unit test 2018-03-15 13:47:40 -07:00
Priya Wadhwa 21a9207428
Copy command and unit tests 2018-03-14 17:06:46 -07:00