resource

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// ServiceInactive is a non-started service.
	ServiceInactive = "inactive"
	// ServiceActivating is a starting service.
	ServiceActivating = "activating"
	// ServiceActive is a started service.
	ServiceActive = "active"
	// ServiceFailed is a service that failed to start
	ServiceFailed = "failed"
)

Variables

This section is empty.

Functions

func ToState

func ToState(v interface{}) plan.State

ToState creates a new State using reflection on v.

func WithoutProxy

func WithoutProxy(script string) string

Types

type Base

type Base struct{}

Base can be embedded into a struct to provide a default implementation of plan.Resource.

func (*Base) Apply

func (b *Base) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*Base) QueryState

func (b *Base) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*Base) State

func (b *Base) State() plan.State

State implements plan.Resource.

func (*Base) Undo

func (b *Base) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type Deb

type Deb struct {
	Name string `structs:"name"`
	// Suffix is either "=" followed by the version, or "/" followed by the release stream (stable|testing|unstable).
	// Examples:
	//   Name: "busybox"
	//   Name: "busybox", Suffix: "/stable"
	//   Name: "busybox", Suffix: "=1:1.27.2-2ubuntu3.2"
	Suffix string `structs:"suffix"`
}

Deb represents a .deb package.

func DebResourceFromPackage

func DebResourceFromPackage(p debPkgInfo) *Deb

func (*Deb) Apply

func (d *Deb) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (propagate bool, err error)

func (*Deb) QueryState

func (d *Deb) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)

func (*Deb) State

func (d *Deb) State() plan.State

func (*Deb) Undo

func (d *Deb) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

func (*Deb) WouldChangeState

func (d *Deb) WouldChangeState(ctx context.Context, r plan.Runner) (bool, error)

WouldChangeState returns false if it's guaranteed that a call to Apply() wouldn't change the package installed, and true otherwise.

type Dir

type Dir struct {
	// Path at which to create directory
	Path fmt.Stringer `structs:"path,omitempty"`
	// RecursiveDelete makes the undo operation recursive
	RecursiveDelete bool
}

Dir represents a directory on the file system.

func (*Dir) Apply

func (d *Dir) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*Dir) QueryState

func (d *Dir) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*Dir) State

func (d *Dir) State() plan.State

State implements plan.Resource.

func (*Dir) Undo

func (d *Dir) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type File

type File struct {
	// Source is a path to a local file. Only of of (Source, Content) can be
	// specified at once.
	Source string `structs:"source,omitempty"`
	// Content is the file content. Only of of (Source, Content) can be specified
	// at once.
	Content string `structs:"content,omitempty"`
	// Destination is the file destination path (required).
	Destination string `structs:"destination"`
	// File MD5 checksum. We use md5sum as it's part of coreutils and even part of
	// the default alpine image.
	Checksum string `structs:"checksum" plan:"hide"`
}

File represents a file on the file system.

func (*File) Apply

func (f *File) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*File) QueryState

func (f *File) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*File) State

func (f *File) State() plan.State

State implements plan.Resource.

func (*File) Undo

func (f *File) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type GatherFactFunc

type GatherFactFunc func(ctx context.Context, o *OS, r plan.Runner) error

type KubeSecret

type KubeSecret struct {
	Base

	// SecretName is the name of the secret to read
	SecretName string `structs:"secretName"`
	// Checksum contains the sha256 checksum of the secret data
	Checksum [sha256.Size]byte `structs:"checksum"`
	// DestinationDirectory is the location in which to write stored file data
	DestinationDirectory string `structs:"destinationDirectory"`
	// SecretData holds the actual secret contents -- not serialized
	SecretData SecretData `structs:"-" plan:"hide"`
	// FileNameTransform transforms a secret key into the file name for its contents
	FileNameTransform func(string) string
}

KubeSecret writes secrets to the filesystem where they can be picked up by daemons

func NewKubeSecretResource

