mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 18:10:59 +00:00
Delete kustomizationerror.
Do a longstanding TODO to remove kustomizationerror. It wasn't used much, and it wasn't used consistently, because it's complicated to decided when it's worth proceeding to accumulate errors when one already knows that one has a fatal error in the kustomization. Its use was blocking refactoring for simplicity and making tests harder to write. Removing it lets us reinstate the cyclomatic complexity check in KustTarget. Also added more info to the affected error messages.
This commit is contained in:
@@ -41,22 +41,18 @@ func (rmF *Factory) RF() *resource.Factory {
|
||||
return rmF.resF
|
||||
}
|
||||
|
||||
// FromFiles returns a ResMap given a resource path slice.
|
||||
func (rmF *Factory) FromFiles(
|
||||
loader ifc.Loader, paths []string) (ResMap, error) {
|
||||
var result []ResMap
|
||||
for _, path := range paths {
|
||||
content, err := loader.Load(path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Load from path "+path+" failed")
|
||||
}
|
||||
res, err := rmF.NewResMapFromBytes(content)
|
||||
if err != nil {
|
||||
return nil, internal.Handler(err, path)
|
||||
}
|
||||
result = append(result, res)
|
||||
// FromFile returns a ResMap given a resource path.
|
||||
func (rmF *Factory) FromFile(
|
||||
loader ifc.Loader, path string) (ResMap, error) {
|
||||
content, err := loader.Load(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return MergeWithErrorOnIdCollision(result...)
|
||||
res, err := rmF.NewResMapFromBytes(content)
|
||||
if err != nil {
|
||||
return nil, internal.Handler(err, path)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// newResMapFromBytes decodes a list of objects in byte array format.
|
||||
@@ -65,7 +61,6 @@ func (rmF *Factory) NewResMapFromBytes(b []byte) (ResMap, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := ResMap{}
|
||||
for _, res := range resources {
|
||||
id := res.Id()
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/pkg/types"
|
||||
)
|
||||
|
||||
func TestFromFiles(t *testing.T) {
|
||||
func TestFromFile(t *testing.T) {
|
||||
|
||||
resourceStr := `apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -85,12 +85,10 @@ metadata:
|
||||
}),
|
||||
}
|
||||
|
||||
m, _ := rmF.FromFiles(
|
||||
l, []string{"deployment.yaml"})
|
||||
m, _ := rmF.FromFile(l, "deployment.yaml")
|
||||
if len(m) != 3 {
|
||||
t.Fatalf("%#v should contain 3 appResource, but got %d", m, len(m))
|
||||
}
|
||||
|
||||
if err := expected.ErrorIfNotEqual(m); err != nil {
|
||||
t.Fatalf("actual doesn't match expected: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user