github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/docker/buildkit/ssh.go (about) 1 /** 2 Code for parsing Buildkit arguments adapted from Docker CLI 3 4 Adapted from 5 https://github.com/docker/cli/blob/28ac2f82c690ac8f37c2980f2787572815439a50/cli/command/image/build_buildkit.go 6 7 8 Copyright 2013-2017 Docker, Inc. 9 10 Licensed under the Apache License, Version 2.0 (the "License"); 11 you may not use this file except in compliance with the License. 12 You may obtain a copy of the License at 13 14 http://www.apache.org/licenses/LICENSE-2.0 15 16 Unless required by applicable law or agreed to in writing, software 17 distributed under the License is distributed on an "AS IS" BASIS, 18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 See the License for the specific language governing permissions and 20 limitations under the License. 21 */ 22 23 package buildkit 24 25 import ( 26 "strings" 27 28 "github.com/moby/buildkit/session" 29 "github.com/moby/buildkit/session/sshforward/sshprovider" 30 ) 31 32 func ParseSSHSpecs(sl []string) (session.Attachable, error) { 33 configs := make([]sshprovider.AgentConfig, 0, len(sl)) 34 for _, v := range sl { 35 c := parseSSH(v) 36 configs = append(configs, *c) 37 } 38 return sshprovider.NewSSHAgentProvider(configs) 39 } 40 41 func parseSSH(value string) *sshprovider.AgentConfig { 42 parts := strings.SplitN(value, "=", 2) 43 cfg := sshprovider.AgentConfig{ 44 ID: parts[0], 45 } 46 if len(parts) > 1 { 47 cfg.Paths = strings.Split(parts[1], ",") 48 } 49 return &cfg 50 }