func NewKubeSecretResource(secretName string, secretData SecretData, destinationDirectory string, fileNameTransform func(string) string) (*KubeSecret, error)

NewKubeSecretResource creates a new object from secret data

func (*KubeSecret) Apply

func (ks *KubeSecret) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*KubeSecret) QueryState

func (ks *KubeSecret) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)

func (*KubeSecret) State

func (ks *KubeSecret) State() plan.State

State implements plan.Resource.

func (*KubeSecret) Undo

func (ks *KubeSecret) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type KubeadmJoin

type KubeadmJoin struct {
	Base

	// IsMaster should be true if this node should join as a master, or false otherwise.
	IsMaster bool `structs:"isMaster"`
	// NodeIP is the IP of the node trying to join the cluster.
	NodeIP string `structs:"nodeIP"`
	// NodeName, if non-empty, will override the default node name guessed by kubeadm.
	NodeName string
	// MasterIP is the IP of the master node to connect to in order to join the cluster --
	// hidden because the value can change in multi-master configurations but should not make the node plan
	// appear to have changed.
	MasterIP string `structs:"masterIP" plan:"hide"`
	// MasterPort is the port of the master node to connect to in order to join the cluster.
	MasterPort int `structs:"masterPort"`
	// Token is used to authenticate with the Kubernetes API server.
	Token string `structs:"token" plan:"hide"`
	// DiscoveryTokenCaCertHash is used to validate that the root CA public key of the cluster we are trying to join matches.
	DiscoveryTokenCaCertHash string `structs:"discoveryTokenCaCertHash" plan:"hide"`
	// CertificateKey is used to add master nodes to the cluster.
	CertificateKey string `structs:"certificateKey" plan:"hide"`
	// IgnorePreflightErrors is optionally used to skip kubeadm's preflight checks.
	IgnorePreflightErrors []string `structs:"ignorePreflightErrors"`
	// External Load Balancer name or IP address to be used instead of the master's IP
	ControlPlaneEndpoint string `structs:"controlPlaneEndpoint"`
	// Kubernetes Version is used to prepare different parameters
	KubernetesVersion string `structs:"version"`
}

KubeadmJoin represents an attempt to join a Kubernetes node via kubeadm.

func (*KubeadmJoin) Apply

func (kj *KubeadmJoin) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource. TODO: find a way to make this idempotent. TODO: should such a resource be splitted in smaller resources?

func (*KubeadmJoin) State

func (kj *KubeadmJoin) State() plan.State

State implements plan.Resource.

func (*KubeadmJoin) Undo

func (kj *KubeadmJoin) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type OS

type OS struct {
	MachineID  string `structs:"MachineID"`
	SystemUUID string `structs:"SystemUUID"`
	// contains filtered or unexported fields
}

OS is a set of OS properties.

func NewOS

func NewOS(ctx context.Context, r plan.Runner) (*OS, error)

func (*OS) Apply

func (p *OS) Apply(ctx context.Context, r plan.Runner, _ plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*OS) GetSELinuxStatus

func (p *OS) GetSELinuxStatus(ctx context.Context) (SELinuxStatus, SELinuxMode, error)

func (*OS) HasCommand

func (p *OS) HasCommand(ctx context.Context, cmd string) (bool, error)

func (*OS) IsOSInContainerVM

func (p *OS) IsOSInContainerVM(ctx context.Context) (bool, error)

func (*OS) IsSELinuxMode

func (p *OS) IsSELinuxMode(ctx context.Context, mode string) (bool, error)

func (*OS) QueryState

func (p *OS) QueryState(ctx context.Context, r plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*OS) State

func (p *OS) State() plan.State

State implements plan.Resource.

func (*OS) Undo

func (p *OS) Undo(ctx context.Context, r plan.Runner, current plan.State) error

type PkgType

type PkgType string
const (
	PkgTypeDeb  PkgType = "Deb"
	PkgTypeRPM  PkgType = "RPM"
	PkgTypeRHEL PkgType = "RHEL"
)

