app

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EnvironmentDirName is the directory name for environments.
	EnvironmentDirName = "environments"

	// LibDirName is the directory name for libraries.
	LibDirName = "lib"
)
View Source
const (
	// DefaultAPIVersion is the default ks API version to use if not specified.
	DefaultAPIVersion = "0.1.0"
	// Kind is the schema resource type.
	Kind = "ksonnet.io/app"
	// DefaultVersion is the default version of the app schema.
	DefaultVersion = "0.0.1"
)

Variables

View Source
var (
	// DefaultFilePermissions are the default permissions for a file.
	DefaultFilePermissions = os.FileMode(0644)
	// DefaultFolderPermissions are the default permissions for a folder.
	DefaultFolderPermissions = os.FileMode(0755)

	// LibUpdater updates ksonnet lib versions.
	LibUpdater = updateLibData
)
View Source
var (
	// ErrRegistryNameInvalid is the error where a registry name is invalid.
	ErrRegistryNameInvalid = fmt.Errorf("Registry name is invalid")
	// ErrRegistryExists is the error when trying to create a registry that already exists.
	ErrRegistryExists = fmt.Errorf("Registry with name already exists")
	// ErrEnvironmentNameInvalid is the error where an environment name is invalid.
	ErrEnvironmentNameInvalid = fmt.Errorf("Environment name is invalid")
	// ErrEnvironmentExists is the error when trying to create an environment that already exists.
	ErrEnvironmentExists = fmt.Errorf("Environment with name already exists")
	// ErrEnvironmentNotExists is the error when trying to update an environment that doesn't exist.
	ErrEnvironmentNotExists = fmt.Errorf("Environment with name doesn't exist")
)

Functions

func StubUpdateLibData added in v0.9.0

func StubUpdateLibData(fs afero.Fs, k8sSpecFlag, libPath string, useVersionPath bool) (string, error)

StubUpdateLibData always returns no error.

func Write added in v0.9.0

func Write(fs afero.Fs, appRoot string, spec *Spec) error

Write writes the provided spec to file system.

Types

type App added in v0.9.0

type App interface {
	AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec) error
	Environment(name string) (*EnvironmentSpec, error)
	Environments() (EnvironmentSpecs, error)
	Libraries() LibraryRefSpecs
	LibPath(envName string) (string, error)
	Init() error
	Registries() RegistryRefSpecs
	RenameEnvironment(from, to string) error
	RemoveEnvironment(name string) error
	Upgrade(dryRun bool) error
}

App is a ksonnet application.

func Load added in v0.9.0

func Load(fs afero.Fs, appRoot string) (App, error)

Load loads the application configuration.

type App001 added in v0.9.0

type App001 struct {
	// contains filtered or unexported fields
}

App001 is a ksonnet 0.0.1 application.

func NewApp001 added in v0.9.0

func NewApp001(fs afero.Fs, root string) (*App001, error)

NewApp001 creates an App001 instance.

func (*App001) AddEnvironment added in v0.9.0

func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec) error

AddEnvironment adds an environment spec to the app spec. If the spec already exists, it is overwritten.

func (*App001) Environment added in v0.9.0

func (a *App001) Environment(name string) (*EnvironmentSpec, error)

Environment returns the spec for an environment. In 0.1.0, the file lives in /environments/name/spec.json.

func (*App001) Environments added in v0.9.0

func (a *App001) Environments() (EnvironmentSpecs, error)

Environments returns specs for all environments. In 0.1.0, the environment spec lives in spec.json files.

func (*App001) Init added in v0.9.0

func (a *App001) Init() error

Init initializes the App.

func (*App001) LibPath added in v0.9.0

func (a *App001) LibPath(envName string) (string, error)

LibPath returns the lib path for an env environment.

func (*App001) Libraries added in v0.9.0

func (a *App001) Libraries() LibraryRefSpecs

Libraries returns application libraries.

func (*App001) Registries added in v0.9.0

func (a *App001) Registries() RegistryRefSpecs

Registries returns application registries.

func (*App001) RemoveEnvironment added in v0.9.0

