sigs.k8s.io/cluster-api@v1.7.1/cmd/clusterctl/internal/test/fake_processor.go (about) 1 /* 2 Copyright 2019 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 test 18 19 import ( 20 "fmt" 21 ) 22 23 type FakeProcessor struct { 24 errGetVariables error 25 errGetVariableMap error 26 errProcess error 27 artifactName string 28 } 29 30 func NewFakeProcessor() *FakeProcessor { 31 return &FakeProcessor{} 32 } 33 34 func (fp *FakeProcessor) WithTemplateName(n string) *FakeProcessor { 35 fp.artifactName = n 36 return fp 37 } 38 39 func (fp *FakeProcessor) WithGetVariablesErr(e error) *FakeProcessor { 40 fp.errGetVariables = e 41 return fp 42 } 43 44 func (fp *FakeProcessor) WithProcessErr(e error) *FakeProcessor { 45 fp.errProcess = e 46 return fp 47 } 48 49 func (fp *FakeProcessor) GetTemplateName(_, _ string) string { 50 return fp.artifactName 51 } 52 53 func (fp *FakeProcessor) GetClusterClassTemplateName(_, name string) string { 54 return fmt.Sprintf("clusterclass-%s.yaml", name) 55 } 56 57 func (fp *FakeProcessor) GetVariables(_ []byte) ([]string, error) { 58 return nil, fp.errGetVariables 59 } 60 61 func (fp *FakeProcessor) GetVariableMap(_ []byte) (map[string]*string, error) { 62 return nil, fp.errGetVariableMap 63 } 64 65 func (fp *FakeProcessor) Process(_ []byte, _ func(string) (string, error)) ([]byte, error) { 66 return nil, fp.errProcess 67 }