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

feat: Add network option to BuildpackArtifact #9565

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs-v2/content/en/schemas/v4beta12.json
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,11 @@
"[\"key1=value1\", \"key2=value2\", \"key3={{.ENV_VARIABLE}}\"]"
]
},
"network": {
"type": "string",
"description": "configure network settings of the build containers. The value of Network is handed directly to the docker client. For valid values of this field see: https://docs.docker.com/network/#network-drivers.",
"x-intellij-html-description": "configure network settings of the build containers. The value of Network is handed directly to the docker client. For valid values of this field see: https://docs.docker.com/network/#network-drivers."
},
"projectDescriptor": {
"type": "string",
"description": "path to the project descriptor file.",
Expand Down Expand Up @@ -1066,7 +1071,8 @@
"clearCache",
"projectDescriptor",
"dependencies",
"volumes"
"volumes",
"network"
],
"additionalProperties": false,
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,5 @@ func containerConfig(artifact *latest.BuildpackArtifact) (pack.ContainerConfig,
vols = append(vols, spec)
}

return pack.ContainerConfig{Volumes: vols}, nil
return pack.ContainerConfig{Volumes: vols, Network: artifact.Network}, nil
}
14 changes: 14 additions & 0 deletions pkg/skaffold/build/buildpacks/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,22 @@ func TestContainerConfig(t *testing.T) {
tests := []struct {
description string
volumes []*latest.BuildpackVolume
network string
shouldErr bool
expected pack.ContainerConfig
}{
{
description: "only network",
volumes: []*latest.BuildpackVolume{},
network: "host",
expected: pack.ContainerConfig{Network: "host"},
},
{
description: "network and volume",
volumes: []*latest.BuildpackVolume{{Host: "/foo", Target: "/bar"}},
network: "host",
expected: pack.ContainerConfig{Volumes: []string{"/foo:/bar"}, Network: "host"},
},
{
description: "single volume with no options",
volumes: []*latest.BuildpackVolume{{Host: "/foo", Target: "/bar"}},
Expand Down Expand Up @@ -96,6 +109,7 @@ func TestContainerConfig(t *testing.T) {
testutil.Run(t, test.description, func(t *testutil.T) {
artifact := latest.BuildpackArtifact{
Volumes: test.volumes,
Network: test.network,
}
result, err := containerConfig(&artifact)
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expected, result)
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,11 @@ type BuildpackArtifact struct {

// Volumes support mounting host volumes into the container.
Volumes []*BuildpackVolume `yaml:"volumes,omitempty"`

// Network configure network settings of the build containers.
// The value of Network is handed directly to the docker client.
// For valid values of this field see: https://docs.docker.com/network/#network-drivers.
Network string `yaml:"network,omitempty"`
}

// BuildpackDependencies *alpha* is used to specify dependencies for an artifact built by buildpacks.
Expand Down