github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/kubectl/exec.go (about) 1 //go:build !windows 2 // +build !windows 3 4 /* 5 Copyright 2020 The Skaffold Authors 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package kubectl 21 22 import ( 23 "context" 24 "os/exec" 25 ) 26 27 // Cmd is a wrapper on exec.Cmd 28 type Cmd struct { 29 *exec.Cmd 30 } 31 32 // CommandContext creates a new Cmd 33 func CommandContext(ctx context.Context, name string, arg ...string) *Cmd { 34 return &Cmd{Cmd: exec.CommandContext(ctx, name, arg...)} 35 } 36 37 // Terminate kills the underlying process 38 func (c *Cmd) Terminate() error { 39 return c.Process.Kill() 40 }