genutils

package
v0.0.0-...-79dde53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// MergePatchStrategy is the name of the Merge patch strategy
	MergePatchStrategy = "merge"
	// ReplacePatchStrategy is the name of the Replace patch strategy
	ReplacePatchStrategy = "replace"
)

Variables

View Source
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

func ContainsPatchStrategy(field *markers.FieldInfo, strategy string) bool

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

func GetPatchMergeKey(field *markers.FieldInfo) string

GetPatchMergeKey reads the field tags to retrieve the patch merge key. It returns nil if no such key is defined

func LatestKubeLikeVersion

func LatestKubeLikeVersion(versions []string) string

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

func RegisterUnionMarkers(into *markers.Registry) error

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.

Types

type Visitor

type Visitor func(schema *apiext.JSONSchemaProps) (newVisitor Visitor, stop bool)

Visitor is the type of a function that visits one level of Json schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL