cmd

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// lifecycle errors not specific to any phase: 1-99
	CodeFailed = 1 // CodeFailed indicates generic lifecycle error
	// 2: reserved
	CodeInvalidArgs = 3

	// API errors
	CodeIncompatiblePlatformAPI  = 11
	CodeIncompatibleBuildpackAPI = 12
)
View Source
const (
	EnvAnalyzedPath        = "CNB_ANALYZED_PATH"
	EnvAppDir              = "CNB_APP_DIR"
	EnvBuildpacksDir       = "CNB_BUILDPACKS_DIR"
	EnvCacheDir            = "CNB_CACHE_DIR"
	EnvCacheImage          = "CNB_CACHE_IMAGE"
	EnvDeprecationMode     = "CNB_DEPRECATION_MODE"
	EnvGID                 = "CNB_GROUP_ID"
	EnvGroupPath           = "CNB_GROUP_PATH"
	EnvLaunchCacheDir      = "CNB_LAUNCH_CACHE_DIR"
	EnvLayersDir           = "CNB_LAYERS_DIR"
	EnvLogLevel            = "CNB_LOG_LEVEL"
	EnvNoColor             = "CNB_NO_COLOR" // defaults to false
	EnvOrderPath           = "CNB_ORDER_PATH"
	EnvPlanPath            = "CNB_PLAN_PATH"
	EnvPlatformAPI         = "CNB_PLATFORM_API"
	EnvPlatformDir         = "CNB_PLATFORM_DIR"
	EnvPreviousImage       = "CNB_PREVIOUS_IMAGE"
	EnvProcessType         = "CNB_PROCESS_TYPE"
	EnvProjectMetadataPath = "CNB_PROJECT_METADATA_PATH"
	EnvReportPath          = "CNB_REPORT_PATH"
	EnvRunImage            = "CNB_RUN_IMAGE"
	EnvSkipLayers          = "CNB_ANALYZE_SKIP_LAYERS" // defaults to false
	EnvSkipRestore         = "CNB_SKIP_RESTORE"        // defaults to false
	EnvStackPath           = "CNB_STACK_PATH"
	EnvUID                 = "CNB_USER_ID"
	EnvUseDaemon           = "CNB_USE_DAEMON" // defaults to false
)
View Source
const (
	DeprecationModeQuiet = "quiet"
	DeprecationModeWarn  = "warn"
	DeprecationModeError = "error"
)

Variables

View Source
var (
	DefaultAppDir          = filepath.Join(rootDir, "workspace")
	DefaultBuildpacksDir   = filepath.Join(rootDir, "cnb", "buildpacks")
	DefaultDeprecationMode = DeprecationModeWarn
	DefaultLauncherPath    = filepath.Join(rootDir, "cnb", "lifecycle", "launcher"+execExt)
	DefaultLayersDir       = filepath.Join(rootDir, "layers")
	DefaultLogLevel        = "info"
	DefaultPlatformAPI     = "0.3"
	DefaultPlatformDir     = filepath.Join(rootDir, "platform")
	DefaultProcessType     = "web"
	DefaultStackPath       = filepath.Join(rootDir, "cnb", "stack.toml")

	DefaultAnalyzedFile        = "analyzed.toml"
	DefaultGroupFile           = "group.toml"
	DefaultOrderFile           = "order.toml"
	DefaultPlanFile            = "plan.toml"
	DefaultProjectMetadataFile = "project-metadata.toml"
	DefaultReportFile          = "report.toml"

	PlaceholderAnalyzedPath        = filepath.Join("<layers>", DefaultAnalyzedFile)
	PlaceholderGroupPath           = filepath.Join("<layers>", DefaultGroupFile)
	PlaceholderPlanPath            = filepath.Join("<layers>", DefaultPlanFile)
	PlaceholderProjectMetadataPath = filepath.Join("<layers>", DefaultProjectMetadataFile)
	PlaceholderReportPath          = filepath.Join("<layers>", DefaultReportFile)
	PlaceholderOrderPath           = filepath.Join("<layers>", DefaultOrderFile)
)
View Source
var (
	DefaultLogger = &Logger{
		&log.Logger{
			Handler: &handler{
				writer: Stdout,
			},
		},
	}
	Stdout = color.NewConsole(os.Stdout)
	Stderr = color.NewConsole(os.Stderr)
)
View Source
var (
	// Version is the version of the lifecycle and all produced binaries.
	Version = "0.0.0"
	// SCMCommit is the commit information provided by SCM.
	SCMCommit = ""
	// SCMRepository is the source repository.
	SCMRepository = ""

	DeprecationMode = EnvOrDefault(EnvDeprecationMode, DefaultDeprecationMode)
)

