Documentation
¶
Index ¶
- Constants
- Variables
- func AddUnionOneOfConstraints(jsonSchema *apiext.JSONSchemaProps, unionDiscriminators []markers.FieldInfo, ...)
- func ContainsPatchStrategy(field *markers.FieldInfo, strategy string) bool
- func EditJSONSchema(jsonSchema *apiext.JSONSchemaProps, visitor Visitor)
- func GetPatchMergeKey(field *markers.FieldInfo) string
- func LatestKubeLikeVersion(versions []string) string
- func RegisterUnionMarkers(into *markers.Registry) error
- func SortKubeLikeVersion(versions []string)
- func WriteFormattedSourceFile(filename string, ctx *genall.GenerationContext, root *loader.Package, ...)
- type Visitor
Constants ¶
const ( // MergePatchStrategy is the name of the Merge patch strategy MergePatchStrategy = "merge" // ReplacePatchStrategy is the name of the Replace patch strategy ReplacePatchStrategy = "replace" )
Variables ¶
var ( // UnionMarker is the definition of the union marker, as defined in https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/20190325-unions.md#proposal UnionMarker = markers.Must(markers.MakeDefinition("union", markers.DescribesType, struct{}{})) // UnionDiscriminatorMarker is the definition of the union discriminator marker, as defined in https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/20190325-unions.md#proposal UnionDiscriminatorMarker = markers.Must(markers.MakeDefinition("unionDiscriminator", markers.DescribesField, struct{}{})) )
Functions ¶
func AddUnionOneOfConstraints ¶
func AddUnionOneOfConstraints(jsonSchema *apiext.JSONSchemaProps, unionDiscriminators []markers.FieldInfo, removeDiscriminators bool, fieldsToSkip ...string)
AddUnionOneOfConstraints adds oneOf constraints in the given Json schema for all the unions, based on the authorized values of the union members
func ContainsPatchStrategy ¶
ContainsPatchStrategy reads the field tags to check whether the given patch strategy is defined
func EditJSONSchema ¶
func EditJSONSchema(jsonSchema *apiext.JSONSchemaProps, visitor Visitor)
EditJSONSchema allows editing a Json Schema by applying the visitor function to each level of the schema.
func GetPatchMergeKey ¶
GetPatchMergeKey reads the field tags to retrieve the patch merge key. It returns nil if no such key is defined
func LatestKubeLikeVersion ¶
LatestKubeLikeVersion retrieves the latest version from the the provided versions, according to "kube-like" versioning order. "Kube-like" versions start with a "v", then are followed by a number (the major version), then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major version, then minor version. An example sorted list of versions: v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10.
func RegisterUnionMarkers ¶
RegisterUnionMarkers registers the `union` and `unionDiscriminator` markers
func SortKubeLikeVersion ¶
func SortKubeLikeVersion(versions []string)
SortKubeLikeVersion sorts the provided versions according to "kube-like" versioning order. "Kube-like" versions start with a "v", then are followed by a number (the major version), then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major version, then minor version. An example sorted list of versions: v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10.
func WriteFormattedSourceFile ¶
func WriteFormattedSourceFile(filename string, ctx *genall.GenerationContext, root *loader.Package, writeContents func(*bytes.Buffer))
WriteFormattedSourceFile creates a Go source file in a given package, dumps to it the content provided by the `writeContents` function and formats the result through go/fmt. If formatting cannot be applied (due to some syntax error probably), it returns an error.