Debian Codegraph @

exec.go

raw symbols SCIP
1 /*
2 Copyright 2023 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package knftablesscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/
18
19 import (
20 "os/execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/"
21 )
22
23 // execer is a mockable wrapper around os/exec.
24 type execerscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/execer# interface {
25 // LookPath wraps exec.LookPath
26 LookPathscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/execer#LookPath.(file string) (string, error)
27
28 // Run runs cmd as with cmd.Output(). If an error occurs, and the process outputs
29 // stderr, then that output will be returned in the error.
30 Runscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/execer#Run.(cmd *execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/.Cmdscip-go gomod github.com/golang/go/src go1.20 `os/exec`/Cmd#) (string, error)
31 }
32
33 // realExec implements execer by actually using os/exec
34 type realExecscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/realExec# struct{}
35
36 // LookPath is part of execer
37 func (realExecscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/realExec#) LookPathscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/realExec#LookPath().(file string) (string, error) {
38 return execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/.LookPathscip-go gomod github.com/golang/go/src go1.20 `os/exec`/LookPath().(file)
39 }
40
41 // Run is part of execer
42 func (realExecscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/realExec#) Runscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/realExec#Run().(cmd *execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/.Cmdscip-go gomod github.com/golang/go/src go1.20 `os/exec`/Cmd#) (string, error) {
43 out, err := cmd.Outputscip-go gomod github.com/golang/go/src go1.20 `os/exec`/Cmd#Output().()
44 if err != nil {
45 err = wrapErrorscip-go gomod sigs.k8s.io/knftables . `sigs.k8s.io/knftables`/wrapError().(err)
46 }
47 return string(out), err
48 }