Skip to content

Commit

Permalink
Merge pull request #19 from harness/CI-9848
Browse files Browse the repository at this point in the history
fix: [CI-9848]: network driver flag
  • Loading branch information
devkimittal authored Oct 10, 2023
2 parents c6b8475 + d41d79d commit dd02097
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type Config struct {
ServerName string `envconfig:"SERVER_NAME" default:"drone"`

Runner struct {
Volumes []string `envconfig:"CI_MOUNT_VOLUMES"`
Volumes []string `envconfig:"CI_MOUNT_VOLUMES"`
NetworkDriver string `envconfig:"NETWORK_DRIVER"`
}

Server struct {
Expand Down
5 changes: 5 additions & 0 deletions engine/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func (e *Docker) Setup(ctx context.Context, pipelineConfig *spec.PipelineConfig)
if pipelineConfig.Platform.OS == "windows" {
driver = "nat"
}

if pipelineConfig.NetworkDriver != "" {
driver = pipelineConfig.NetworkDriver
}

_, err := e.client.NetworkCreate(ctx, pipelineConfig.Network.ID, types.NetworkCreate{
Driver: driver,
Options: pipelineConfig.Network.Options,
Expand Down
2 changes: 1 addition & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func toWindowsDrive(s string) string {
if len(s) >= 2 && (s[0] >= 'a' && s[0] <= 'z' || s[0] >= 'A' && s[0] <= 'Z') && s[1] == ':' {
return toWindowsPath(s)
}
return "c:" + toWindowsPath(s)
return "C:" + toWindowsPath(s)
}

// helper function converts the path to a valid windows
Expand Down
1 change: 1 addition & 0 deletions engine/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type (
Platform Platform `json:"platform,omitempty"`
Volumes []*Volume `json:"volumes,omitempty"`
Network Network `json:"network"`
NetworkDriver string `json:"network_driver"`
Envs map[string]string `json:"envs,omitempty"`
Files []*File `json:"files,omitempty"`
EnableDockerSetup *bool `json:"mount_docker_socket"`
Expand Down
5 changes: 3 additions & 2 deletions handler/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ func HandleSetup(config *config.Config) http.HandlerFunc {
s.Volumes = append(s.Volumes, getGlobalVolumes(config)...)

cfg := &spec.PipelineConfig{
Envs: s.Envs,
Network: s.Network,
Envs: s.Envs,
Network: s.Network,
NetworkDriver: config.Runner.NetworkDriver,
Platform: spec.Platform{
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Expand Down
4 changes: 3 additions & 1 deletion handler/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func HandleStartStep(config *config.Config) http.HandlerFunc {
v.Path = hv.HostPath.Path
}
}
updateDelegateCapacity(&s.StartStepRequestConfig)
if config.DelegateCapacity.Secret != "" {
updateDelegateCapacity(&s.StartStepRequestConfig)
}
updateGitCloneConfig(&s.StartStepRequestConfig)

// fmt.Printf("start step request config: %+v\n", s.StartStepRequestConfig)
Expand Down

0 comments on commit dd02097

Please sign in to comment.