app

package
v0.10.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: 14 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

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

StubUpdateLibData always returns no error.

Types

type App

type App interface {
	// AddEnvironment adds an environment.
	AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec, isOverride bool) error
	// AddRegistry adds a registry.
	AddRegistry(spec *RegistryRefSpec, isOverride bool) error
	// CurrentEnvironment returns the current environment name or an empty string.
	CurrentEnvironment() string
	// Environment finds an environment by name.
	Environment(name string) (*EnvironmentSpec, error)
	// Environments returns all environments.
	Environments() (EnvironmentSpecs, error)
	// EnvironmentParams returns params for an environment.
	EnvironmentParams(name string) (string, error)
	// Fs is the app's afero Fs.
	Fs() afero.Fs
	// Init inits an environment.
	Init() error
	// LibPath returns the path of the lib for an environment.
	LibPath(envName string) (string, error)
	// Libraries returns all environments.
	Libraries() (LibraryRefSpecs, error)
	// Registries returns all registries.
	Registries() (RegistryRefSpecs, error)
	// RemoveEnvironment removes an environment from the main configuration or an override.
	RemoveEnvironment(name string, override bool) error
	// RenameEnvironment renames an environment in the main configuration or an override.
	RenameEnvironment(from, to string, override bool) error
	// Root returns the root path of the application.
	Root() string
	// SetCurrentEnvironment sets the current environment.
	SetCurrentEnvironment(name string) error
	// UpdateTargets sets the targets for an environment.
	UpdateTargets(envName string, targets []string) error
	// UpdateLib updates a library.
	UpdateLib(name string, spec *LibraryRefSpec) error
	// Upgrade upgrades an application to the current version.
	Upgrade(dryRun bool) error
}

App is a ksonnet application.

func Load

func Load(fs afero.Fs, cwd string, skipFindRoot bool) (App, error)

Load loads the application configuration.

type App001

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

App001 is a ksonnet 0.0.1 application.

func NewApp001

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

NewApp001 creates an App001 instance.

func (*App001) AddEnvironment

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

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

func (App001) AddRegistry

func (ba App001) AddRegistry(newReg *RegistryRefSpec, isOverride bool) error

func (App001) CurrentEnvironment

func (ba App001) CurrentEnvironment() string

func (*App001) Environment

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) EnvironmentParams

func (ba App001) EnvironmentParams(envName string) (string, error)

func (*App001) Environments

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) Fs

func (ba App001) Fs() afero.Fs

func (*App001) Init

func (a *App001) Init() error

Init initializes the App.

func (*App001) LibPath

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

LibPath returns the lib path for an env environment.

func (*App001) Libraries

func (a *App001) Libraries() (LibraryRefSpecs, error)

Libraries returns application libraries.

func (*App001) Registries

func (a *App001) Registries() (RegistryRefSpecs, error)

Registries returns application registries.

func (*App001) RemoveEnvironment

func (a *App001) RemoveEnvironment(envName string, override bool) error

RemoveEnvironment removes an environment.

func (*App001) RenameEnvironment

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

RenameEnvironment renames environments.

func (App001) Root

func (ba App001) Root() string

func (App001) SetCurrentEnvironment

func (ba App001) SetCurrentEnvironment(name string) error

func (App001) UpdateLib

func (ba App001) UpdateLib(name string, libSpec *LibraryRefSpec) error

func (*App001) UpdateTargets

func (a *App001) UpdateTargets(envName string, targets []string) error

UpdateTargets returns an error since 0.0.1 based applications don't have support for targets.

func (*App001) Upgrade

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

Upgrade upgrades the app to the latest apiVersion.

type App010

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

App010 is a ksonnet 0.1.0 application.

func NewApp010

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

NewApp010 creates an App010 instance.

func (*App010) AddEnvironment

func (a *App010) AddEnvironment(name, k8sSpecFlag string, newEnv *EnvironmentSpec, isOverride bool) error

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

func (App010) AddRegistry

func (ba App010) AddRegistry(newReg *RegistryRefSpec, isOverride bool) error

func (App010) CurrentEnvironment

func (ba App010) CurrentEnvironment() string

func (*App010) Environment

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

Environment returns the spec for an environment.

func (App010) EnvironmentParams

func (ba App010) EnvironmentParams(envName string) (string, error)

func (*App010) Environments

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

Environments returns all environment specs.

func (App010) Fs

func (ba App010) Fs() afero.Fs

func (*App010) Init

func (a *App010) Init() error

Init initializes the App.

func (*App010) LibPath

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

LibPath returns the lib path for an env environment.

func (*App010) Libraries

func (a *App010) Libraries() (LibraryRefSpecs, error)

Libraries returns application libraries.

func (*App010) Registries

func (a *App010) Registries() (RegistryRefSpecs, error)

Registries returns application registries.

func (*App010) RemoveEnvironment

func (a *App010) RemoveEnvironment(envName string, override bool) error

RemoveEnvironment removes an environment.

func (*App010) RenameEnvironment

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

RenameEnvironment renames environments.

func (App010) Root

func (ba App010) Root() string

func (App010) SetCurrentEnvironment

func (ba App010) SetCurrentEnvironment(name string) error

func (App010) UpdateLib

func (ba App010) UpdateLib(name string, libSpec *LibraryRefSpec) error

func (*App010) UpdateTargets

func (a *App010) UpdateTargets(envName string, targets []string) error

UpdateTargets updates the list of targets for a 0.1.0 application.

func (*App010) Upgrade

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

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

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"`
	// contains filtered or unexported fields
}

EnvironmentSpec contains the specification for ksonnet environments.

func (*EnvironmentSpec) IsOverride

func (e *EnvironmentSpec) IsOverride() bool

IsOverride is true if this EnvironmentSpec is an override.

func (*EnvironmentSpec) MakePath

func (e *EnvironmentSpec) MakePath(rootPath string) string

MakePath return the absolute path to the environment directory.

type EnvironmentSpecs

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 Override

type Override struct {
	Environments EnvironmentSpecs `json:"environments,omitempty"`
	Registries   RegistryRefSpecs `json:"registries,omitempty"`
}

Override defines overrides to ksonnet project configurations.

type RegistryRefSpec

type RegistryRefSpec struct {
	// Name is the user defined name of a registry.
	Name string `json:"-"`
	// Protocol is the registry protocol for this registry. Currently supported
	// values are `github` and `fs`.
	Protocol string `json:"protocol"`
	// URI is the location of the registry.
	URI string `json:"uri"`
	// GitVersion is the git information for the registry.
	GitVersion *GitVersionSpec `json:"gitVersion,omitempty"`
	// contains filtered or unexported fields
}

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

func (*RegistryRefSpec) IsOverride

func (r *RegistryRefSpec) IsOverride() bool

IsOverride is true if this RegistryRefSpec is an override.

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 (*Spec) AddEnvironmentSpec

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

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

DeleteEnvironmentSpec removes the environment specification from the app spec.

func (*Spec) GetEnvironmentSpec

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

GetEnvironmentSpec returns the environment specification for the environment.

func (*Spec) GetEnvironmentSpecs

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

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