func (a *App001) RemoveEnvironment(envName string) error

RemoveEnvironment removes an environment.

func (*App001) RenameEnvironment added in v0.9.1

func (a *App001) RenameEnvironment(from, to string) error

RenameEnvironment renames environments.

func (*App001) Upgrade added in v0.9.0

func (a *App001) Upgrade(dryRun bool) error

Upgrade upgrades the app to the latest apiVersion.

type App010 added in v0.9.0

type App010 struct {
	// contains filtered or unexported fields
}

App010 is a ksonnet 0.1.0 application.

func NewApp010 added in v0.9.0

func NewApp010(fs afero.Fs, root string) (*App010, error)

NewApp010 creates an App010 instance.

func (*App010) AddEnvironment added in v0.9.0

func (a *App010) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec) error

AddEnvironment adds an environment spec to the app spec. If the spec already exists, it is overwritten.

func (*App010) Environment added in v0.9.0

func (a *App010) Environment(name string) (*EnvironmentSpec, error)

Environment returns the spec for an environment.

func (*App010) Environments added in v0.9.0

func (a *App010) Environments() (EnvironmentSpecs, error)

Environments returns all environment specs.

func (*App010) Init added in v0.9.0

func (a *App010) Init() error

Init initializes the App.

func (*App010) LibPath added in v0.9.0

func (a *App010) LibPath(envName string) (string, error)

LibPath returns the lib path for an env environment.

func (*App010) Libraries added in v0.9.0

func (a *App010) Libraries() LibraryRefSpecs

Libraries returns application libraries.

func (*App010) Registries added in v0.9.0

func (a *App010) Registries() RegistryRefSpecs

Registries returns application registries.

func (*App010) RemoveEnvironment added in v0.9.0

func (a *App010) RemoveEnvironment(envName string) error

RemoveEnvironment removes an environment.

func (*App010) RenameEnvironment added in v0.9.1

func (a *App010) RenameEnvironment(from, to string) error

RenameEnvironment renames environments.

func (*App010) Upgrade added in v0.9.0

func (a *App010) Upgrade(dryRun bool) error

Upgrade upgrades the app to the latest apiVersion.

type ContributorSpec

type ContributorSpec struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

ContributorSpec is a specification for the project contributors.

type ContributorSpecs

type ContributorSpecs []*ContributorSpec

ContributorSpecs is a list of 0 or more contributors.

type EnvironmentDestinationSpec added in v0.9.0

type EnvironmentDestinationSpec struct {
	// Server is the Kubernetes server that the cluster is running on.
	Server string `json:"server"`
	// Namespace is the namespace of the Kubernetes server that targets should
	// be deployed to. This is "default", if not specified.
	Namespace string `json:"namespace"`
}

EnvironmentDestinationSpec contains the specification for the cluster address that the environment points to.

type EnvironmentSpec added in v0.9.0

type EnvironmentSpec struct {
	// Name is the user defined name of an environment
	Name string `json:"-"`
	// KubernetesVersion is the kubernetes version the targetted cluster is
	// running on.
	KubernetesVersion string `json:"k8sVersion"`
	// Path is the relative project path containing metadata for this
	// environment.
	Path string `json:"path"`
	// Destination stores the cluster address that this environment points to.
	Destination *EnvironmentDestinationSpec `json:"destination"`
	// Targets contain the relative component paths that this environment
	// wishes to deploy on it's destination.
	Targets []string `json:"targets,omitempty"`
}

EnvironmentSpec contains the specification for ksonnet environments.

type EnvironmentSpecs added in v0.9.0

type EnvironmentSpecs map[string]*EnvironmentSpec

EnvironmentSpecs contains one or more EnvironmentSpec.

type GitVersionSpec

type GitVersionSpec struct {
	RefSpec   string `json:"refSpec"`
	CommitSHA string `json:"commitSha"`
}

GitVersionSpec is the specification for a Registry's Git Version.

type LibraryRefSpec

type LibraryRefSpec struct {
	Name       string          `json:"name"`
	Registry   string          `json:"registry"`
	GitVersion *GitVersionSpec `json:"gitVersion"`
}

