Add/fix some documentation and vars names.

This commit is contained in:
Jeffrey Regan
2018-11-07 12:32:49 -08:00
parent ba953484bf
commit d05bb6b199
6 changed files with 68 additions and 53 deletions

View File

@@ -30,21 +30,21 @@ import (
"sigs.k8s.io/kustomize/pkg/types"
)
// KunstructurerFactoryImpl hides construction using apimachinery types.
type KunstructurerFactoryImpl struct {
cmfactory *configmapandsecret.ConfigMapFactory
secfactory *configmapandsecret.SecretFactory
// KunstructuredFactoryImpl hides construction using apimachinery types.
type KunstructuredFactoryImpl struct {
cmFactory *configmapandsecret.ConfigMapFactory
secretFactory *configmapandsecret.SecretFactory
}
var _ ifc.KunstructuredFactory = &KunstructurerFactoryImpl{}
var _ ifc.KunstructuredFactory = &KunstructuredFactoryImpl{}
// NewKunstructuredFactoryImpl returns a factory.
func NewKunstructuredFactoryImpl() ifc.KunstructuredFactory {
return &KunstructurerFactoryImpl{}
return &KunstructuredFactoryImpl{}
}
// SliceFromBytes returns a slice of Kunstructured.
func (kf *KunstructurerFactoryImpl) SliceFromBytes(
func (kf *KunstructuredFactoryImpl) SliceFromBytes(
in []byte) ([]ifc.Kunstructured, error) {
decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(in), 1024)
var result []ifc.Kunstructured
@@ -71,14 +71,14 @@ func isEmptyYamlError(err error) bool {
}
// FromMap returns an instance of Kunstructured.
func (kf *KunstructurerFactoryImpl) FromMap(
func (kf *KunstructuredFactoryImpl) FromMap(
m map[string]interface{}) ifc.Kunstructured {
return &UnstructAdapter{Unstructured: unstructured.Unstructured{Object: m}}
}
// MakeConfigMap returns an instance of Kunstructured for ConfigMap
func (kf *KunstructurerFactoryImpl) MakeConfigMap(args *types.ConfigMapArgs, options *types.GeneratorOptions) (ifc.Kunstructured, error) {
cm, err := kf.cmfactory.MakeConfigMap(args, options)
func (kf *KunstructuredFactoryImpl) MakeConfigMap(args *types.ConfigMapArgs, options *types.GeneratorOptions) (ifc.Kunstructured, error) {
cm, err := kf.cmFactory.MakeConfigMap(args, options)
if err != nil {
return nil, err
}
@@ -86,8 +86,8 @@ func (kf *KunstructurerFactoryImpl) MakeConfigMap(args *types.ConfigMapArgs, opt
}
// MakeSecret returns an instance of Kunstructured for Secret
func (kf *KunstructurerFactoryImpl) MakeSecret(args *types.SecretArgs, options *types.GeneratorOptions) (ifc.Kunstructured, error) {
sec, err := kf.secfactory.MakeSecret(args, options)
func (kf *KunstructuredFactoryImpl) MakeSecret(args *types.SecretArgs, options *types.GeneratorOptions) (ifc.Kunstructured, error) {
sec, err := kf.secretFactory.MakeSecret(args, options)
if err != nil {
return nil, err
}
@@ -95,13 +95,13 @@ func (kf *KunstructurerFactoryImpl) MakeSecret(args *types.SecretArgs, options *
}
// Set sets loader, filesystem and workdirectory
func (kf *KunstructurerFactoryImpl) Set(fs fs.FileSystem, ldr ifc.Loader) {
kf.cmfactory = configmapandsecret.NewConfigMapFactory(fs, ldr)
kf.secfactory = configmapandsecret.NewSecretFactory(fs, ldr.Root())
func (kf *KunstructuredFactoryImpl) Set(fs fs.FileSystem, ldr ifc.Loader) {
kf.cmFactory = configmapandsecret.NewConfigMapFactory(fs, ldr)
kf.secretFactory = configmapandsecret.NewSecretFactory(fs, ldr.Root())
}
// validate validates that u has kind and name
func (kf *KunstructurerFactoryImpl) validate(u unstructured.Unstructured) error {
func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error {
if u.GetName() == "" {
return fmt.Errorf("Missing metadata.name in object %v", u)
}