Skip to content

Commit

Permalink
Revert containerDaemonSocket breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX authored and github-actions committed Apr 25, 2023
1 parent ac8d38c commit 70fcc8a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ func parseMatrix(matrix []string) map[string]map[string]bool {
return matrixes
}

func isDockerHostURI(daemonPath string) bool {
if protoIndex := strings.Index(daemonPath, "://"); protoIndex != -1 {
scheme := daemonPath[:protoIndex]
if strings.IndexFunc(scheme, func(r rune) bool {
return (r < 'a' || r > 'z') && (r < 'A' || r > 'Z')
}) == -1 {
return true
}
}
return false
}

//nolint:gocyclo
func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
Expand All @@ -365,7 +377,8 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
socketPath, hasDockerHost := os.LookupEnv("DOCKER_HOST")
if !hasDockerHost {
// a - in containerDaemonSocket means don't mount, preserve this value
skipMount := input.containerDaemonSocket == "-"
// otherwise if input.containerDaemonSocket is a filepath don't use it as socketPath
skipMount := input.containerDaemonSocket == "-" || !isDockerHostURI(input.containerDaemonSocket)
if input.containerDaemonSocket != "" && !skipMount {
socketPath = input.containerDaemonSocket
} else {
Expand Down

0 comments on commit 70fcc8a

Please sign in to comment.