Merge "Revert "Adding Filesystem check function to templater""
This commit is contained in:
commit
ba81a32a50
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package extlib
|
|
||||||
|
|
||||||
import (
|
|
||||||
"opendev.org/airship/airshipctl/pkg/fs"
|
|
||||||
)
|
|
||||||
|
|
||||||
func fileExists(path string) bool {
|
|
||||||
docfs := fs.NewDocumentFs()
|
|
||||||
return docfs.Exists(path)
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package extlib
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestFileExists(t *testing.T) {
|
|
||||||
assert.Equal(t, true, fileExists("fs_test.go"))
|
|
||||||
assert.Equal(t, false, fileExists("fs_test_nonexistent.go"))
|
|
||||||
}
|
|
@ -32,7 +32,6 @@ var genericMap = map[string]interface{}{
|
|||||||
"genCAWithKeyEx": generateCertificateAuthorityWithPEMKeyEx,
|
"genCAWithKeyEx": generateCertificateAuthorityWithPEMKeyEx,
|
||||||
"genSignedCertEx": generateSignedCertificateEx,
|
"genSignedCertEx": generateSignedCertificateEx,
|
||||||
"genSignedCertWithKeyEx": generateSignedCertificateWithPEMKeyEx,
|
"genSignedCertWithKeyEx": generateSignedCertificateWithPEMKeyEx,
|
||||||
"fileExists": fileExists,
|
|
||||||
"regexGen": regexGen,
|
"regexGen": regexGen,
|
||||||
"toYaml": toYaml,
|
"toYaml": toYaml,
|
||||||
"toUint32": toUint32,
|
"toUint32": toUint32,
|
||||||
|
@ -186,20 +186,6 @@ template: |
|
|||||||
"at <regexGen .regex (.limit | int)>: error calling " +
|
"at <regexGen .regex (.limit | int)>: error calling " +
|
||||||
"regexGen: error parsing regexp: missing closing ]: `[a-z`",
|
"regexGen: error parsing regexp: missing closing ]: `[a-z`",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
cfg: `
|
|
||||||
apiVersion: airshipit.org/v1alpha1
|
|
||||||
kind: Templater
|
|
||||||
metadata:
|
|
||||||
name: notImportantHere
|
|
||||||
template: |
|
|
||||||
FileExists: {{ fileExists "./templater.go" }}
|
|
||||||
NoFileExists: {{ fileExists "./templater1.go" }}
|
|
||||||
`,
|
|
||||||
expectedOut: `FileExists: true
|
|
||||||
NoFileExists: false
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user