Documentation
¶
Overview ¶
Package state keeps the Installations a user has made: the catalog of saved selections, stored in one file.
Index ¶
- Constants
- func Dir() (string, error)
- type Catalog
- func (c *Catalog) ClusterNameFree(name, original string) error
- func (c *Catalog) Clusters() []string
- func (c *Catalog) Demos() []string
- func (c *Catalog) Find(key string) (Installation, bool)
- func (c *Catalog) Forget(key string) error
- func (c *Catalog) FreeClusterName() string
- func (c *Catalog) Keys() []string
- func (c *Catalog) Last() (Installation, bool)
- func (c *Catalog) Len() int
- func (c *Catalog) NewDemo() Installation
- func (c *Catalog) NewInstall(context string) (Installation, bool)
- func (c *Catalog) Problem() error
- func (c *Catalog) Record(st Installation) error
- type Installation
Constants ¶
const ( KindDemo = "kind" Cluster = "cluster" )
const (
// DefaultClusterName is the name of the first demo's kind cluster.
DefaultClusterName = "kubrix-demo"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is the user's saved Installations: demos on kind clusters and installs on existing clusters.
A Catalog that could not read its file is empty, reports why through Problem, and refuses to write, so the unreadable file is never overwritten.
func Open ¶
Open reads the catalog in dir. A missing file is an empty catalog; an empty dir is an unavailable one.
func (*Catalog) ClusterNameFree ¶
ClusterNameFree checks that name can name a kind cluster for a demo. original is the key of the demo being rerun, which may keep its own name.
func (*Catalog) Clusters ¶
Clusters returns the keys of the installs on existing clusters, most recently used first.
func (*Catalog) Find ¶
func (c *Catalog) Find(key string) (Installation, bool)
Find returns the installation with the key (kind cluster name or kube context).
func (*Catalog) FreeClusterName ¶
FreeClusterName returns the first kind cluster name of kubrix-demo, kubrix-demo-2, ... that no installation uses.
func (*Catalog) Last ¶
func (c *Catalog) Last() (Installation, bool)
Last is the installation used most recently, of either kind.
func (*Catalog) NewDemo ¶
func (c *Catalog) NewDemo() Installation
NewDemo returns the selections a new demo starts from: those of the last demo, without its repository, and with a kind cluster name that is free.
func (*Catalog) NewInstall ¶
func (c *Catalog) NewInstall(context string) (Installation, bool)
NewInstall returns the selections an install on the kube context starts from, and whether the context was installed to before. A rerun keeps everything. A new context starts from the last install on a cluster, without what belongs to that cluster (repository, domain, excluded apps, version). Without one, only the personal choices of the last demo carry over.
func (*Catalog) Record ¶
func (c *Catalog) Record(st Installation) error
Record saves the installation and makes it the most recently used one. It does not replace an installation of the other kind that has the same key.
type Installation ¶
type Installation struct {
Kind string `json:"kind,omitempty"`
GitHost string `json:"gitHost,omitempty"`
Org string `json:"org,omitempty"`
Repo string `json:"repo,omitempty"`
GitUserName string `json:"gitUserName,omitempty"`
TargetType string `json:"targetType,omitempty"`
UpstreamRepo string `json:"upstreamRepo,omitempty"`
UpstreamBranch string `json:"upstreamBranch,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
Context string `json:"context,omitempty"`
Domain string `json:"domain,omitempty"`
DNSProvider string `json:"dnsProvider,omitempty"`
CloudProvider string `json:"cloudProvider,omitempty"`
ExcludedApps []string `json:"excludedApps,omitempty"`
}
Installation holds one installation's selections. It deliberately has no token or DNS credential field.
func (Installation) IsCluster ¶
func (st Installation) IsCluster() bool
func (Installation) Key ¶
func (st Installation) Key() string
Key identifies an installation: the kind cluster name for demos, the kube context otherwise.
func (Installation) Where ¶
func (st Installation) Where() string
Where says where the platform runs, e.g. "kind cluster kubrix-demo" or "context prod".