Skip to content

Commit

Permalink
Update documentation and add more escape options
Browse files Browse the repository at this point in the history
  • Loading branch information
tlbdk committed Nov 20, 2019
1 parent cb4c928 commit 396613e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Docker buildkit build with a key stored in Google Cloud KMS:
export SSH_KEY_PATH=kms://projects/yourprojectname/locations/global/keyRings/yourkeyring/cryptoKeys/ssh-key/cryptoKeyVersions/1
export PROGRESS_NO_TRUNC=1
export DOCKER_BUILDKIT=1
auth-wrapper docker --progress=plain --ssh=default='$SSH_AUTH_SOCK' .
# The strings $SSH_AUTH_SOCK and $$SSH_AUTH_SOCK will be replaced with socket in the arguments
auth-wrapper docker --progress=plain --ssh=default='\$SSH_AUTH_SOCK' . # Note the escape to make sure we don't use the shells SSH_AUTH_SOCK
```

[Dockerfile](./testdata/Dockerfile)
Expand All @@ -40,7 +41,7 @@ steps:
- name: 'gcr.io/$PROJECT_ID/auth-wrapper.master:latest'
args: ['build', '--progress=plain', '--ssh=default=$$SSH_AUTH_SOCK', '-tag=gcr.io/$PROJECT_ID/$REPO_NAME.$BRANCH_NAME:$COMMIT_SHA', '.']
env:
- "SSH_KEY_PATH=kms://projects/connectedcars-staging/locations/global/keyRings/cloudbuilder/cryptoKeys/ssh-key/cryptoKeyVersions/3"
- "SSH_KEY_PATH=kms://projects/$PROJECT_ID/locations/global/keyRings/cloudbuilder/cryptoKeys/ssh-key/cryptoKeyVersions/1"
- "PROGRESS_NO_TRUNC=1"
- "DOCKER_BUILDKIT=1"
images: ['gcr.io/$PROJECT_ID/$REPO_NAME.$BRANCH_NAME']
Expand Down
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func runWithSSHAgent(command string, args []string, sshKeyPath string, sshKeyPas

// Do string replacement for SSH_AUTH_SOCK
for i, arg := range args {
fmt.Fprintf(os.Stderr, "arg[%d]: %s\n", i, arg)
args[i] = strings.ReplaceAll(arg, "$SSH_AUTH_SOCK", sshAuthSock)
args[i] = strings.ReplaceAll(arg, "$$SSH_AUTH_SOCK", sshAuthSock)
}

}
Expand Down

0 comments on commit 396613e

Please sign in to comment.