Merge "Revert "Adding Filesystem check function to templater""

This commit is contained in:
Zuul 2021-03-01 17:45:24 +00:00 committed by Gerrit Code Review
commit ba81a32a50
4 changed files with 0 additions and 65 deletions

View File

@ -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)
}

View File

@ -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"))
}

View File

@ -32,7 +32,6 @@ var genericMap = map[string]interface{}{
"genCAWithKeyEx": generateCertificateAuthorityWithPEMKeyEx,
"genSignedCertEx": generateSignedCertificateEx,
"genSignedCertWithKeyEx": generateSignedCertificateWithPEMKeyEx,
"fileExists": fileExists,
"regexGen": regexGen,
"toYaml": toYaml,
"toUint32": toUint32,

View File

@ -186,20 +186,6 @@ template: |
"at <regexGen .regex (.limit | int)>: error calling " +
"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 {