cmd

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 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

	// detect phase errors: 100-199
	CodeFailedDetect = 100 // CodeFailedDetect indicates that no buildpacks detected
	// CodeFailedDetectWithErrors indicated that no buildpacks detected and at least one errored
	CodeFailedDetectWithErrors = 101
	CodeDetectError            = 102 // CodeDetectError indicates generic detect error

	// analyze phase errors: 200-299
	CodeAnalyzeError = 202 // CodeAnalyzeError indicates generic analyze error

	// restore phase errors: 300-399
	CodeRestoreError = 302 // CodeRestoreError indicates generic restore error

	// build phase errors: 400-499
	CodeFailedBuildWithErrors = 401 // CodeFailedBuildWithErrors indicates buildpack error during /bin/build
	CodeBuildError            = 402 // CodeBuildError indicates generic build error

	// export phase errors: 500-599
	CodeExportError = 502 // CodeExportError indicates generic export error

	// rebase phase errors: 600-699
	CodeRebaseError = 602 // CodeRebaseError indicates generic rebase error

	// launch phase errors: 700-799
	CodeLaunchError = 702 // CodeLaunchError indicates generic launch error
)
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"
	EnvRegistryAuth        = "CNB_REGISTRY_AUTH"
	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 (
	DefaultAnalyzedPath        = filepath.Join(".", "analyzed.toml")
	DefaultAppDir              = filepath.Join(rootDir, "workspace")
	DefaultBuildpacksDir       = filepath.Join(rootDir, "cnb", "buildpacks")
	DefaultDeprecationMode     = DeprecationModeWarn
	DefaultGroupPath           = filepath.Join(".", "group.toml")
	DefaultLauncherPath        = filepath.Join(rootDir, "cnb", "lifecycle", "launcher"+execExt)
	DefaultLayersDir           = filepath.Join(rootDir, "layers")
	DefaultLogLevel            = "info"
	DefaultOrderPath           = filepath.Join(rootDir, "cnb", "order.toml")
	DefaultPlanPath            = filepath.Join(".", "plan.toml")
	DefaultPlatformAPI         = "0.3"
	DefaultPlatformDir         = filepath.Join(rootDir, "platform")
	DefaultProcessType         = "web"
	DefaultProjectMetadataPath = filepath.Join(".", "project-metadata.toml")
	DefaultReportPath          = filepath.Join(".", "report.toml")
	DefaultStackPath           = filepath.Join(rootDir, "cnb", "stack.toml")
)
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.

View Source
var (
	DefaultLogger = &Logger{
		&log.Logger{
			Handler: &handler{
				writer: os.Stdout,
			},
		},
	}
)

Functions

func BoolEnv added in v0.9.0

func BoolEnv(k string) bool

func DeprecatedFlagRunImage added in v0.7.0

func DeprecatedFlagRunImage(image *string)

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(dir *string)

func FlagAppDir

func FlagAppDir(dir *string)

func FlagBuildpacksDir

func FlagBuildpacksDir(dir *string)

func FlagCacheDir

func FlagCacheDir(dir *string)

func FlagCacheImage

func FlagCacheImage(image *string)

func FlagGID

func FlagGID(gid *int)

func FlagGroupPath

func FlagGroupPath(path *string)

func FlagLaunchCacheDir

func FlagLaunchCacheDir(dir *string)

func FlagLauncherPath

func FlagLauncherPath(path *string)

func FlagLayersDir

func FlagLayersDir(dir *string)

func FlagLogLevel

func FlagLogLevel(level *string)

func FlagNoColor added in v0.9.0

func FlagNoColor(skip *bool)

func FlagOrderPath

func FlagOrderPath(path *string)

func FlagPlanPath

func FlagPlanPath(path *string)

func FlagPlatformDir

func FlagPlatformDir(dir *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(path *string)

func FlagRunImage

func FlagRunImage(image *string)

func FlagSkipLayers

func FlagSkipLayers(skip *bool)

func FlagSkipRestore added in v0.7.0

func FlagSkipRestore(skip *bool)

func FlagStackPath

func FlagStackPath(path *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 {
	Init()
	Args(nargs int, args []string) error
	Privileges() error
	Exec() error
}

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