common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicAutomatedTestingRepoURL  = "https://github.com/yorinasub17/packer-plugin-git-shell-automated-testing.git"
	PrivateAutomatedTestingRepoURL = "https://github.com/yorinasub17/packer-plugin-git-shell-automated-testing-private.git"
	TestGitTokenEnvVar             = "TEST_GIT_TOKEN"
	TestGitUsernameEnvVar          = "TEST_GIT_USERNAME"
)

Variables

This section is empty.

Functions

func CloneAndCheckout

func CloneAndCheckout(opts GitOptions, cloneDir string) error

CloneAndCheckout uses go-git to clone the configured repository at the desired ref into the given cloneDir.

func RunAccTest added in v0.2.0

func RunAccTest(
	t *testing.T,
	testName string,
	testTemplate string,
	provisionerType string,
	expectedLogs []string,
)

RunAccTest is a helper routine to simplify setting up an acc test for the various provisioners in this repo.

Types

type File added in v0.2.0

type File struct {
	// Path is the relative path in the git repo where the file or folder to upload is located.
	Path string `mapstructure:"path" required:"true"`
	// Destination is the path on the machine where the file or folder will be uploaded to.
	Destination string `mapstructure:"destination" required:"true"`
}

func (*File) FlatMapstructure added in v0.2.0

func (*File) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatFile. FlatFile is an auto-generated flat version of File. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type FlatFile added in v0.2.0

type FlatFile struct {
	Path        *string `mapstructure:"path" required:"true" cty:"path" hcl:"path"`
	Destination *string `mapstructure:"destination" required:"true" cty:"destination" hcl:"destination"`
}

FlatFile is an auto-generated flat version of File. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatFile) HCL2Spec added in v0.2.0

func (*FlatFile) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a File. This spec is used by HCL to read the fields of File. The decoded values from this spec will then be applied to a FlatFile.

type FlatScript

type FlatScript struct {
	Path            *string  `mapstructure:"path" required:"true" cty:"path" hcl:"path"`
	Args            []string `mapstructure:"args" cty:"args" hcl:"args"`
	EnvironmentVars []string `mapstructure:"environment_vars" cty:"environment_vars" hcl:"environment_vars"`
}

FlatScript is an auto-generated flat version of Script. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatScript) HCL2Spec

func (*FlatScript) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Script. This spec is used by HCL to read the fields of Script. The decoded values from this spec will then be applied to a FlatScript.

type GitConfig added in v0.2.0

type GitConfig struct {
	packer_common.PackerConfig `mapstructure:",squash"`

	// Source is the git URL (e.g., https://github.com/yorinasub17/packer-git-shell-example.git) where the scripts are
	// located.
	Source string `mapstructure:"source" required:"true"`
	// Ref is the git ref to checkout when sourcing the scripts.
	Ref string `mapstructure:"ref" required:"true"`
	// UsernameEnvVar is the name of the environment variable to lookup for the username to use when authing to the git
	// repo. Defaults to GIT_USERNAME.
	UsernameEnvVar string `mapstructure:"username_env_var"`
	// PasswordEnvVar is the name of the environment variable to lookup for the password to use when authing to the git
	// repo. If unset, defaults to GIT_PASSWORD.
	PasswordEnvVar string `mapstructure:"password_env_var"`
}

func (GitConfig) GetGitOptions added in v0.2.0

func (cfg GitConfig) GetGitOptions() GitOptions

type GitOptions

type GitOptions struct {
	// RepoURL is the URL of the git repo to clone.
	RepoURL string

	// Ref is the git ref to checkout after cloning.
	Ref string

	// UsernameEnvVar is the name of the environment variable to lookup for the username to use when authing to the git
	// repo. If unset, defaults to defaultUsernameEnvVar.
	UsernameEnvVar string

	// PasswordEnvVar is the name of the environment variable to lookup for the password to use when authing to the git
	// repo. If unset, defaults to defaultPasswordEnvVar.
	PasswordEnvVar string
}

GitOptions specifies the options to use when cloning a git repo and checking out a ref.

type Script

type Script struct {
	// Path is the relative path in the git repo where the script to run is located.
	Path string `mapstructure:"path" required:"true"`
	// Args is the script args to pass when executing the script.
	Args []string `mapstructure:"args"`
	// EnvironmentVars is the list of environment variables that should be set when the script is called. Each entry is
	// a key=value string, setting the environment variable `key` to the given `value`.
	EnvironmentVars []string `mapstructure:"environment_vars"`
}

func (*Script) FlatMapstructure

func (*Script) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatScript. FlatScript is an auto-generated flat version of Script. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type ScriptConfig added in v0.2.0

type ScriptConfig struct {
	// Scripts is a list of blocks that specify which scripts from the repo should be called, and with what args. The
	// scripts will be called in the order in which the blocks are defined. At least one script block must be defined.
	Scripts []Script `mapstructure:"script"`
}

Jump to

Keyboard shortcuts

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