type RPM

type RPM struct {
	Name string `structs:"name"`
	// Version is optional
	Version             string `structs:"version,omitempty"`
	Release             string `structs:"release,omitempty"`
	IgnoreOtherVersions bool   `structs:"ignoreOtherVersions,omitempty"`
	DisableExcludes     string `structs:"disableExcludes,omitempty"`
}

RPM represents an RPM package.

It isn't legal to provide a Release if no Version is specified. TODO: What about epoch?

func (*RPM) Apply

func (p *RPM) Apply(ctx context.Context, r plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*RPM) QueryState

func (p *RPM) QueryState(ctx context.Context, r plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*RPM) State

func (p *RPM) State() plan.State

State implements plan.Resource.

func (*RPM) Undo

func (p *RPM) Undo(ctx context.Context, r plan.Runner, current plan.State) error

Undo implements plan.Resource

func (*RPM) WouldChangeState

func (p *RPM) WouldChangeState(ctx context.Context, r plan.Runner) (bool, error)

WouldChangeState returns false if a call to Apply() is guaranteed not to change the installed version of the package, and true otherwise.

type Run

type Run struct {
	Base

	Script       fmt.Stringer  `structs:"script"`
	UndoScript   fmt.Stringer  `structs:"undoScript,omitempty"`
	UndoResource plan.Resource `structs:"undoResource,omitempty"`
	Output       *string       // for later resources to use
}

Run is a resource running a script (which can be just a single command). Run doesn't realise any state, Apply will always run the given script.

func (*Run) Apply

func (r *Run) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*Run) State

func (r *Run) State() plan.State

State implements plan.Resource.

func (*Run) Undo

func (r *Run) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type SELinuxMode

type SELinuxMode int
const (
	SELinuxModeUnknown SELinuxMode = iota
	SELinuxEnforcing
	SELinuxPermissive
	SELinuxDisabled
)

func (SELinuxMode) IsDisabled

func (m SELinuxMode) IsDisabled() bool

func (SELinuxMode) IsEnforcing

func (m SELinuxMode) IsEnforcing() bool

func (SELinuxMode) IsPermissive

func (m SELinuxMode) IsPermissive() bool

func (SELinuxMode) IsUnknown

func (m SELinuxMode) IsUnknown() bool

type SELinuxStatus

type SELinuxStatus int
const (
	SELinuxUnknown SELinuxStatus = iota
	SELinuxNotInstalled
	SELinuxInstalled
)

func (SELinuxStatus) IsInstalled

func (s SELinuxStatus) IsInstalled() bool

func (SELinuxStatus) IsNotInstalled

func (s SELinuxStatus) IsNotInstalled() bool

func (SELinuxStatus) IsUnknown

func (s SELinuxStatus) IsUnknown() bool

type SecretData

type SecretData map[string][]byte

SecretData maps names to values as in Kubernetes v1.Secret

type Service

type Service struct {
	// Name of the systemd unit.
	Name string `structs:"name"`
	// Status is the desired service status. Only "active" or "inactive" are valid
	// input.
	Status string `structs:"status"`
	// Whether the service is enabled (systemctl enable) or not.
	Enabled bool `structs:"enabled"`
}

Service represents a systemd service.

func (*Service) Apply

func (p *Service) Apply(ctx context.Context, r plan.Runner, diff plan.Diff) (bool, error)

Apply implements plan.Resource.

func (*Service) QueryState

func (p *Service) QueryState(ctx context.Context, r plan.Runner) (plan.State, error)

QueryState implements plan.Resource.

func (*Service) State

func (p *Service) State() plan.State

State implements plan.Resource.

func (*Service) Undo

func (p *Service) Undo(ctx context.Context, r plan.Runner, current plan.State) error

Undo implements plan.Resource

Jump to

Keyboard shortcuts

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