Documentation
¶
Index ¶
- Constants
- Variables
- func NewWorkflowGenerator(options ...Option) *workflowGenerator
- func PrintConfiguration(cfg WorkflowConfig, runtime string, w io.Writer) error
- func PrintPostExportMessage(opts WorkflowConfig, w io.Writer) error
- type BufferWriter
- type Option
- type WorkflowConfig
- type WorkflowGeneratorMock
- type WorkflowWriter
Constants ¶
const ( MainLayoutPlainText = `` /* 281-byte string literal not displayed */ RequireManyPlainText = ` Required Secrets & Variables: %s %s %s %s %s ` RequireOnePlainText = ` Required secret: %s ` PostExportManyPlainText = ` GitHub Workflow created at: %s Create the following Secrets & Variables on github.com: %s %s %s %s %s ` PostExportOnePlainText = ` GitHub Workflow created at: %s Create the following Secret on github.com: %s ` )
const ( DefaultPlatform = "github" DefaultGitHubWorkflowDir = ".github/workflows" DefaultGitHubWorkflowFilename = "func-deploy.yaml" DefaultBranch = "main" DefaultWorkflowName = "Func Deploy" DefaultRemoteBuildWorkflowName = "Remote " + DefaultWorkflowName DefaultKubeconfigSecretName = "KUBECONFIG" DefaultRegistryLoginUrlVariableName = "REGISTRY_LOGIN_URL" DefaultRegistryUserVariableName = "REGISTRY_USERNAME" DefaultRegistryPassSecretName = "REGISTRY_PASSWORD" DefaultRegistryUrlVariableName = "REGISTRY_URL" DefaultRegistryLogin = true DefaultWorkflowDispatch = false DefaultRemoteBuild = false DefaultSelfHostedRunner = false DefaultTestStep = true DefaultForce = false DefaultVerbose = false )
Variables ¶
var DefaultWorkflowWriter = &fileWriter{}
DefaultWorkflowWriter is the default implementation for writing workflow files to disk.
var ErrWorkflowExists = errors.New("existing GitHub workflow detected, overwrite using the --force option")
ErrWorkflowExists is returned when a GitHub workflow file already exists and --force is not specified.
Functions ¶
func NewWorkflowGenerator ¶
func NewWorkflowGenerator(options ...Option) *workflowGenerator
NewWorkflowGenerator creates a workflow generator with sensible defaults: writes to disk via DefaultWorkflowWriter, prints to os.Stdout, and uses a full default WorkflowConfig. All defaults can be overridden via options. If WithWorkflowConfig is used, the provided config replaces the defaults and any empty string fields are backfilled with defaults.
func PrintConfiguration ¶
func PrintConfiguration(cfg WorkflowConfig, runtime string, w io.Writer) error
func PrintPostExportMessage ¶
func PrintPostExportMessage(opts WorkflowConfig, w io.Writer) error
Types ¶
type BufferWriter ¶
BufferWriter is a test double (fake) that implements WorkflowWriter by writing to an in-memory buffer instead of the filesystem.
func NewBufferWriter ¶
func NewBufferWriter() *BufferWriter
NewBufferWriter creates a new BufferWriter test double.
func (*BufferWriter) Exist ¶
func (bw *BufferWriter) Exist(_ string) bool
Exist is a fake implementation that returns true if the buffer has content.
type Option ¶
type Option func(*workflowGenerator)
Option configures a workflowGenerator.
func WithMessageWriter ¶
WithMessageWriter sets the writer used for user-facing messages.
func WithVerbose ¶
WithVerbose enables detailed configuration output after generation.
func WithWorkflowConfig ¶
func WithWorkflowConfig(wc WorkflowConfig) Option
WithWorkflowConfig overrides the default workflow configuration. Empty string fields are backfilled with defaults after all options are applied. Boolean fields are used as-is since their zero value (false) is indistinguishable from an explicit false.
func WithWorkflowWriter ¶
func WithWorkflowWriter(ww WorkflowWriter) Option
WithWorkflowWriter sets the writer used to persist the workflow file.
type WorkflowConfig ¶
type WorkflowConfig struct {
GithubWorkflowDir,
GithubWorkflowFilename,
Branch,
WorkflowName,
KubeconfigSecret,
RegistryLoginUrlVar,
RegistryUserVar,
RegistryPassSecret,
RegistryUrlVar string
RegistryLogin,
SelfHostedRunner,
RemoteBuild,
WorkflowDispatch,
TestStep,
Force bool
}
WorkflowConfig holds the settings for generating a GitHub Actions workflow.
type WorkflowGeneratorMock ¶
type WorkflowGeneratorMock struct {
WasInvoked bool // true after Generate is called
Config WorkflowConfig // captured config from factory
FnRoot string // captured function root from Generate
}
WorkflowGeneratorMock is a test double that records calls to Generate for assertion in tests.