Skip to content

Commit

Permalink
feat(docker.network): docker->network now supports any value
Browse files Browse the repository at this point in the history
  • Loading branch information
idsulik committed Apr 17, 2024
1 parent ba74c33 commit 9b95087
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
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

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

0 comments on commit 9b95087

Please sign in to comment.