From b70848b57b7cb92a4f36c4f3be5ff09f4120db4d Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Fri, 26 Feb 2021 18:39:44 +0000 Subject: [PATCH] Revert "Adding Filesystem check function to templater" This reverts commit 154bcec95cc207339f05dd4d62e987efb25d0366 We don't use this function anywhere, moreover fs related functions are way beyond the reasonable functionality of templater. Especially taking into account that we have only 1 function. Change-Id: I919d8466ff1eab2d2687db7055bf974b7b608d8e --- pkg/document/plugin/templater/extlib/fs.go | 24 ----------------- .../plugin/templater/extlib/fs_test.go | 26 ------------------- .../plugin/templater/extlib/funcmap.go | 1 - .../plugin/templater/templater_test.go | 14 ---------- 4 files changed, 65 deletions(-) delete mode 100644 pkg/document/plugin/templater/extlib/fs.go delete mode 100644 pkg/document/plugin/templater/extlib/fs_test.go diff --git a/pkg/document/plugin/templater/extlib/fs.go b/pkg/document/plugin/templater/extlib/fs.go deleted file mode 100644 index e727c18e0..000000000 --- a/pkg/document/plugin/templater/extlib/fs.go +++ /dev/null @@ -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) -} diff --git a/pkg/document/plugin/templater/extlib/fs_test.go b/pkg/document/plugin/templater/extlib/fs_test.go deleted file mode 100644 index 55c76b72a..000000000 --- a/pkg/document/plugin/templater/extlib/fs_test.go +++ /dev/null @@ -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")) -} diff --git a/pkg/document/plugin/templater/extlib/funcmap.go b/pkg/document/plugin/templater/extlib/funcmap.go index 2de52ebea..c6b5d1474 100644 --- a/pkg/document/plugin/templater/extlib/funcmap.go +++ b/pkg/document/plugin/templater/extlib/funcmap.go @@ -32,7 +32,6 @@ var genericMap = map[string]interface{}{ "genCAWithKeyEx": generateCertificateAuthorityWithPEMKeyEx, "genSignedCertEx": generateSignedCertificateEx, "genSignedCertWithKeyEx": generateSignedCertificateWithPEMKeyEx, - "fileExists": fileExists, "regexGen": regexGen, "toYaml": toYaml, "toUint32": toUint32, diff --git a/pkg/document/plugin/templater/templater_test.go b/pkg/document/plugin/templater/templater_test.go index f8b478f4c..c19ec5c68 100644 --- a/pkg/document/plugin/templater/templater_test.go +++ b/pkg/document/plugin/templater/templater_test.go @@ -186,20 +186,6 @@ template: | "at : 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 {