fluxexec

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

README

Flux Exec (fluxexec)

Introduction

This package provides a wrapper of the command line interface to execute Flux commands.

How to add new flags

Add the new type Option struct to the options.go of fluxexec package. Then create a function to represent it.

The below example shows how to add the --export flag. We have ExportOption struct to whole the value of the --export flag, and we have Export function to represent this flag during the command creation.

type ExportOption struct {
	export bool
}

// Export represents the --export flag.
func Export(export bool) *ExportOption {
	return &ExportOption{export}
}

After that we go to each command wrapper file, for example we have install.go file as the wrapper of flux install command, and we have bootstrap_github.go file as the wrapper of the flux bootstrap github command.

Following the above example, we add the --export flag to the wrapper of the install command.

First, find the installConfig struct in the install.go file. Then, add the export field to the struct.

type installConfig struct {
	clusterDomain      string
	components         []string
	componentsExtra    []string
	export             bool     // Here's our new export field
	imagePullSecret    string
	logLevel           string
	networkPolicy      bool
	registry           string
	tolerationKeys     []string
	watchAllNamespaces bool
}

Then, we add the configureInstall function for the ExportOption struct. This function will be called to configure the installConfig struct, by setting the value of the export field.

func (opt *ExportOption) configureInstall(conf *installConfig) {
	conf.export = opt.export
}

Next, locate the installCmd function.

