Documentation ¶
Index ¶
- Constants
- Variables
- func SaveOverride(encoder Encoder, fs afero.Fs, root string, o *Override) error
- func StubUpdateLibData(fs afero.Fs, k8sSpecFlag, libPath string) (string, error)
- type App
- type App001
- func (a *App001) AddEnvironment(e *EnvironmentConfig, k8sSpecFlag string, isOverride bool) error
- func (ba App001) AddRegistry(newReg *RegistryConfig, isOverride bool) error
- func (a *App001) CheckUpgrade() (bool, error)
- func (ba App001) CurrentEnvironment() string
- func (a *App001) Environment(name string) (*EnvironmentConfig, error)
- func (ba App001) EnvironmentParams(envName string) (string, error)
- func (a *App001) Environments() (EnvironmentConfigs, error)
- func (ba App001) Fs() afero.Fs
- func (a *App001) LibPath(envName string) (string, error)
- func (a *App001) Libraries() (LibraryConfigs, error)
- func (a *App001) Registries() (RegistryConfigs, 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, env string, libSpec *LibraryConfig) error
- func (ba App001) UpdateRegistry(spec *RegistryConfig) error
- func (a *App001) UpdateTargets(envName string, targets []string) error
- func (a *App001) Upgrade(dryRun bool) error
- func (ba App001) VendorPath() string
- type App010
- func (a *App010) AddEnvironment(newEnv *EnvironmentConfig, k8sSpecFlag string, isOverride bool) error
- func (ba App010) AddRegistry(newReg *RegistryConfig, isOverride bool) error
- func (a *App010) CheckUpgrade() (bool, error)
- func (ba App010) CurrentEnvironment() string
- func (ba App010) Environment(name string) (*EnvironmentConfig, error)
- func (ba App010) EnvironmentParams(envName string) (string, error)
- func (ba App010) Environments() (EnvironmentConfigs, error)
- func (ba App010) Fs() afero.Fs
- func (a *App010) LibPath(envName string) (string, error)
- func (a *App010) Libraries() (LibraryConfigs, error)
- func (a *App010) Registries() (RegistryConfigs, 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, env string, libSpec *LibraryConfig) error
- func (ba App010) UpdateRegistry(spec *RegistryConfig) error
- func (a *App010) UpdateTargets(envName string, targets []string) error
- func (a *App010) Upgrade(dryRun bool) error
- func (ba App010) VendorPath() string
- type ContributorSpec
- type ContributorSpecs
- type Encoder
- type EnvironmentConfig
- type EnvironmentConfigs
- type EnvironmentDestinationSpec
- type GitVersionSpec
- type LibraryConfig
- type LibraryConfigs
- type Override
- type RegistryConfig
- type RegistryConfigs
- type RepositorySpec
- type Spec
- func (s *Spec) AddEnvironmentConfig(env *EnvironmentConfig) error
- func (s *Spec) AddRegistryConfig(cfg *RegistryConfig) error
- func (s *Spec) DeleteEnvironmentConfig(name string) error
- func (s *Spec) GetEnvironmentConfig(name string) (*EnvironmentConfig, bool)
- func (s *Spec) GetEnvironmentConfigs() EnvironmentConfigs
- func (s *Spec) Marshal() ([]byte, error)
- func (s *Spec) RegistryConfig(name string) (*RegistryConfig, bool)
- func (s *Spec) UpdateEnvironmentConfig(name string, env *EnvironmentConfig) error
- type YAMLEncoder
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.2.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 ¶
func SaveOverride ¶ added in v0.11.0
SaveOverride saves the override to the filesystem.
Types ¶
type App ¶
type App interface { // AddEnvironment adds an environment. AddEnvironment(spec *EnvironmentConfig, k8sSpecFlag string, isOverride bool) error // AddRegistry adds a registry. AddRegistry(spec *RegistryConfig, isOverride bool) error // CurrentEnvironment returns the current environment name or an empty string. CurrentEnvironment() string // Environment finds an environment by name. Environment(name string) (*EnvironmentConfig, error) // Environments returns all environments. Environments() (EnvironmentConfigs, error) // EnvironmentParams returns params for an environment. EnvironmentParams(name string) (string, error) // Fs is the app's afero Fs. Fs() afero.Fs // CheckUpgrade checks whether an app should be upgraded. CheckUpgrade() (bool, error) // LibPath returns the path of the lib for an environment. LibPath(envName string) (string, error) // Libraries returns all environments. Libraries() (LibraryConfigs, error) // Registries returns all registries. Registries() (RegistryConfigs, 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 adds or updates a library reference. // env is optional - if provided the reference is scoped under the environment, // otherwise it is globally scoped. UpdateLib(name string, env string, spec *LibraryConfig) error // UpdateRegistry updates a registry. UpdateRegistry(spec *RegistryConfig) error // Upgrade upgrades an application to the current version. Upgrade(dryRun bool) error // VendorPath returns the root of the vendor path. VendorPath() string }
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(e *EnvironmentConfig, k8sSpecFlag string, 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 *RegistryConfig, isOverride bool) error
func (*App001) CheckUpgrade ¶ added in v0.12.0
CheckUpgrade initializes the App.
func (App001) CurrentEnvironment ¶
func (ba App001) CurrentEnvironment() string
func (*App001) Environment ¶
func (a *App001) Environment(name string) (*EnvironmentConfig, 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() (EnvironmentConfigs, 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() (LibraryConfigs, error)
Libraries returns application libraries.
func (*App001) Registries ¶
func (a *App001) Registries() (RegistryConfigs, 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, env string, libSpec *LibraryConfig) error
UpdateLib adds or updates a library reference. env is optional - if provided the reference is scoped under the environment, otherwise it is globally scoped.
func (App001) UpdateRegistry ¶ added in v0.12.0
func (ba App001) UpdateRegistry(spec *RegistryConfig) error
UpdateRegistry updates a registry spec and persists in app[.override].yaml
func (*App001) UpdateTargets ¶
UpdateTargets returns an error since 0.0.1 based applications don't have support for targets.
func (App001) VendorPath ¶ added in v0.12.0
func (ba App001) VendorPath() string
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(newEnv *EnvironmentConfig, k8sSpecFlag string, 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 *RegistryConfig, isOverride bool) error
func (*App010) CheckUpgrade ¶ added in v0.12.0
CheckUpgrade initializes the App.
func (App010) CurrentEnvironment ¶
func (ba App010) CurrentEnvironment() string
func (App010) Environment ¶
func (ba App010) Environment(name string) (*EnvironmentConfig, error)
Environment returns the spec for an environment.
func (App010) EnvironmentParams ¶
func (App010) Environments ¶
func (ba App010) Environments() (EnvironmentConfigs, error)
Environments returns all environment specs, merged with any corresponding overrides. Note overrides cannot override environment libraries.
func (*App010) Libraries ¶
func (a *App010) Libraries() (LibraryConfigs, error)
Libraries returns application libraries.
func (*App010) Registries ¶
func (a *App010) Registries() (RegistryConfigs, 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, env string, libSpec *LibraryConfig) error
UpdateLib adds or updates a library reference. env is optional - if provided the reference is scoped under the environment, otherwise it is globally scoped.
func (App010) UpdateRegistry ¶ added in v0.12.0
func (ba App010) UpdateRegistry(spec *RegistryConfig) error
UpdateRegistry updates a registry spec and persists in app[.override].yaml
func (*App010) UpdateTargets ¶
UpdateTargets updates the list of targets for a 0.1.0 application.
func (App010) VendorPath ¶ added in v0.12.0
func (ba App010) VendorPath() string
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 Encoder ¶ added in v0.11.0
type Encoder interface { // Encode writes an item to a stream. Implementations may return errors // if the data to be encoded is invalid. Encode(i interface{}, w io.Writer) error }
Encoder writes items to a serialized form.
type EnvironmentConfig ¶ added in v0.12.0
type EnvironmentConfig struct { // Name is the user defined name of an environment Name string `json:"-"` // KubernetesVersion is the kubernetes version the targeted 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"` // Libraries specifies versioned libraries specifically used by this environment. Libraries LibraryConfigs `json:"libraries,omitempty"` // contains filtered or unexported fields }
EnvironmentConfig contains the specification for ksonnet environments.
func (*EnvironmentConfig) IsOverride ¶ added in v0.12.0
func (e *EnvironmentConfig) IsOverride() bool
IsOverride is true if this EnvironmentConfig is an override.
func (*EnvironmentConfig) MakePath ¶ added in v0.12.0
func (e *EnvironmentConfig) MakePath(rootPath string) string
MakePath return the absolute path to the environment directory.
type EnvironmentConfigs ¶ added in v0.12.0
type EnvironmentConfigs map[string]*EnvironmentConfig
EnvironmentConfigs contains one or more EnvironmentConfig.
func (*EnvironmentConfigs) UnmarshalJSON ¶ added in v0.12.0
func (e *EnvironmentConfigs) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. Our goal is to populate the Name field of EnvironmentConfig objects according to they key name in the environments map.
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 GitVersionSpec ¶
GitVersionSpec is the specification for a Registry's Git Version.
type LibraryConfig ¶ added in v0.12.0
type LibraryConfig struct { Name string `json:"name"` Registry string `json:"registry"` Version string `json:"version"` }
LibraryConfig is the specification for a library part.
func (*LibraryConfig) UnmarshalJSON ¶ added in v0.12.0
func (l *LibraryConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. We implement some compatibility conversions.
type LibraryConfigs ¶ added in v0.12.0
type LibraryConfigs map[string]*LibraryConfig
LibraryConfigs is a mapping of a library configurations by name.
func (*LibraryConfigs) UnmarshalJSON ¶ added in v0.12.0
func (l *LibraryConfigs) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. We implement some compatibility conversions.
type Override ¶
type Override struct { Kind string `json:"kind"` APIVersion string `json:"apiVersion"` Environments EnvironmentConfigs `json:"environments,omitempty"` Registries RegistryConfigs `json:"registries,omitempty"` }
Override defines overrides to ksonnet project configurations.
type RegistryConfig ¶ added in v0.12.0
type RegistryConfig 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`, `fs`, `helm`. Protocol string `json:"protocol"` // URI is the location of the registry. URI string `json:"uri"` // contains filtered or unexported fields }
RegistryConfig defines the spec for a registry. A registry is a collection of library parts.
func (*RegistryConfig) IsOverride ¶ added in v0.12.0
func (r *RegistryConfig) IsOverride() bool
IsOverride is true if this RegistryConfig is an override.
type RegistryConfigs ¶ added in v0.12.0
type RegistryConfigs map[string]*RegistryConfig
RegistryConfigs is a map of the registry name to a RegistryConfig.
func (*RegistryConfigs) UnmarshalJSON ¶ added in v0.12.0
func (r *RegistryConfigs) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. Our goal is to populate the Name field of RegistryConfig objects according to they key name in the registries map.
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 RegistryConfigs `json:"registries,omitempty"` Environments EnvironmentConfigs `json:"environments,omitempty"` Libraries LibraryConfigs `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) AddEnvironmentConfig ¶ added in v0.12.0
func (s *Spec) AddEnvironmentConfig(env *EnvironmentConfig) error
AddEnvironmentConfig adds an EnvironmentConfig to the list of EnvironmentConfigs. This is equivalent to registering the environment for a ksonnet app.
func (*Spec) AddRegistryConfig ¶ added in v0.12.0
func (s *Spec) AddRegistryConfig(cfg *RegistryConfig) error
AddRegistryConfig adds the RegistryConfig to the app spec.
func (*Spec) DeleteEnvironmentConfig ¶ added in v0.12.0
DeleteEnvironmentConfig removes the environment specification from the app spec.
func (*Spec) GetEnvironmentConfig ¶ added in v0.12.0
func (s *Spec) GetEnvironmentConfig(name string) (*EnvironmentConfig, bool)
GetEnvironmentConfig returns the environment specification for the environment. TODO: Consider returning copies instead of originals
func (*Spec) GetEnvironmentConfigs ¶ added in v0.12.0
func (s *Spec) GetEnvironmentConfigs() EnvironmentConfigs
GetEnvironmentConfigs returns all environment specifications. TODO: Consider returning copies instead of originals
func (*Spec) RegistryConfig ¶ added in v0.12.0
func (s *Spec) RegistryConfig(name string) (*RegistryConfig, bool)
RegistryConfig returns a populated RegistryConfig given a registry name.
func (*Spec) UpdateEnvironmentConfig ¶ added in v0.12.0
func (s *Spec) UpdateEnvironmentConfig(name string, env *EnvironmentConfig) error
UpdateEnvironmentConfig updates the environment with the provided name to the specified spec.
type YAMLEncoder ¶ added in v0.11.0
type YAMLEncoder struct{}
YAMLEncoder write items to a serialized form in YAML format.