Documentation ¶
Overview ¶
Package kubeversion contains a collection of helper methods that help to customize the code generated for ksonnet-lib to suit different Kubernetes versions.
For example, we may choose not to emit certain properties for some objects in Kubernetes v1.7.0; or, we might want to rename a property method. This package contains both the helper methods that perform such transformations, as well as the data for the transformations we use for each version.
Index ¶
- func Beta(k8sVersion string) bool
- func IsBlacklistedID(k8sVersion string, path kubespec.DefinitionName) bool
- func IsBlacklistedProperty(k8sVersion string, path kubespec.DefinitionName, ...) bool
- func KSource(k8sVersion string) string
- func MapIdentifier(k8sVersion, id string) string
- type CustomConstructorParam
- type CustomConstructorSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBlacklistedID ¶
func IsBlacklistedID(k8sVersion string, path kubespec.DefinitionName) bool
IsBlacklistedProperty taks a definition name (e.g., `io.k8s.kubernetes.pkg.apis.apps.v1beta1.Deployment`), a property name (e.g., `status`), and reports whether it is blacklisted for some Kubernetes version. This is particularly useful when deciding whether or not to generate mixins and property methods for a given property (as we likely wouldn't in the case of, say, `status`).
func IsBlacklistedProperty ¶
func IsBlacklistedProperty( k8sVersion string, path kubespec.DefinitionName, propertyName kubespec.PropertyName, ) bool
IsBlacklistedProperty taks a definition name (e.g., `io.k8s.kubernetes.pkg.apis.apps.v1beta1.Deployment`), a property name (e.g., `status`), and reports whether it is blacklisted for some Kubernetes version. This is particularly useful when deciding whether or not to generate mixins and property methods for a given property (as we likely wouldn't in the case of, say, `status`).
func MapIdentifier ¶
MapIdentifier takes a text identifier and maps it to a Jsonnet-appropriate identifier, for some version of Kubernetes. For example, in Kubernetes v1.7.0, we might map `clusterIP` -> `clusterIp`.
Types ¶
type CustomConstructorParam ¶
CustomConstructorParam specifies a parameter for a `CustomConstructorSpec`. This class allows users to specify constructors of various forms, including:
- The "normal" form, e.g., `foo(bar):: self.bar(bar)`,
- Parameters with default values, e.g., `foo(bar="baz"):: self.bar(bar)`, and
- Parameters that are nested inside the object, e.g., `foo(bar):: self.baz.bat.bar(bar)`
DESIGN NOTES:
- For constructors that use nested paths, we do not currently check that the path is valid. So for example, `self.baz.bat.bar` in the example above may not correspond to a real property. We make this decision because it complicates the code, and it doesn't seem worth it since this feature is used relatively rarely.
type CustomConstructorSpec ¶
type CustomConstructorSpec struct { ID string Params []CustomConstructorParam }
CustomConstructorSpec specifies a custom constructor for `ksonnet-gen` to emit as part of ksonnet-lib. In particular, this specifies a constructor of the form:
foo(bar, baz):: self.bar(bar) + self.baz(baz)
The parameter list and the body are all generated from the `Params` field.
DESIGN NOTES:
- If the user specifies a custom constructor, we will not emit the default zero-argument constructor, `new()`. This is a purposeful decision which we make because we are typically customizing the constructors precisely because the zero-argument constructor is not meaninful for a given API object.
- We currently do not check that parameter names are unique. Duplicate identifiers in a parameter list results in a Jsonnet compiler error, though, so this should be caught by review and CI, and it is hence not important for this case to be covered by this code.
func ConstructorSpec ¶
func ConstructorSpec( k8sVersion string, path kubespec.DefinitionName, ) ([]CustomConstructorSpec, bool)