spec

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package spec implements methods to parse and process the cluster spec, which is the main input to kubeformation. ClusterSpec is versioned. The version is identified by

version: v1

in the cluster spec. Each version has a corresponding handler, which implements the VersionedSpecHandler interface. Handler should implement the logic of parsing the cluster spec from a raw yaml byte array. It should also specify how the cluster spec converts to the Spec specific to each provider.

Each handler should also register here by invoking the Register function. Usually the invocation is present in the init section of handler. The handler should then be imported once in code:

import (
  _ "github.com/hasura/kubeformation/pkg/spec/v1"
)

Read method of this package can be called with raw yaml data for cluster spec. Version is read from the data and the corresponding handler will be returned, which can be used to generate the provider specific template.

When cluster spec changes in a way that breaks existing implementation, a new handler, say v2 should be created. This way, both v1 and v2 cluster spec can he handled by the same tool.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSpec = errors.New("kubeformation: unknown spec format")

ErrInvalidSpec is thrown when the spec is not in a readable format

View Source
var ErrInvalidSpecVersion = errors.New("kubeformation: invalid spec version")

ErrInvalidSpecVersion is thrown when spec with an unknown version is provided

View Source
var ErrVersionAlreadyRegistered = errors.New("kubeformation: version is already registered")

ErrVersionAlreadyRegistered is thrown when a version handler that is already registered tries to register again

Functions

func Register

func Register(version string, vsh VersionedSpecHandler) error

Register a version handler vsh that can handle a particular version of spec

Types

type VersionedSpec

type VersionedSpec struct {
	// Version of the given spec
	Version string `json:"version"`
}

VersionedSpec denotes the minimum required information to identify a spec version. Cluster Spec in read as this type first to infer the version and choose the correct handler.

type VersionedSpecHandler

type VersionedSpecHandler interface {
	// Read takes data and gives a VersionedSpecHandler
	Read(data []byte) (VersionedSpecHandler, error)

	// GetVersion returns the current handler version
	GetVersion() string

	// GenerateProviderTemplate returns a map of template files for
	// the given provider. If provider is not explicitly passed,
	// it is taken from the Spec.
	GenerateProviderTemplate(provider.ProviderType) (map[string][]byte, error)
}

VersionedSpecHandler is the interface every handler should implement.

func Read

func Read(data []byte) (VersionedSpecHandler, error)

Read a spec and return the corresponding version handler

Directories

Path Synopsis
Package v1 implements handler for Cluster Spec v1
Package v1 implements handler for Cluster Spec v1

Jump to

Keyboard shortcuts

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