func (flux *Flux) installCmd(ctx context.Context, opts ...InstallOption) (*exec.Cmd, error) {

This function will be called to create the command, with all the flags as args. We add the following if statement to help this command generate the --export flag.

	if c.export {
		args = append(args, "--export")
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorEmailOption

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

func AuthorEmail

func AuthorEmail(authorEmail string) *AuthorEmailOption

AuthorEmail represents the --author-email flag.

type AuthorNameOption

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

func AuthorName

func AuthorName(authorName string) *AuthorNameOption

AuthorName represents the --author-name flag.

type BootstrapGitHubOption

type BootstrapGitHubOption interface {
	// contains filtered or unexported methods
}

BootstrapGitHubOption represents options used in the BootstrapGitHub method.

type BootstrapOption

type BootstrapOption interface {
	// contains filtered or unexported methods
}

BootstrapOption represents options used in the Bootstrap* methods.

type BootstrapOptions

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

BootstrapOptions is a special set of options for the (parent) bootstrap command.

func WithBootstrapOptions

func WithBootstrapOptions(opts ...BootstrapOption) *BootstrapOptions

type BranchOption

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

func Branch

func Branch(branch string) *BranchOption

Branch represents the --branch flag.

type CaFileOption

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

func CaFile

func CaFile(caFile string) *CaFileOption

CaFile represents the --ca-file flag.

type ClusterDomainOption

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

func ClusterDomain

func ClusterDomain(clusterDomain string) *ClusterDomainOption

ClusterDomain represents the --cluster-domain flag.

type CommitMessageAppendixOption

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

func CommitMessageAppendix

func CommitMessageAppendix(commitMessageAppendix string) *CommitMessageAppendixOption

CommitMessageAppendix represents the --commit-message-appendix flag.

type Component

type Component string
const (
	ComponentSourceController       Component = "source-controller"
	ComponentKustomizeController    Component = "kustomize-controller"
	ComponentHelmController         Component = "helm-controller"
	ComponentNotificationController Component = "notification-controller"
)

type ComponentExtra

type ComponentExtra string
const (
	ComponentImageReflectorController  ComponentExtra = "image-reflector-controller"
	ComponentImageAutomationController ComponentExtra = "image-automation-controller"
)

type ComponentsExtraOption

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

func ComponentsExtra

func ComponentsExtra(componentsExtra ...ComponentExtra) *ComponentsExtraOption

ComponentsExtra represents the --components-extra flag.

type ComponentsOption

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

func Components

func Components(components ...Component) *ComponentsOption

Components represents the --components flag.

type EcdsaCurve

type EcdsaCurve string
const (
	EcdsaCurveP256 EcdsaCurve = "p256"
	EcdsaCurveP384 EcdsaCurve = "p384"
	EcdsaCurveP521 EcdsaCurve = "p521"
)

type ErrNoSuitableBinary

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

func (*ErrNoSuitableBinary) Error

func (e *ErrNoSuitableBinary) Error() string

func (*ErrNoSuitableBinary) Unwrap

func (e *ErrNoSuitableBinary) Unwrap() error

type ExportOption

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

func Export

func Export(export bool) *ExportOption

Export represents the --export flag.

type Flux

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

func NewFlux

func NewFlux(workingDir string, execPath string) (*Flux, error)

func (*Flux) BootstrapGitHub

func (flux *Flux) BootstrapGitHub(ctx context.Context, opts ...BootstrapGitHubOption) error

func (*Flux) ExecPath

func (flux *Flux) ExecPath() string

ExecPath returns the path to the Flux executable.

func (*Flux) Install

func (flux *Flux) Install(ctx context.Context, opts ...InstallOption) error

func (*Flux) SetLogger

func (flux *Flux) SetLogger(logger logger.Logger)

SetLogger specifies a logger for tfexec to use.

func (*Flux) SetStderr

func (flux *Flux) SetStderr(w io.Writer)

SetStderr specifies a writer to stream stderr to for every command.

This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.

func (*Flux) SetStdout

func (flux *Flux) SetStdout(w io.Writer)

SetStdout specifies a writer to stream stdout to for every command.

This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.

func (*Flux) WorkingDir

func (flux *Flux) WorkingDir() string

WorkingDir returns the working directory for Flux.

type GpgKeyIdOption

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

func GpgKeyId

func GpgKeyId(gpgKeyId string) *GpgKeyIdOption

GpgKeyId represents the --gpg-key-id flag.

type GpgKeyRingOption

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

func GpgKeyRing

func GpgKeyRing(gpgKeyRing string) *GpgKeyRingOption

GpgKeyRing represents the --gpg-key-ring flag.

type GpgPassphraseOption

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

func GpgPassphrase

func GpgPassphrase(gpgPassphrase string) *GpgPassphraseOption

GpgPassphrase represents the --gpg-passphrase flag.

type HostnameOption

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

func Hostname

func Hostname(hostname string) *HostnameOption

Hostname represents the --hostname flag.

type ImagePullSecretOption

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

func ImagePullSecret

func ImagePullSecret(imagePullSecret string) *ImagePullSecretOption

ImagePullSecret represents the --image-pull-secret flag.

type InstallOption

type InstallOption interface {
	// contains filtered or unexported methods
}

InstallOption represents options used in the Install method.

type IntervalOption

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

func Interval

func Interval(interval string) *IntervalOption

Interval represents the --interval flag.

type KeyAlgorithm

type KeyAlgorithm string
const (
	KeyAlgorithmRSA     KeyAlgorithm = "rsa"
	KeyAlgorithmECDSA   KeyAlgorithm = "ecdsa"
	KeyAlgorithmED25519 KeyAlgorithm = "ed25519"
)

type LogLevelOption

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

func LogLevel

func LogLevel(logLevel string) *LogLevelOption

LogLevel represents the --log-level flag.

type NetworkPolicyOption

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

func NetworkPolicy

func NetworkPolicy(networkPolicy bool) *NetworkPolicyOption

NetworkPolicy represents the --network-policy flag.

type OwnerOption

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

func Owner

func Owner(owner string) *OwnerOption

Owner represents the --owner flag.

type PathOption

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

func Path

func Path(path string) *PathOption

Path represents the --path flag.

type PersonalOption

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

func Personal

func Personal(personal bool) *PersonalOption

Personal represents the --personal flag.

type PrivateKeyFileOption

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

func PrivateKeyFile

func PrivateKeyFile(privateKeyFile string) *PrivateKeyFileOption

PrivateKeyFile represents the --private-key-file flag.

type PrivateOption

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

func Private

func Private(private bool) *PrivateOption

Private represents the --private flag.

type ReadWriteKeyOption

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

func ReadWriteKey

func ReadWriteKey(readWriteKey bool) *ReadWriteKeyOption

ReadWriteKey represents the --read-write-key flag.

type ReconcileOption

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

func Reconcile

func Reconcile(reconcile bool) *ReconcileOption

Reconcile represents the --reconcile flag.

type RecurseSubmodulesOption

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

func RecurseSubmodules

func RecurseSubmodules(recurseSubmodules bool) *RecurseSubmodulesOption

RecurseSubmodules represents the --recurse-submodules flag.

type RegistryOption

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

func Registry

func Registry(registry string) *RegistryOption

Registry represents the --registry flag.

type RepositoryOption

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

func Repository

func Repository(repository string) *RepositoryOption

Repository represents the --repository flag.

type SecretNameOption

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

func SecretName

func SecretName(secretName string) *SecretNameOption

SecretName represents the --secret-name flag.

type SshEcdsaCurveOption

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

func SshEcdsaCurve

func SshEcdsaCurve(ecdsaCurve EcdsaCurve) *SshEcdsaCurveOption

SshEcdsaCurve represents the --ssh-ecdsa-curve flag.

type SshHostnameOption

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

func SshHostname

func SshHostname(sshHostname string) *SshHostnameOption

SshHostname represents the --ssh-hostname flag.

type SshKeyAlgorithmOption

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

func SshKeyAlgorithm

func SshKeyAlgorithm(sshKeyAlgorithm KeyAlgorithm) *SshKeyAlgorithmOption

SshKeyAlgorithm represents the --ssh-key-algorithm flag.

type SshRsaBitsOption

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

func SshRsaBits

func SshRsaBits(sshRsaBits int) *SshRsaBitsOption

SshRsaBits represents the --ssh-rsa-bits flag.

type TeamOption

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

func Team

func Team(team ...string) *TeamOption

Team represents the --team flag.

type TokenAuthOption

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

func TokenAuth

func TokenAuth(tokenAuth bool) *TokenAuthOption

TokenAuth represents the --token-auth flag.

type TolerationKeysOption

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

func TolerationKeys

func TolerationKeys(tolerationKeys ...string) *TolerationKeysOption

TolerationKeys represents the --toleration-keys flag.

type WatchAllNamespacesOption

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

func WatchAllNamespaces

func WatchAllNamespaces(watchAllNamespaces bool) *WatchAllNamespacesOption

WatchAllNamespaces represents the --watch-all-namespaces flag.

Jump to

Keyboard shortcuts

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