diff --git a/k8sdeps/configmapandsecret/configmapfactory.go b/k8sdeps/configmapandsecret/configmapfactory.go index fc9a30da8..7dabad4b5 100644 --- a/k8sdeps/configmapandsecret/configmapfactory.go +++ b/k8sdeps/configmapandsecret/configmapfactory.go @@ -26,8 +26,8 @@ import ( "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/validation" + "sigs.k8s.io/kustomize/k8sdeps/kv" "sigs.k8s.io/kustomize/pkg/ifc" - "sigs.k8s.io/kustomize/pkg/kv" "sigs.k8s.io/kustomize/pkg/types" ) diff --git a/k8sdeps/configmapandsecret/kv.go b/k8sdeps/configmapandsecret/kv.go index 8ba1e5f4a..1ad4264e7 100644 --- a/k8sdeps/configmapandsecret/kv.go +++ b/k8sdeps/configmapandsecret/kv.go @@ -22,8 +22,8 @@ import ( "strings" "github.com/pkg/errors" + "sigs.k8s.io/kustomize/k8sdeps/kv" "sigs.k8s.io/kustomize/pkg/ifc" - "sigs.k8s.io/kustomize/pkg/kv" ) func keyValuesFromLiteralSources(sources []string) ([]kv.KVPair, error) { diff --git a/k8sdeps/configmapandsecret/kv_test.go b/k8sdeps/configmapandsecret/kv_test.go new file mode 100644 index 000000000..0b7fe5c37 --- /dev/null +++ b/k8sdeps/configmapandsecret/kv_test.go @@ -0,0 +1,57 @@ +/* +Copyright 2019 The Kubernetes Authors. + +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 + + http://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 configmapandsecret + +import ( + "reflect" + "testing" + + "sigs.k8s.io/kustomize/k8sdeps/kv" + "sigs.k8s.io/kustomize/pkg/fs" + "sigs.k8s.io/kustomize/pkg/loader" +) + +func TestKeyValuesFromFileSources(t *testing.T) { + tests := []struct { + description string + sources []string + expected []kv.KVPair + }{ + { + description: "create kvs from file sources", + sources: []string{"files/app-init.ini"}, + expected: []kv.KVPair{ + { + Key: "app-init.ini", + Value: "FOO=bar", + }, + }, + }, + } + + fSys := fs.MakeFakeFS() + fSys.WriteFile("/files/app-init.ini", []byte("FOO=bar")) + for _, tc := range tests { + kvs, err := keyValuesFromFileSources(loader.NewFileLoaderAtRoot(fSys), tc.sources) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if !reflect.DeepEqual(kvs, tc.expected) { + t.Fatalf("in testcase: %q updated:\n%#v\ndoesn't match expected:\n%#v\n", tc.description, kvs, tc.expected) + } + } +} diff --git a/k8sdeps/configmapandsecret/secretfactory.go b/k8sdeps/configmapandsecret/secretfactory.go index e3a95f329..cc5d68b42 100644 --- a/k8sdeps/configmapandsecret/secretfactory.go +++ b/k8sdeps/configmapandsecret/secretfactory.go @@ -23,8 +23,8 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/validation" + "sigs.k8s.io/kustomize/k8sdeps/kv" "sigs.k8s.io/kustomize/pkg/ifc" - "sigs.k8s.io/kustomize/pkg/kv" "sigs.k8s.io/kustomize/pkg/types" ) diff --git a/pkg/kv/kv.go b/k8sdeps/kv/kv.go similarity index 100% rename from pkg/kv/kv.go rename to k8sdeps/kv/kv.go diff --git a/pkg/kv/kv_test.go b/k8sdeps/kv/kv_test.go similarity index 100% rename from pkg/kv/kv_test.go rename to k8sdeps/kv/kv_test.go