mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Use DepProvider in tests to access kyaml impls.
This commit is contained in:
@@ -8,17 +8,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
resmaptest_test "sigs.k8s.io/kustomize/api/testutils/resmaptest"
|
||||
)
|
||||
|
||||
func TestNameReferenceHappyRun(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).AddWithName(
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).AddWithName(
|
||||
"cm1",
|
||||
map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
@@ -261,7 +258,8 @@ func TestNameReferenceHappyRun(t *testing.T) {
|
||||
},
|
||||
}).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).ReplaceResource(
|
||||
expected := resmaptest_test.NewSeededRmBuilderDefault(
|
||||
t, m.ShallowCopy()).ReplaceResource(
|
||||
map[string]interface{}{
|
||||
"group": "apps",
|
||||
"apiVersion": "v1",
|
||||
@@ -475,14 +473,12 @@ func TestNameReferenceHappyRun(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
tests := []struct {
|
||||
resMap resmap.ResMap
|
||||
expectedErr string
|
||||
}{
|
||||
{
|
||||
resMap: resmaptest_test.NewRmBuilder(t, rf).Add(
|
||||
resMap: resmaptest_test.NewRmBuilderDefault(t).Add(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "rbac.authorization.k8s.io/v1",
|
||||
"kind": "ClusterRole",
|
||||
@@ -502,7 +498,7 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
}).ResMap(),
|
||||
expectedErr: "is expected to be"},
|
||||
{
|
||||
resMap: resmaptest_test.NewRmBuilder(t, rf).Add(
|
||||
resMap: resmaptest_test.NewRmBuilderDefault(t).Add(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "rbac.authorization.k8s.io/v1",
|
||||
"kind": "ClusterRole",
|
||||
@@ -538,8 +534,7 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNameReferencePersistentVolumeHappyRun(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
rf := provider.NewDefaultDepProvider().GetResourceFactory()
|
||||
|
||||
v1 := rf.FromMapWithName(
|
||||
"volume1",
|
||||
@@ -664,9 +659,7 @@ const (
|
||||
// object with the same original names (uniquename) in different namespaces
|
||||
// and with different current Id.
|
||||
func TestNameReferenceNamespace(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).
|
||||
// Add ConfigMap with the same org name in noNs, "ns1" and "ns2" namespaces
|
||||
AddWithName(orgname, map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
@@ -715,7 +708,7 @@ func TestNameReferenceNamespace(t *testing.T) {
|
||||
AddWithNsAndName(ns1, orgname, deploymentMap(ns1, prefixedname, orgname, orgname)).
|
||||
AddWithNsAndName(ns2, orgname, deploymentMap(ns2, suffixedname, orgname, orgname)).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
expected := resmaptest_test.NewSeededRmBuilderDefault(t, m.ShallowCopy()).
|
||||
ReplaceResource(deploymentMap(defaultNs, modifiedname, modifiedname, modifiedname)).
|
||||
ReplaceResource(deploymentMap(ns1, prefixedname, prefixedname, prefixedname)).
|
||||
ReplaceResource(deploymentMap(ns2, suffixedname, suffixedname, suffixedname)).ResMap()
|
||||
@@ -735,9 +728,7 @@ func TestNameReferenceNamespace(t *testing.T) {
|
||||
// object with the same original names (uniquename) in different namespaces
|
||||
// and with different current Id.
|
||||
func TestNameReferenceClusterWide(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).
|
||||
// Add ServiceAccount with the same org name in noNs, "ns1" and "ns2" namespaces
|
||||
AddWithName(orgname, map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
@@ -816,7 +807,7 @@ func TestNameReferenceClusterWide(t *testing.T) {
|
||||
},
|
||||
}}).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
expected := resmaptest_test.NewSeededRmBuilderDefault(t, m.ShallowCopy()).
|
||||
ReplaceResource(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "rbac.authorization.k8s.io/v1",
|
||||
@@ -898,9 +889,7 @@ func TestNameReferenceClusterWide(t *testing.T) {
|
||||
// object with the same original names (uniquename) in different namespaces
|
||||
// and with different current Id.
|
||||
func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).
|
||||
AddWithNsAndName(ns4, orgname, map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Secret",
|
||||
@@ -964,7 +953,7 @@ func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
},
|
||||
}}).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
expected := resmaptest_test.NewSeededRmBuilderDefault(t, m.ShallowCopy()).
|
||||
ReplaceResource(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "rbac.authorization.k8s.io/v1",
|
||||
@@ -1026,9 +1015,7 @@ func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
// It validates the change done is IsSameFuzzyNamespace which
|
||||
// uses the IsNsEquals method instead of the simple == operator.
|
||||
func TestNameReferenceCandidateSelection(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).
|
||||
AddWithName("cm1", map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
@@ -1045,7 +1032,7 @@ func TestNameReferenceCandidateSelection(t *testing.T) {
|
||||
AddWithName("deploy1", deploymentMap("", "p1-deploy1", "cm1", "secret1")).
|
||||
ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
expected := resmaptest_test.NewSeededRmBuilderDefault(t, m.ShallowCopy()).
|
||||
ReplaceResource(deploymentMap("", "p1-deploy1", "p1-cm1-hash", "p1-secret1-hash")).
|
||||
ResMap()
|
||||
|
||||
|
||||
@@ -7,10 +7,8 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
resmaptest_test "sigs.k8s.io/kustomize/api/testutils/resmaptest"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
@@ -46,8 +44,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
{Gvk: resid.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/interface"},
|
||||
{Gvk: resid.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/num"},
|
||||
},
|
||||
res: resmaptest_test.NewRmBuilder(
|
||||
t, resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())).
|
||||
res: resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
@@ -77,8 +74,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
}}).ResMap(),
|
||||
},
|
||||
expected: expected{
|
||||
res: resmaptest_test.NewRmBuilder(
|
||||
t, resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())).
|
||||
res: resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
@@ -116,8 +112,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
fs: []types.FieldSpec{
|
||||
{Gvk: resid.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/slice"},
|
||||
},
|
||||
res: resmaptest_test.NewRmBuilder(
|
||||
t, resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())).
|
||||
res: resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
@@ -138,8 +133,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
fs: []types.FieldSpec{
|
||||
{Gvk: resid.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/nil"},
|
||||
},
|
||||
res: resmaptest_test.NewRmBuilder(
|
||||
t, resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())).
|
||||
res: resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
@@ -151,8 +145,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
}}).ResMap(),
|
||||
},
|
||||
expected: expected{
|
||||
res: resmaptest_test.NewRmBuilder(
|
||||
t, resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())).
|
||||
res: resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
. "sigs.k8s.io/kustomize/api/internal/accumulator"
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
@@ -20,16 +20,14 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
func makeResAccumulator(t *testing.T) (*ResAccumulator, *resource.Factory) {
|
||||
func makeResAccumulator(t *testing.T) *ResAccumulator {
|
||||
ra := MakeEmptyAccumulator()
|
||||
err := ra.MergeConfig(builtinconfig.MakeDefaultConfig())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
err = ra.AppendAll(
|
||||
resmaptest_test.NewRmBuilder(t, rf).
|
||||
resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
@@ -66,11 +64,11 @@ func makeResAccumulator(t *testing.T) (*ResAccumulator, *resource.Factory) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
return ra, rf
|
||||
return ra
|
||||
}
|
||||
|
||||
func TestResolveVarsHappy(t *testing.T) {
|
||||
ra, _ := makeResAccumulator(t)
|
||||
ra := makeResAccumulator(t)
|
||||
err := ra.MergeVars([]types.Var{
|
||||
{
|
||||
Name: "SERVICE_ONE",
|
||||
@@ -99,7 +97,7 @@ func TestResolveVarsHappy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveVarsOneUnused(t *testing.T) {
|
||||
ra, _ := makeResAccumulator(t)
|
||||
ra := makeResAccumulator(t)
|
||||
err := ra.MergeVars([]types.Var{
|
||||
{
|
||||
Name: "SERVICE_ONE",
|
||||
@@ -140,11 +138,10 @@ func expectLog(t *testing.T, log bytes.Buffer, expect string) {
|
||||
}
|
||||
|
||||
func TestResolveVarsVarNeedsDisambiguation(t *testing.T) {
|
||||
ra, rf := makeResAccumulator(t)
|
||||
|
||||
ra := makeResAccumulator(t)
|
||||
rm0 := resmap.New()
|
||||
err := rm0.Append(
|
||||
rf.FromMap(
|
||||
provider.NewDefaultDepProvider().GetResourceFactory().FromMap(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Service",
|
||||
@@ -213,8 +210,7 @@ func makeVarToNamepaceAndPath(
|
||||
}
|
||||
|
||||
func TestResolveVarConflicts(t *testing.T) {
|
||||
rf := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
|
||||
|
||||
rf := provider.NewDefaultDepProvider().GetResourceFactory()
|
||||
// create configmaps in foo and bar namespaces with `data.provider` values.
|
||||
fooAws := makeNamespacedConfigMapWithDataProviderValue("foo", "aws")
|
||||
barAws := makeNamespacedConfigMapWithDataProviderValue("bar", "aws")
|
||||
@@ -261,7 +257,7 @@ func TestResolveVarConflicts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveVarsGoodResIdBadField(t *testing.T) {
|
||||
ra, _ := makeResAccumulator(t)
|
||||
ra := makeResAccumulator(t)
|
||||
err := ra.MergeVars([]types.Var{
|
||||
{
|
||||
Name: "SERVICE_ONE",
|
||||
@@ -286,7 +282,7 @@ func TestResolveVarsGoodResIdBadField(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveVarsUnmappableVar(t *testing.T) {
|
||||
ra, _ := makeResAccumulator(t)
|
||||
ra := makeResAccumulator(t)
|
||||
err := ra.MergeVars([]types.Var{
|
||||
{
|
||||
Name: "SERVICE_THREE",
|
||||
@@ -310,7 +306,7 @@ func TestResolveVarsUnmappableVar(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveVarsWithNoambiguation(t *testing.T) {
|
||||
ra1, rf := makeResAccumulator(t)
|
||||
ra1 := makeResAccumulator(t)
|
||||
err := ra1.MergeVars([]types.Var{
|
||||
{
|
||||
Name: "SERVICE_ONE",
|
||||
@@ -327,7 +323,7 @@ func TestResolveVarsWithNoambiguation(t *testing.T) {
|
||||
// Create another accumulator having a resource with different prefix
|
||||
ra2 := MakeEmptyAccumulator()
|
||||
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
m := resmaptest_test.NewRmBuilderDefault(t).
|
||||
Add(map[string]interface{}{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
|
||||
@@ -7,14 +7,13 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
var fileReader = kunstruct.NewKunstructuredFactoryImpl()
|
||||
|
||||
// This document is meant to be used at the elasticsearch document type.
|
||||
// Fields are serialized as-is to elasticsearch, where indices are built
|
||||
// to facilitate text search queries. Identifiers, Values, FilePath,
|
||||
@@ -42,6 +41,7 @@ type KustomizationDocument struct {
|
||||
Kinds []string `json:"kinds,omitempty"`
|
||||
Identifiers []string `json:"identifiers,omitempty"`
|
||||
Values []string `json:"values,omitempty"`
|
||||
resFactory *resource.Factory
|
||||
}
|
||||
|
||||
type set map[string]struct{}
|
||||
@@ -52,6 +52,7 @@ func (doc *KustomizationDocument) Copy() *KustomizationDocument {
|
||||
Kinds: doc.Kinds,
|
||||
Identifiers: doc.Identifiers,
|
||||
Values: doc.Values,
|
||||
resFactory: provider.NewDefaultDepProvider().GetResourceFactory(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ func (doc *KustomizationDocument) readBytes() ([]map[string]interface{}, error)
|
||||
}
|
||||
|
||||
configs := make([]map[string]interface{}, 0)
|
||||
ks, err := fileReader.SliceFromBytes(data)
|
||||
ks, err := doc.resFactory.SliceFromBytes(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse resource: %v", err)
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ import (
|
||||
. "sigs.k8s.io/kustomize/api/internal/plugins/execplugin"
|
||||
pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/utils"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
fLdr "sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
||||
)
|
||||
|
||||
func TestExecPluginConfig(t *testing.T) {
|
||||
@@ -33,10 +31,8 @@ s/$BAR/bar baz/g
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rf := resmap.NewFactory(
|
||||
resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl()), nil)
|
||||
v := valtest_test.MakeFakeValidator()
|
||||
pvd := provider.NewDefaultDepProvider()
|
||||
rf := resmap.NewFactory(pvd.GetResourceFactory(), pvd.GetMerginator())
|
||||
pluginConfig := rf.RF().FromMap(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "someteam.example.com/v1",
|
||||
@@ -62,7 +58,7 @@ s/$BAR/bar baz/g
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
p.Config(resmap.NewPluginHelpers(ldr, v, rf), yaml)
|
||||
p.Config(resmap.NewPluginHelpers(ldr, pvd.GetFieldValidator(), rf), yaml)
|
||||
|
||||
expected := "someteam.example.com/v1/sedtransformer/SedTransformer"
|
||||
if !strings.HasSuffix(p.Path(), expected) {
|
||||
|
||||
@@ -8,11 +8,10 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
. "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
@@ -51,8 +50,8 @@ func TestLoader(t *testing.T) {
|
||||
BuildGoPlugin("builtin", "", "SecretGenerator").
|
||||
BuildGoPlugin("someteam.example.com", "v1", "SomeServiceGenerator")
|
||||
defer th.Reset()
|
||||
rmF := resmap.NewFactory(resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl()), nil)
|
||||
p := provider.NewDefaultDepProvider()
|
||||
rmF := resmap.NewFactory(p.GetResourceFactory(), p.GetMerginator())
|
||||
fLdr, err := loader.NewLoader(
|
||||
loader.RestrictionRootOnly,
|
||||
filesys.Separator, filesys.MakeFsInMemory())
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
@@ -64,7 +64,7 @@ func strptr(s string) *string {
|
||||
}
|
||||
|
||||
func TestUpdateResourceOptions(t *testing.T) {
|
||||
rf := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
|
||||
rf := provider.NewDefaultDepProvider().GetResourceFactory()
|
||||
in := resmap.New()
|
||||
expected := resmap.New()
|
||||
cases := []struct {
|
||||
@@ -108,7 +108,7 @@ func TestUpdateResourceOptions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateResourceOptionsWithInvalidHashAnnotationValues(t *testing.T) {
|
||||
rf := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
|
||||
rf := provider.NewDefaultDepProvider().GetResourceFactory()
|
||||
cases := []string{
|
||||
"",
|
||||
"FaLsE",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
@@ -76,8 +76,7 @@ commonLabels:
|
||||
}
|
||||
|
||||
kt := makeKustTargetWithRf(
|
||||
t, th.GetFSys(), "/",
|
||||
resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()))
|
||||
t, th.GetFSys(), "/", provider.NewDefaultDepProvider())
|
||||
for tn, tc := range testCases {
|
||||
t.Run(tn, func(t *testing.T) {
|
||||
th.WriteK("/", tc.content)
|
||||
@@ -148,7 +147,8 @@ metadata:
|
||||
{"op": "add", "path": "/spec/replica", "value": "3"}
|
||||
]`)
|
||||
|
||||
resFactory := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
|
||||
pvd := provider.NewDefaultDepProvider()
|
||||
resFactory := pvd.GetResourceFactory()
|
||||
|
||||
resources := []*resource.Resource{
|
||||
resFactory.FromMapWithName("dply1", map[string]interface{}{
|
||||
@@ -244,8 +244,7 @@ metadata:
|
||||
}
|
||||
}
|
||||
|
||||
kt := makeKustTargetWithRf(
|
||||
t, th.GetFSys(), "/whatever", resFactory)
|
||||
kt := makeKustTargetWithRf(t, th.GetFSys(), "/whatever", pvd)
|
||||
err := kt.Load()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected Resources error %v", err)
|
||||
|
||||
@@ -7,14 +7,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/internal/k8sdeps/merge"
|
||||
pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/internal/target"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
fLdr "sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
||||
)
|
||||
|
||||
@@ -22,9 +20,7 @@ func makeAndLoadKustTarget(
|
||||
t *testing.T,
|
||||
fSys filesys.FileSystem,
|
||||
root string) *target.KustTarget {
|
||||
kt := makeKustTargetWithRf(
|
||||
t, fSys, root,
|
||||
resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()))
|
||||
kt := makeKustTargetWithRf(t, fSys, root, provider.NewDefaultDepProvider())
|
||||
if err := kt.Load(); err != nil {
|
||||
t.Fatalf("Unexpected load error %v", err)
|
||||
}
|
||||
@@ -35,13 +31,12 @@ func makeKustTargetWithRf(
|
||||
t *testing.T,
|
||||
fSys filesys.FileSystem,
|
||||
root string,
|
||||
resourceFactory *resource.Factory) *target.KustTarget {
|
||||
pvd *provider.DepProvider) *target.KustTarget {
|
||||
ldr, err := fLdr.NewLoader(fLdr.RestrictionRootOnly, root, fSys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rf := resmap.NewFactory(
|
||||
resourceFactory, merge.NewMerginator(resourceFactory))
|
||||
rf := resmap.NewFactory(pvd.GetResourceFactory(), pvd.GetMerginator())
|
||||
pc := konfig.DisabledPluginConfig()
|
||||
return target.NewKustTarget(
|
||||
ldr,
|
||||
|
||||
Reference in New Issue
Block a user