github

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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
`
)
View Source
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

View Source
var DefaultWorkflowWriter = &fileWriter{}

DefaultWorkflowWriter is the default implementation for writing workflow files to disk.

View Source
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

type BufferWriter struct {
	Path   string
	Buffer *bytes.Buffer
}

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.

func (*BufferWriter) Write

func (bw *BufferWriter) Write(path string, raw []byte) error

Write is a fake implementation that stores content in the buffer.

type Option

type Option func(*workflowGenerator)

Option configures a workflowGenerator.

func WithMessageWriter

func WithMessageWriter(mw io.Writer) Option

WithMessageWriter sets the writer used for user-facing messages.

func WithVerbose

func WithVerbose(v bool) Option

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.

func (*WorkflowGeneratorMock) Generate

Generate implements fn.CIGenerator by recording the call.

type WorkflowWriter

type WorkflowWriter interface {
	Exist(path string) bool
	Write(path string, raw []byte) error
}

WorkflowWriter defines the interface for writing workflow files to a given path.

Jump to

Keyboard shortcuts

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