ifc.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Package ifc holds miscellaneous interfaces used by kustomize.
  14. package ifc
  15. import (
  16. "sigs.k8s.io/kustomize/pkg/gvk"
  17. "sigs.k8s.io/kustomize/pkg/types"
  18. )
  19. // Validator provides functions to validate annotations and labels
  20. type Validator interface {
  21. MakeAnnotationValidator() func(map[string]string) error
  22. MakeLabelValidator() func(map[string]string) error
  23. ValidateNamespace(string) []string
  24. }
  25. // Loader interface exposes methods to read bytes.
  26. type Loader interface {
  27. // Root returns the root location for this Loader.
  28. Root() string
  29. // New returns Loader located at newRoot.
  30. New(newRoot string) (Loader, error)
  31. // Load returns the bytes read from the location or an error.
  32. Load(location string) ([]byte, error)
  33. // Cleanup cleans the loader
  34. Cleanup() error
  35. }
  36. // Kunstructured allows manipulation of k8s objects
  37. // that do not have Golang structs.
  38. type Kunstructured interface {
  39. Map() map[string]interface{}
  40. SetMap(map[string]interface{})
  41. Copy() Kunstructured
  42. GetFieldValue(string) (string, error)
  43. MarshalJSON() ([]byte, error)
  44. UnmarshalJSON([]byte) error
  45. GetGvk() gvk.Gvk
  46. GetKind() string
  47. GetName() string
  48. SetName(string)
  49. GetLabels() map[string]string
  50. SetLabels(map[string]string)
  51. GetAnnotations() map[string]string
  52. SetAnnotations(map[string]string)
  53. }
  54. // KunstructuredFactory makes instances of Kunstructured.
  55. type KunstructuredFactory interface {
  56. SliceFromBytes([]byte) ([]Kunstructured, error)
  57. FromMap(m map[string]interface{}) Kunstructured
  58. MakeConfigMap(args *types.ConfigMapArgs, options *types.GeneratorOptions) (Kunstructured, error)
  59. MakeSecret(args *types.SecretArgs, options *types.GeneratorOptions) (Kunstructured, error)
  60. Set(ldr Loader)
  61. }
  62. // See core.v1.SecretTypeOpaque
  63. const SecretTypeOpaque = "Opaque"