Skip to content

Adapting validation for docker container network mode to include ENV_VARS #5589

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

Conversation

zedfmario
Copy link
Contributor

Description

In PR #5088 I enabled the possibility of reusing the network stack from another docker container.
That mode required either a name or a docker id to check what container you want to reuse the network stack from.

The configuration at that point required the exact name or id. It's quite common in the docker environment, when referencing by id, to use the very first 12 chars of the container name, as those are the ones shown when docker ps is executed.
Example:

> docker ps
CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS               NAMES
7765077b5d37        alpine              "tail -f /dev/null"   About an hour ago   Up About an hour                        alpine

This PR finds docker containers by ids using HasPrefix instead of equal. It also adapts the validation for docker container network mode to include ENV_VARS. It will automatically translate the ENV_VAR with the os.Environment variable.

User facing changes (remove if N/A)

from now on, it is possible to write the container name as follows:

build:
  docker:
    network: "container:{{.ENV_VAR}}"

where ENV_VAR could be 7765077b5d37, for example.

…ARS. It also finds docker containers by ids using HasPrefix instead of equal.

from now on, it is possible to write the container name as follows:

```
build:
  docker:
    network: "container:{{.ENV_VAR}}"
```

it will automatically translate the ENV_VAR with the os.Environment variable.
@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #5589 (0897b85) into master (70cd58b) will decrease coverage by 0.02%.
The diff coverage is 73.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5589      +/-   ##
==========================================
- Coverage   71.08%   71.06%   -0.03%     
==========================================
  Files         402      402              
  Lines       15145    15182      +37     
==========================================
+ Hits        10766    10789      +23     
- Misses       3586     3598      +12     
- Partials      793      795       +2     
Impacted Files Coverage Δ
pkg/skaffold/schema/validation/validation.go 86.64% <73.07%> (-3.78%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70cd58b...0897b85. Read the comment docs.

@zedfmario zedfmario marked this pull request as ready for review March 22, 2021 09:58
@zedfmario zedfmario requested a review from a team as a code owner March 22, 2021 09:58
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

few nits.

@zedfmario zedfmario marked this pull request as draft March 23, 2021 08:12
@zedfmario zedfmario marked this pull request as ready for review March 23, 2021 09:04
@zedfmario zedfmario requested a review from tejal29 March 23, 2021 09:50
@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Mar 24, 2021
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Mar 24, 2021
@tejal29 tejal29 merged commit 3a6c3e0 into GoogleContainerTools:master Mar 24, 2021
@zedfmario zedfmario deleted the feature/container-network-mode-with-envvars branch November 28, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants