jsonnet

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package jsonnet contains a collection of simple rewriting facilities that allow us to easily map text from the OpenAPI spec to things that are Jsonnet-friendly (e.g., renaming identifiers that are Jsonnet keywords, lowerCamelCase'ing names, and so on).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldKey

type FieldKey string

FieldKey represents the literal text of a key for some JSON object field, after rewriting to avoid collisions with Jsonnet keywords. For example, for `{foo: ...}`, the `FieldKey` would be `foo`, while for `{error: ...}`, the `FieldKey` would be `"error"` (with quotation marks, to avoid collisions).

func RewriteAsFieldKey

func RewriteAsFieldKey(text kubespec.PropertyName) FieldKey

RewriteAsFieldKey takes a `PropertyName` and converts it to a valid Jsonnet field name. For example, if the `PropertyName` has a value of `"error"`, then this would generate an invalid object, `{error: ...}`. Hence, this function will quote this string, so that it ends up like: `{"error": ...}`.

type FuncParam

type FuncParam string

FuncParam represents the parameter to a Jsonnet function, after being rewritten to avoid collisions with Jsonnet keywords and normalized to fit the Jsonnet style (i.e., lowerCamelCase) using a manual set of custom transformations that change per Kubernetes version. For example, in `foo(BarAPI) {...}`, `FuncParam` would be `barApi`, and in `foo(error) {...}`, `FuncParam` would be `errorParam`.

func RewriteAsFuncParam

func RewriteAsFuncParam(
	k8sVersion string, text kubespec.PropertyName,
) FuncParam

RewriteAsFuncParam takes a `PropertyName` and converts it to a valid Jsonnet function parameter. For example, if the `PropertyName` has a value of `"error"`, then this would generate an invalid function parameter, `function(error) ...`. Hence, this function will alter the identifier, so that it ends up like: `function(errorParam) ...`.

NOTE: This transformation involves a hand-curated style change to lowerCamelCase (e.g., `fooAPI` -> `fooApi`). This list changes per Kubernetes version, according to identifiers that don't conform to this style.

type Identifier

type Identifier string

Identifier represents any identifier in a Jsonnet program, after being normalized to fit the Jsonnet style (i.e., lowerCamelCase) using a manual set of custom transformations that change per Kubernetes version. For example, `fooAPI` becomes `fooApi`.

func RewriteAsIdentifier

func RewriteAsIdentifier(
	k8sVersion string, rawID fmt.Stringer,
) Identifier

RewriteAsIdentifier takes a `GroupName`, `ObjectKind`, `PropertyName`, or `string`, and converts it to a Jsonnet-style Identifier. Typically this includes lower-casing the first letter, but also changing initialisms like fooAPI -> fooApi.

NOTE: This transformation involves a hand-curated style change to lowerCamelCase (e.g., `fooAPI` -> `fooApi`). This list changes per Kubernetes version, according to identifiers that don't conform to this style.

func (Identifier) ToMixinID

func (id Identifier) ToMixinID() Identifier

func (Identifier) ToSetterID

func (id Identifier) ToSetterID() Identifier

Jump to

Keyboard shortcuts

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