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(docker-network): docker.network now supports any value #9390

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions docs-v2/content/en/schemas/v4beta10.json
Original file line number Diff line number Diff line change
Expand Up @@ -1773,14 +1773,8 @@
},
"network": {
"type": "string",
"description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are `host`: use the host's networking stack. `bridge`: use the bridged network configuration. `container:<name|id>`: reuse another container's network stack. `none`: no networking in the container.",
"x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are <code>host</code>: use the host's networking stack. <code>bridge</code>: use the bridged network configuration. <code>container:&lt;name|id&gt;</code>: reuse another container's network stack. <code>none</code>: no networking in the container.",
"enum": [
"host",
"bridge",
"container:<name|id>",
"none"
]
"description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Examples: `host`: use the host's networking stack. `bridge`: use the bridged network configuration. `container:<name|id>`: reuse another container's network stack. `none`: no networking in the container. `my-custom-network`: user-defined network.",
"x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Examples: <code>host</code>: use the host's networking stack. <code>bridge</code>: use the bridged network configuration. <code>container:&lt;name|id&gt;</code>: reuse another container's network stack. <code>none</code>: no networking in the container. <code>my-custom-network</code>: user-defined network."
},
"noCache": {
"type": "boolean",
Expand Down
2 changes: 2 additions & 0 deletions fs/assets/credits_generated/github.com/hashicorp/hcl/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/hashicorp/hcl

go 1.22
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to fix this issue #9352 (comment)


require github.com/davecgh/go-spew v1.1.1
4 changes: 3 additions & 1 deletion pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,11 +1551,13 @@ type DockerArtifact struct {

// NetworkMode is passed through to docker and overrides the
// network configuration of docker builder. If unset, use whatever
// is configured in the underlying docker daemon. Valid modes are
// is configured in the underlying docker daemon.
// Examples:
// `host`: use the host's networking stack.
// `bridge`: use the bridged network configuration.
// `container:<name|id>`: reuse another container's network stack.
// `none`: no networking in the container.
// `my-custom-network`: user-defined network.
NetworkMode string `yaml:"network,omitempty"`

// AddHost lists add host.
Expand Down
3 changes: 1 addition & 2 deletions pkg/skaffold/schema/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ func validateDockerNetworkMode(cfg *parser.SkaffoldConfigEntry, artifacts []*lat
if a.DockerArtifact == nil || a.DockerArtifact.NetworkMode == "" {
continue
}
mode := strings.ToLower(a.DockerArtifact.NetworkMode)
if mode == "none" || mode == "bridge" || mode == "host" {
if !strings.HasPrefix(strings.ToLower(a.DockerArtifact.NetworkMode), "container:") {
continue
}
networkModeErr := validateDockerNetworkModeExpression(a.ImageName, a.DockerArtifact.NetworkMode)
Expand Down
8 changes: 4 additions & 4 deletions pkg/skaffold/schema/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,14 @@ func TestValidateNetworkMode(t *testing.T) {
},
},
{
description: "invalid networkmode",
shouldErr: true,
description: "custom networkmode",
shouldErr: false,
artifacts: []*latest.Artifact{
{
ImageName: "image/bad",
ImageName: "image/custom",
ArtifactType: latest.ArtifactType{
DockerArtifact: &latest.DockerArtifact{
NetworkMode: "Bad",
NetworkMode: "my-network-mode",
},
},
},
Expand Down