Documentation ¶
Index ¶
- Constants
- Variables
- func AllInit(kubeConfigPath string, verbose bool, with []string) error
- func Banner()
- func BusyboxDeployment(name string) *v1.Deployment
- func Client() (*kubernetes.Clientset, error)
- func ClientFromFlags(apiUrl, kubeConfigPath string) (*kubernetes.Clientset, error)
- func ClientFromPath(kubeConfigPath string) (*kubernetes.Clientset, error)
- func Codify(input io.Reader, v *CodifyValues) ([]byte, error)
- func Install(app Deployable) error
- func List()
- func PrintJSON(app Deployable) error
- func PrintKubeYAML(app Deployable) error
- func PrintObjects(app Deployable)
- func ReaderToBytes(input io.Reader) ([]byte, error)
- func Register(app Deployable)
- func RegisterAndError(app Deployable) error
- func RegisterAndExit(app Deployable)
- func Registry() map[string]Deployable
- func RunCommandLine() error
- func RunCommandLineAndExit()
- func RunCommandLineWithOptions() error
- func RunOutput(appName string, o OutputEncoding) error
- func Src(path string) ([]byte, error)
- func TestClusterKubeConfigPath() string
- func TestClusterStart() error
- func TestClusterStop() error
- func Uninstall(app Deployable) error
- type AppMeta
- type CodifyObject
- type CodifyValues
- type Deployable
- type OutputEncoding
- type Program
- type Source
Constants ¶
const ( KubeconfigEnvironmentalVariable = "KUBECONFIG" KubeconfigDefaultDirectory = ".kube" KubeconfigDefaultFile = "config" )
const ( // TestClusterName is used to identify the test cluster with Kind. TestClusterName string = "namltestcluster" )
const ( // YAMLDelimiter is the official delimiter used to append multiple // YAML files together into the same file. // // Reference: https://yaml.org/spec/1.2/spec.html // YAMLDelimiter string = "\n---\n" )
Variables ¶
var ( //go:embed src/main.go.tpl FormatMainGo string //go:embed src/library.go.tpl FormatLibraryGo string )
var Version string = "1.0.1"
Version is this specific version on naml
Functions ¶
func AllInit ¶
AllInit is the "constructor" for every command line flag. This is how we use naml -w to include sub-namls
func BusyboxDeployment ¶
func BusyboxDeployment(name string) *v1.Deployment
BusyboxDeployment is useful for quick testing and debugging. This is broken by design.
func Client ¶
func Client() (*kubernetes.Clientset, error)
Client is used to authenticate with Kubernetes and build the Kube client for the rest of the program.
func ClientFromFlags ¶
func ClientFromFlags(apiUrl, kubeConfigPath string) (*kubernetes.Clientset, error)
ClientFromFlags will plumb well-known command line flags through to the kubeconfig
func ClientFromPath ¶
func ClientFromPath(kubeConfigPath string) (*kubernetes.Clientset, error)
ClientFromPath is used to authenticate with Kubernetes and build the Kube client for the rest of the program given a specific kube config path.
Useful for testing.
func Codify ¶ added in v0.2.6
func Codify(input io.Reader, v *CodifyValues) ([]byte, error)
Codify will take any valid Kubernetes YAML as an io.Reader and do it's best to return a syntactically correct Go program that is NAML compliant.
The NAML codebase is Apache 2.0 licensed, so we assume that any calling code will adopt the same Apache license.
func Install ¶
func Install(app Deployable) error
Install is used to install an application in Kubernetes
func PrintJSON ¶ added in v0.3.0
func PrintJSON(app Deployable) error
func PrintKubeYAML ¶ added in v0.3.0
func PrintKubeYAML(app Deployable) error
func PrintObjects ¶ added in v0.2.9
func PrintObjects(app Deployable)
func ReaderToBytes ¶ added in v0.2.7
ReaderToBytes is basically a wrapper for ReadAll, however we add in some specific error language for stdin.
func RegisterAndError ¶
func RegisterAndError(app Deployable) error
func RegisterAndExit ¶
func RegisterAndExit(app Deployable)
RegisterAndExit will register the app or exit with an error message in stdout
func RunCommandLine ¶
func RunCommandLine() error
RunCommandLine is the global NAML command line program.
Use this if you would like to use the built in NAML command line interface.
func RunCommandLineAndExit ¶
func RunCommandLineAndExit()
func RunCommandLineWithOptions ¶
func RunCommandLineWithOptions() error
RunCommandLineWithOptions is here so we can default values in RunCommandLine() that we would want to pass in here later (tests, etc)
func RunOutput ¶ added in v0.2.7
func RunOutput(appName string, o OutputEncoding) error
func TestClusterKubeConfigPath ¶
func TestClusterKubeConfigPath() string
TestClusterKubeConfigPath will export the kubeconfig path to this directory to use for the client in the tests.
func TestClusterStart ¶
func TestClusterStart() error
TestClusterStart can be used to start the test cluster in the TestMain() function.
func TestClusterStop ¶
func TestClusterStop() error
TestClusterStop can be used to stop the test cluster in the TestMain() function.
func Uninstall ¶
func Uninstall(app Deployable) error
Uninstall is used to uninstall an application in Kubernetes
Types ¶
type AppMeta ¶ added in v0.4.0
type AppMeta struct { Description string metav1.ObjectMeta }
type CodifyObject ¶ added in v0.2.6
type CodifyObject interface { // Install returns the snippet of code that would // traditionally live inside a function. This // will define literally (what it can) a struct // for the object, and pass it to the corresponding // kubernetes library. Install() (string, []string) // Uninstall is the reverse library call of install. Uninstall() string }
func ReaderToCodifyObjects ¶ added in v0.2.7
func ReaderToCodifyObjects(input io.Reader) ([]CodifyObject, int, error)
ReaderToCodifyObjects will convert an io.Reader to naml compatible Go objects.
This function works by doing the best it can, and will return as many CodifyObjects as possible. The function will return a positive integer for every YAML object it detects, that it is unable to Codify. If the delta is greater than 0, that means we have encountered a loss.
type CodifyValues ¶ added in v0.4.0
type CodifyValues struct { LibraryMode bool AuthorName string AuthorEmail string CopyrightYear string AppNameTitle string AppNameLower string Description string Version string Install string Uninstall string Packages string PackageName string }
CodifyValues are ultimately what is rendered into the .naml files in /src. These values are what will be created in the output.
type Deployable ¶
type Deployable interface { // Install will attempt to install in Kubernetes Install(client kubernetes.Interface) error // Uninstall will attempt to uninstall in Kubernetes Uninstall(client kubernetes.Interface) error // Meta returns a NAML Meta structure which embed Kubernetes *metav1.ObjectMeta Meta() *AppMeta // Objects will return the runtime objects defined for each application Objects() []runtime.Object }
Deployable is an interface that can be implemented for deployable applications.
type OutputEncoding ¶ added in v0.2.7
type OutputEncoding int
const ( OutputYAML OutputEncoding = 0 OutputJSON OutputEncoding = 1 )