The following variables are injected at compile time.

Functions

func BoolEnv added in v0.9.0

func BoolEnv(k string) bool

func DefaultAnalyzedPath

func DefaultAnalyzedPath(platformAPI, layersDir string) string

func DefaultGroupPath

func DefaultGroupPath(platformAPI, layersDir string) string

func DefaultOrderPath

func DefaultOrderPath(platformAPI, layersDir string) string

func DefaultPlanPath

func DefaultPlanPath(platformAPI, layersDir string) string

func DefaultProjectMetadataPath added in v0.7.0

func DefaultProjectMetadataPath(platformAPI, layersDir string) string

func DefaultReportPath added in v0.9.0

func DefaultReportPath(platformAPI, layersDir string) string

func DeprecatedFlagRunImage added in v0.7.0

func DeprecatedFlagRunImage(image *string)

func DisableColor added in v0.9.2

func DisableColor(noColor bool)

func EnvOrDefault added in v0.9.0

func EnvOrDefault(key string, defaultVal string) string

func Exit

func Exit(err error)

func ExitWithVersion

func ExitWithVersion()

func FlagAnalyzedPath

func FlagAnalyzedPath(analyzedPath *string)

func FlagAppDir

func FlagAppDir(appDir *string)

func FlagBuildpacksDir

func FlagBuildpacksDir(buildpacksDir *string)

func FlagCacheDir

func FlagCacheDir(cacheDir *string)

func FlagCacheImage

func FlagCacheImage(cacheImage *string)

func FlagGID

func FlagGID(gid *int)

func FlagGroupPath

func FlagGroupPath(groupPath *string)

func FlagLaunchCacheDir

func FlagLaunchCacheDir(launchCacheDir *string)

func FlagLauncherPath

func FlagLauncherPath(launcherPath *string)

func FlagLayersDir

func FlagLayersDir(layersDir *string)

func FlagLogLevel

func FlagLogLevel(level *string)

func FlagNoColor added in v0.9.0

func FlagNoColor(skip *bool)

func FlagOrderPath

func FlagOrderPath(orderPath *string)

func FlagPlanPath

func FlagPlanPath(planPath *string)

func FlagPlatformDir

func FlagPlatformDir(platformDir *string)

func FlagPreviousImage added in v0.7.0

func FlagPreviousImage(image *string)

func FlagProcessType added in v0.7.0

func FlagProcessType(processType *string)

func FlagProjectMetadataPath added in v0.7.0

func FlagProjectMetadataPath(projectMetadataPath *string)

func FlagReportPath added in v0.9.0

func FlagReportPath(reportPath *string)

func FlagRunImage

func FlagRunImage(runImage *string)

func FlagSkipLayers

func FlagSkipLayers(skip *bool)

func FlagSkipRestore added in v0.7.0

func FlagSkipRestore(skip *bool)

func FlagStackPath

func FlagStackPath(stackPath *string)

func FlagTags added in v0.7.0

func FlagTags(tags *StringSlice)

func FlagUID

func FlagUID(uid *int)

func FlagUseDaemon

func FlagUseDaemon(use *bool)

func FlagVersion

func FlagVersion(version *bool)

func Run added in v0.7.0

func Run(c Command, asSubcommand bool)

func VerifyBuildpackAPI added in v0.9.0

func VerifyBuildpackAPI(bp string, requested string) error

func VerifyPlatformAPI added in v0.9.0

func VerifyPlatformAPI(requested string) error

Types

type Command added in v0.7.0

type Command interface {
	// DefineFlags defines the flags that are considered valid and reads their values (if provided)
	DefineFlags()

	// Args validates arguments and flags, and fills in default values
	Args(nargs int, args []string) error

	// Privileges validates the needed privileges
	Privileges() error

	// Exec executes the command
	Exec() error
}

Command defines the interface for running the lifecycle phases

type ErrorFail

type ErrorFail struct {
	Err    error
	Code   int
	Action []string
}

func FailCode

func FailCode(code int, action ...string) *ErrorFail

func FailErr

func FailErr(err error, action ...string) *ErrorFail

func FailErrCode

func FailErrCode(err error, code int, action ...string) *ErrorFail

func SetLogLevel

func SetLogLevel(level string) *ErrorFail

func (*ErrorFail) Error

func (e *ErrorFail) Error() string

type Logger

type Logger struct {
	*log.Logger
}

func (*Logger) Phase added in v0.9.0

func (l *Logger) Phase(name string)

type StringSlice added in v0.7.0

type StringSlice []string

func (*StringSlice) Set added in v0.7.0

func (s *StringSlice) Set(value string) error

func (*StringSlice) String added in v0.7.0

func (s *StringSlice) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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