Documentation ¶
Index ¶
- Constants
- Variables
- func StubUpdateLibData(fs afero.Fs, k8sSpecFlag, libPath string, useVersionPath bool) (string, error)
- type App
- type App001
- func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec, isOverride bool) error
- func (ba App001) AddRegistry(newReg *RegistryRefSpec, isOverride bool) error
- func (ba App001) CurrentEnvironment() string
- func (a *App001) Environment(name string) (*EnvironmentSpec, error)
- func (ba App001) EnvironmentParams(envName string) (string, error)
- func (a *App001) Environments() (EnvironmentSpecs, error)
- func (ba App001) Fs() afero.Fs
- func (a *App001) Init() error
- func (a *App001) LibPath(envName string) (string, error)
- func (a *App001) Libraries() (LibraryRefSpecs, error)
- func (a *App001) Registries() (RegistryRefSpecs, error)
- func (a *App001) RemoveEnvironment(envName string, override bool) error
- func (a *App001) RenameEnvironment(from, to string, override bool) error
- func (ba App001) Root() string
- func (ba App001) SetCurrentEnvironment(name string) error
- func (ba App001) UpdateLib(name string, libSpec *LibraryRefSpec) error
- func (a *App001) UpdateTargets(envName string, targets []string) error
- func (a *App001) Upgrade(dryRun bool) error
- type App010
- func (a *App010) AddEnvironment(name, k8sSpecFlag string, newEnv *EnvironmentSpec, isOverride bool) error
- func (ba App010) AddRegistry(newReg *RegistryRefSpec, isOverride bool) error
- func (ba App010) CurrentEnvironment() string
- func (a *App010) Environment(name string) (*EnvironmentSpec, error)
- func (ba App010) EnvironmentParams(envName string) (string, error)
- func (a *App010) Environments() (EnvironmentSpecs, error)
- func (ba App010) Fs() afero.Fs
- func (a *App010) Init() error
- func (a *App010) LibPath(envName string) (string, error)
- func (a *App010) Libraries() (LibraryRefSpecs, error)
- func (a *App010) Registries() (RegistryRefSpecs, error)
- func (a *App010) RemoveEnvironment(envName string, override bool) error
- func (a *App010) RenameEnvironment(from, to string, override bool) error
- func (ba App010) Root() string
- func (ba App010) SetCurrentEnvironment(name string) error
- func (ba App010) UpdateLib(name string, libSpec *LibraryRefSpec) error
- func (a *App010) UpdateTargets(envName string, targets []string) error
- func (a *App010) Upgrade(dryRun bool) error
- type ContributorSpec
- type ContributorSpecs
- type EnvironmentDestinationSpec
- type EnvironmentSpec
- type EnvironmentSpecs
- type GitVersionSpec
- type LibraryRefSpec
- type LibraryRefSpecs
- type Override
- type RegistryRefSpec
- type RegistryRefSpecs
- type RepositorySpec
- type Spec
- func (s *Spec) AddEnvironmentSpec(spec *EnvironmentSpec) error
- func (s *Spec) AddRegistryRef(registryRefSpec *RegistryRefSpec) error
- func (s *Spec) DeleteEnvironmentSpec(name string) error
- func (s *Spec) GetEnvironmentSpec(name string) (*EnvironmentSpec, bool)
- func (s *Spec) GetEnvironmentSpecs() EnvironmentSpecs
- func (s *Spec) GetRegistryRef(name string) (*RegistryRefSpec, bool)
- func (s *Spec) Marshal() ([]byte, error)
- func (s *Spec) UpdateEnvironmentSpec(name string, spec *EnvironmentSpec) error
Constants ¶
const ( // EnvironmentDirName is the directory name for environments. EnvironmentDirName = "environments" // LibDirName is the directory name for libraries. LibDirName = "lib" )
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 ¶
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 )
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 ¶
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.
type App001 ¶
type App001 struct {
// contains filtered or unexported fields
}
App001 is a ksonnet 0.0.1 application.
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 (*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) 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 ¶
RemoveEnvironment removes an environment.
func (*App001) RenameEnvironment ¶
RenameEnvironment renames environments.
func (App001) SetCurrentEnvironment ¶
func (App001) UpdateLib ¶
func (ba App001) UpdateLib(name string, libSpec *LibraryRefSpec) error
func (*App001) UpdateTargets ¶
UpdateTargets returns an error since 0.0.1 based applications don't have support for targets.
type App010 ¶
type App010 struct {
// contains filtered or unexported fields
}
App010 is a ksonnet 0.1.0 application.
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 (*App010) Environments ¶
func (a *App010) Environments() (EnvironmentSpecs, error)
Environments returns all environment specs.
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 ¶
RemoveEnvironment removes an environment.
func (*App010) RenameEnvironment ¶
RenameEnvironment renames environments.
func (App010) SetCurrentEnvironment ¶
func (App010) UpdateLib ¶
func (ba App010) UpdateLib(name string, libSpec *LibraryRefSpec) error
func (*App010) UpdateTargets ¶
UpdateTargets updates the list of targets for a 0.1.0 application.
type ContributorSpec ¶
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 ¶
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 ¶
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 ¶
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) UpdateEnvironmentSpec ¶
func (s *Spec) UpdateEnvironmentSpec(name string, spec *EnvironmentSpec) error
UpdateEnvironmentSpec updates the environment with the provided name to the specified spec.