doc.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright 2019 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 crd contains utilities for generating CustomResourceDefinitions and
  14. // their corresponding OpenAPI validation schemata.
  15. //
  16. // # Markers
  17. //
  18. // Markers live under the markers subpackage. Two types of markers exist:
  19. // those that modify schema generation (for validation), and those that modify
  20. // the rest of the CRD. See the subpackage for more information and all
  21. // supported markers.
  22. //
  23. // # Collecting Types and Generating CRDs
  24. //
  25. // The Parser is the entrypoint for collecting the information required to
  26. // generate CRDs. Like loader and collector, its methods are idemptotent, not
  27. // doing extra work if called multiple times.
  28. //
  29. // Parser's method start with Need. Calling NeedXYZ indicates that XYZ should
  30. // be made present in the eqivalent field in the Parser, where it can then be
  31. // loaded from. Each Need method will in turn call Need on anything it needs.
  32. //
  33. // In general, root packages should first be loaded into the Parser with
  34. // NeedPackage. Then, CRDs can be generated with NeedCRDFor.
  35. //
  36. // Errors are generally attached directly to the relevant Package with
  37. // AddError.
  38. //
  39. // # Known Packages
  40. //
  41. // There are a few types from Kubernetes that have special meaning, but don't
  42. // have validation markers attached. Those specific types have overrides
  43. // listed in KnownPackages that can be added as overrides to any parser.
  44. //
  45. // # Flattening
  46. //
  47. // Once schemata are generated, they can be used directly by external tooling
  48. // (like JSONSchema validators), but must first be "flattened" to not contain
  49. // references before use in a CRD (Kubernetes doesn't allow references in the
  50. // CRD's validation schema).
  51. //
  52. // The Flattener built in to the Parser takes care of flattening out references
  53. // when requesting the CRDs, but can be invoked manually. It will not modify
  54. // the input schemata.
  55. //
  56. // Flattened schemata may further be passed to FlattenEmbedded to remove the
  57. // use of AllOf (which is used to describe embedded struct fields when
  58. // references are in use). This done automatically when fetching CRDs.
  59. package crd