LibraryRefSpec is the specification for a library part.

type LibraryRefSpecs

type LibraryRefSpecs map[string]*LibraryRefSpec

LibraryRefSpecs is a mapping of a library name to it's LibraryRefSpec.

type RegistryRefSpec

type RegistryRefSpec struct {
	Name       string          `json:"-"`
	Protocol   string          `json:"protocol"`
	URI        string          `json:"uri"`
	GitVersion *GitVersionSpec `json:"gitVersion"`
}

RegistryRefSpec defines the spec for a registry. A registry is a collection of library parts.

type RegistryRefSpecs

type RegistryRefSpecs map[string]*RegistryRefSpec

RegistryRefSpecs is a map of the registry name to a RegistryRefSpec.

type RepositorySpec

type RepositorySpec struct {
	Type string `json:"type"`
	URI  string `json:"uri"`
}

RepositorySpec defines the spec for the upstream repository of this project.

type Spec

type Spec struct {
	APIVersion   string           `json:"apiVersion,omitempty"`
	Kind         string           `json:"kind,omitempty"`
	Name         string           `json:"name,omitempty"`
	Version      string           `json:"version,omitempty"`
	Description  string           `json:"description,omitempty"`
	Authors      []string         `json:"authors,omitempty"`
	Contributors ContributorSpecs `json:"contributors,omitempty"`
	Repository   *RepositorySpec  `json:"repository,omitempty"`
	Bugs         string           `json:"bugs,omitempty"`
	Keywords     []string         `json:"keywords,omitempty"`
	Registries   RegistryRefSpecs `json:"registries,omitempty"`
	Environments EnvironmentSpecs `json:"environments,omitempty"`
	Libraries    LibraryRefSpecs  `json:"libraries,omitempty"`
	License      string           `json:"license,omitempty"`
}

Spec defines all the ksonnet project metadata. This includes details such as the project name, authors, environments, and registries.

func Read added in v0.9.0

func Read(fs afero.Fs, appRoot string) (*Spec, error)

Read will return the specification for a ksonnet application.

func Unmarshal added in v0.9.0

func Unmarshal(bytes []byte) (*Spec, error)

Unmarshal attempts to parse the bytes representing a spec file and convert it into a app.Spec.

func (*Spec) AddEnvironmentSpec added in v0.9.0

func (s *Spec) AddEnvironmentSpec(spec *EnvironmentSpec) error

AddEnvironmentSpec adds an EnvironmentSpec to the list of EnvironmentSpecs. This is equivalent to registering the environment for a ksonnet app.

func (*Spec) AddRegistryRef

func (s *Spec) AddRegistryRef(registryRefSpec *RegistryRefSpec) error

AddRegistryRef adds the RegistryRefSpec to the app spec.

func (*Spec) DeleteEnvironmentSpec added in v0.9.0

func (s *Spec) DeleteEnvironmentSpec(name string) error

DeleteEnvironmentSpec removes the environment specification from the app spec.

func (*Spec) GetEnvironmentSpec added in v0.9.0

func (s *Spec) GetEnvironmentSpec(name string) (*EnvironmentSpec, bool)

GetEnvironmentSpec returns the environment specification for the environment.

func (*Spec) GetEnvironmentSpecs added in v0.9.0

func (s *Spec) GetEnvironmentSpecs() EnvironmentSpecs

GetEnvironmentSpecs returns all environment specifications. We need to pre-populate th EnvironmentSpec name before returning.

func (*Spec) GetRegistryRef

func (s *Spec) GetRegistryRef(name string) (*RegistryRefSpec, bool)

GetRegistryRef returns a populated RegistryRefSpec given a registry name.

func (*Spec) Marshal

func (s *Spec) Marshal() ([]byte, error)

Marshal converts a app.Spec into bytes for file writing.

func (*Spec) UpdateEnvironmentSpec added in v0.9.0

func (s *Spec) UpdateEnvironmentSpec(name string, spec *EnvironmentSpec) error

UpdateEnvironmentSpec updates the environment with the provided name to the specified spec.

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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