-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load built-in plugins for
kustomize localize
(#4869)
* Load and filter built-in plugins * Improve readability * Process plugins as resources instead of bytes * Throw error for validators * Differentiate generators, transformers processing * Enable validators * add wrapper error * improve documentation
- Loading branch information
1 parent
0eff094
commit 832b552
Showing
4 changed files
with
344 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022 The Kubernetes Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package localizer | ||
|
||
import ( | ||
"sigs.k8s.io/kustomize/kyaml/kio" | ||
"sigs.k8s.io/kustomize/kyaml/yaml" | ||
) | ||
|
||
// localizeBuiltinGenerators localizes built-in generators with file paths. | ||
// Note that this excludes helm, which needs a repo. | ||
type localizeBuiltinGenerators struct { | ||
} | ||
|
||
var _ kio.Filter = &localizeBuiltinGenerators{} | ||
|
||
// Filter localizes the built-in generators with file paths. Filter returns an error if | ||
// generators contains a resource that is not a built-in generator, cannot contain a file path, | ||
// needs more than a file path like helm, or is not localizable. | ||
// TODO(annasong): implement | ||
func (lbg *localizeBuiltinGenerators) Filter(generators []*yaml.RNode) ([]*yaml.RNode, error) { | ||
return generators, nil | ||
} | ||
|
||
// localizeBuiltinTransformers localizes built-in transformers with file paths. | ||
type localizeBuiltinTransformers struct { | ||
} | ||
|
||
var _ kio.Filter = &localizeBuiltinTransformers{} | ||
|
||
// Filter localizes the built-in transformers with file paths. Filter returns an error if | ||
// transformers contains a resource that is not a built-in transformer, cannot contain a file path, | ||
// or is not localizable. | ||
// TODO(annasong): implement | ||
func (lbt *localizeBuiltinTransformers) Filter(transformers []*yaml.RNode) ([]*yaml.RNode, error) { | ||
return transformers, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 The Kubernetes Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package localizer | ||
|
||
import "fmt" | ||
|
||
type ResourceLoadError struct { | ||
InlineError error | ||
FileError error | ||
} | ||
|
||
var _ error = ResourceLoadError{} | ||
|
||
func (rle ResourceLoadError) Error() string { | ||
return fmt.Sprintf(`when parsing as inline received error: %s | ||
when parsing as filepath received error: %s`, rle.InlineError, rle.FileError) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters