github.com/jk-he/cni@v0.8.1/pkg/invoke/fakes/raw_exec.go (about) 1 // Copyright 2016 CNI authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package fakes 16 17 import "context" 18 19 type RawExec struct { 20 ExecPluginCall struct { 21 Received struct { 22 PluginPath string 23 StdinData []byte 24 Environ []string 25 } 26 Returns struct { 27 ResultBytes []byte 28 Error error 29 } 30 } 31 FindInPathCall struct { 32 Received struct { 33 Plugin string 34 Paths []string 35 } 36 Returns struct { 37 Path string 38 Error error 39 } 40 } 41 } 42 43 func (e *RawExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData []byte, environ []string) ([]byte, error) { 44 e.ExecPluginCall.Received.PluginPath = pluginPath 45 e.ExecPluginCall.Received.StdinData = stdinData 46 e.ExecPluginCall.Received.Environ = environ 47 return e.ExecPluginCall.Returns.ResultBytes, e.ExecPluginCall.Returns.Error 48 } 49 50 func (e *RawExec) FindInPath(plugin string, paths []string) (string, error) { 51 e.FindInPathCall.Received.Plugin = plugin 52 e.FindInPathCall.Received.Paths = paths 53 return e.FindInPathCall.Returns.Path, e.FindInPathCall.Returns.Error 54 }