Documentation ¶
Index ¶
Constants ¶
View Source
const ( Name = "profile" Usage = "Collects fat image information and generates a fat container report" Alias = "p" )
Variables ¶
View Source
var CLI = &cli.Command{ Name: Name, Aliases: []string{Alias}, Usage: Usage, Flags: []cli.Flag{ commands.Cflag(commands.FlagTarget), commands.Cflag(commands.FlagPull), commands.Cflag(commands.FlagDockerConfigPath), commands.Cflag(commands.FlagRegistryAccount), commands.Cflag(commands.FlagRegistrySecret), commands.Cflag(commands.FlagShowPullLogs), commands.Cflag(commands.FlagComposeFile), commands.Cflag(commands.FlagTargetComposeSvc), commands.Cflag(commands.FlagComposeSvcNoPorts), commands.Cflag(commands.FlagDepExcludeComposeSvcAll), commands.Cflag(commands.FlagDepIncludeComposeSvc), commands.Cflag(commands.FlagDepExcludeComposeSvc), commands.Cflag(commands.FlagDepIncludeComposeSvcDeps), commands.Cflag(commands.FlagDepIncludeTargetComposeSvcDeps), commands.Cflag(commands.FlagComposeNet), commands.Cflag(commands.FlagComposeEnvNoHost), commands.Cflag(commands.FlagComposeEnvFile), commands.Cflag(commands.FlagComposeProjectName), commands.Cflag(commands.FlagComposeWorkdir), commands.Cflag(commands.FlagHTTPProbeOff), commands.Cflag(commands.FlagHTTPProbe), commands.Cflag(commands.FlagHTTPProbeCmd), commands.Cflag(commands.FlagHTTPProbeCmdFile), commands.Cflag(commands.FlagHTTPProbeStartWait), commands.Cflag(commands.FlagHTTPProbeRetryCount), commands.Cflag(commands.FlagHTTPProbeRetryWait), commands.Cflag(commands.FlagHTTPProbePorts), commands.Cflag(commands.FlagHTTPProbeFull), commands.Cflag(commands.FlagHTTPProbeExitOnFailure), commands.Cflag(commands.FlagHTTPProbeCrawl), commands.Cflag(commands.FlagHTTPCrawlMaxDepth), commands.Cflag(commands.FlagHTTPCrawlMaxPageCount), commands.Cflag(commands.FlagHTTPCrawlConcurrency), commands.Cflag(commands.FlagHTTPMaxConcurrentCrawlers), commands.Cflag(commands.FlagHTTPProbeAPISpec), commands.Cflag(commands.FlagHTTPProbeAPISpecFile), commands.Cflag(commands.FlagHTTPProbeExec), commands.Cflag(commands.FlagHTTPProbeExecFile), commands.Cflag(commands.FlagPublishPort), commands.Cflag(commands.FlagPublishExposedPorts), commands.Cflag(commands.FlagRunTargetAsUser), commands.Cflag(commands.FlagShowContainerLogs), commands.Cflag(commands.FlagCopyMetaArtifacts), commands.Cflag(commands.FlagRemoveFileArtifacts), commands.Cflag(commands.FlagExec), commands.Cflag(commands.FlagExecFile), commands.Cflag(commands.FlagCRORuntime), commands.Cflag(commands.FlagCROHostConfigFile), commands.Cflag(commands.FlagCROSysctl), commands.Cflag(commands.FlagCROShmSize), commands.Cflag(commands.FlagUser), commands.Cflag(commands.FlagEntrypoint), commands.Cflag(commands.FlagCmd), commands.Cflag(commands.FlagWorkdir), commands.Cflag(commands.FlagEnv), commands.Cflag(commands.FlagLabel), commands.Cflag(commands.FlagVolume), commands.Cflag(commands.FlagLink), commands.Cflag(commands.FlagEtcHostsMap), commands.Cflag(commands.FlagContainerDNS), commands.Cflag(commands.FlagContainerDNSSearch), commands.Cflag(commands.FlagNetwork), commands.Cflag(commands.FlagHostname), commands.Cflag(commands.FlagExpose), commands.Cflag(commands.FlagExcludeMounts), commands.Cflag(commands.FlagExcludePattern), commands.Cflag(commands.FlagMount), commands.Cflag(commands.FlagContinueAfter), commands.Cflag(commands.FlagUseLocalMounts), commands.Cflag(commands.FlagUseSensorVolume), commands.Cflag(commands.FlagSensorIPCEndpoint), commands.Cflag(commands.FlagSensorIPCMode), }, Action: func(ctx *cli.Context) error { xc := app.NewExecutionContext(Name) targetRef := ctx.String(commands.FlagTarget) if targetRef == "" { if ctx.Args().Len() < 1 { xc.Out.Error("param.target", "missing target image ID/name") cli.ShowCommandHelp(ctx, Name) return nil } else { targetRef = ctx.Args().First() } } gcvalues, err := commands.GlobalFlagValues(ctx) if err != nil { return err } crOpts, err := commands.GetContainerRunOptions(ctx) if err != nil { xc.Out.Error("param.error.container.run.options", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } doPull := ctx.Bool(commands.FlagPull) dockerConfigPath := ctx.String(commands.FlagDockerConfigPath) registryAccount := ctx.String(commands.FlagRegistryAccount) registrySecret := ctx.String(commands.FlagRegistrySecret) doShowPullLogs := ctx.Bool(commands.FlagShowPullLogs) doRmFileArtifacts := ctx.Bool(commands.FlagRemoveFileArtifacts) doCopyMetaArtifacts := ctx.String(commands.FlagCopyMetaArtifacts) portBindings, err := commands.ParsePortBindings(ctx.StringSlice(commands.FlagPublishPort)) if err != nil { xc.Out.Error("param.publish.port", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } doPublishExposedPorts := ctx.Bool(commands.FlagPublishExposedPorts) httpCrawlMaxDepth := ctx.Int(commands.FlagHTTPCrawlMaxDepth) httpCrawlMaxPageCount := ctx.Int(commands.FlagHTTPCrawlMaxPageCount) httpCrawlConcurrency := ctx.Int(commands.FlagHTTPCrawlConcurrency) httpMaxConcurrentCrawlers := ctx.Int(commands.FlagHTTPMaxConcurrentCrawlers) doHTTPProbeCrawl := ctx.Bool(commands.FlagHTTPProbeCrawl) doHTTPProbe := ctx.Bool(commands.FlagHTTPProbe) if doHTTPProbe && ctx.Bool(commands.FlagHTTPProbeOff) { doHTTPProbe = false } httpProbeCmds, err := commands.GetHTTPProbes(ctx) if err != nil { xc.Out.Error("param.http.probe", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } if doHTTPProbe { xc.Out.Info("param.http.probe", ovars{ "message": "using default probe", }) defaultCmd := config.HTTPProbeCmd{ Protocol: "http", Method: "GET", Resource: "/", } if doHTTPProbeCrawl { defaultCmd.Crawl = true } httpProbeCmds = append(httpProbeCmds, defaultCmd) } if len(httpProbeCmds) > 0 { doHTTPProbe = true } httpProbeStartWait := ctx.Int(commands.FlagHTTPProbeStartWait) httpProbeRetryCount := ctx.Int(commands.FlagHTTPProbeRetryCount) httpProbeRetryWait := ctx.Int(commands.FlagHTTPProbeRetryWait) httpProbePorts, err := commands.ParseHTTPProbesPorts(ctx.String(commands.FlagHTTPProbePorts)) if err != nil { xc.Out.Error("param.http.probe.ports", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } doHTTPProbeFull := ctx.Bool(commands.FlagHTTPProbeFull) doHTTPProbeExitOnFailure := ctx.Bool(commands.FlagHTTPProbeExitOnFailure) httpProbeAPISpecs := ctx.StringSlice(commands.FlagHTTPProbeAPISpec) if len(httpProbeAPISpecs) > 0 { doHTTPProbe = true } httpProbeAPISpecFiles, fileErrors := commands.ValidateFiles(ctx.StringSlice(commands.FlagHTTPProbeAPISpecFile)) if len(fileErrors) > 0 { var err error for k, v := range fileErrors { err = v xc.Out.Info("error", ovars{ "file": k, "error": err, }) xc.Out.Error("param.error.http.api.spec.file", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } return err } if len(httpProbeAPISpecFiles) > 0 { doHTTPProbe = true } httpProbeApps := ctx.StringSlice(commands.FlagHTTPProbeExec) moreProbeApps, err := commands.ParseHTTPProbeExecFile(ctx.String(commands.FlagHTTPProbeExecFile)) if err != nil { xc.Out.Error("param.http.probe.exec.file", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } if len(moreProbeApps) > 0 { httpProbeApps = append(httpProbeApps, moreProbeApps...) } doRunTargetAsUser := ctx.Bool(commands.FlagRunTargetAsUser) doShowContainerLogs := ctx.Bool(commands.FlagShowContainerLogs) overrides, err := commands.GetContainerOverrides(ctx) if err != nil { xc.Out.Error("param.error.container.overrides", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } volumeMounts, err := commands.ParseVolumeMounts(ctx.StringSlice(commands.FlagMount)) if err != nil { xc.Out.Error("param.error.mount", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } excludePatterns := commands.ParsePaths(ctx.StringSlice(commands.FlagExcludePattern)) doUseLocalMounts := ctx.Bool(commands.FlagUseLocalMounts) doUseSensorVolume := ctx.String(commands.FlagUseSensorVolume) doExcludeMounts := ctx.Bool(commands.FlagExcludeMounts) if doExcludeMounts { for mpath := range volumeMounts { excludePatterns[mpath] = nil mpattern := fmt.Sprintf("%s/**", mpath) excludePatterns[mpattern] = nil } } continueAfter, err := commands.GetContinueAfter(ctx) if err != nil { xc.Out.Error("param.error.continue.after", err.Error()) xc.Out.State("exited", ovars{ "exit.code": -1, }) xc.Exit(-1) } if !doHTTPProbe && continueAfter.Mode == "probe" { continueAfter.Mode = "enter" xc.Out.Info("enter", ovars{ "message": "changing continue-after from probe to enter because http-probe is disabled", }) } commandReport := ctx.String(commands.FlagCommandReport) if commandReport == "off" { commandReport = "" } OnCommand( xc, gcvalues, targetRef, doPull, dockerConfigPath, registryAccount, registrySecret, doShowPullLogs, crOpts, doHTTPProbe, httpProbeCmds, httpProbeStartWait, httpProbeRetryCount, httpProbeRetryWait, httpProbePorts, httpCrawlMaxDepth, httpCrawlMaxPageCount, httpCrawlConcurrency, httpMaxConcurrentCrawlers, doHTTPProbeFull, doHTTPProbeExitOnFailure, httpProbeAPISpecs, httpProbeAPISpecFiles, httpProbeApps, portBindings, doPublishExposedPorts, doRmFileArtifacts, doCopyMetaArtifacts, doRunTargetAsUser, doShowContainerLogs, overrides, ctx.StringSlice(commands.FlagLink), ctx.StringSlice(commands.FlagEtcHostsMap), ctx.StringSlice(commands.FlagContainerDNS), ctx.StringSlice(commands.FlagContainerDNSSearch), volumeMounts, excludePatterns, doUseLocalMounts, doUseSensorVolume, continueAfter, ctx.String(commands.FlagSensorIPCEndpoint), ctx.String(commands.FlagSensorIPCMode), ctx.String(commands.FlagLogLevel), ctx.String(commands.FlagLogFormat)) return nil }, }
View Source
var CommandFlagSuggestions = &commands.FlagSuggestions{ Names: []prompt.Suggest{ {Text: commands.FullFlagName(commands.FlagTarget), Description: commands.FlagTargetUsage}, {Text: commands.FullFlagName(commands.FlagPull), Description: commands.FlagPullUsage}, {Text: commands.FullFlagName(commands.FlagShowPullLogs), Description: commands.FlagShowPullLogsUsage}, {Text: commands.FullFlagName(commands.FlagShowContainerLogs), Description: commands.FlagShowContainerLogsUsage}, {Text: commands.FullFlagName(commands.FlagCRORuntime), Description: commands.FlagCRORuntimeUsage}, {Text: commands.FullFlagName(commands.FlagCROHostConfigFile), Description: commands.FlagCROHostConfigFileUsage}, {Text: commands.FullFlagName(commands.FlagCROSysctl), Description: commands.FlagCROSysctlUsage}, {Text: commands.FullFlagName(commands.FlagCROShmSize), Description: commands.FlagCROShmSizeUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeOff), Description: commands.FlagHTTPProbeOffUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbe), Description: commands.FlagHTTPProbeUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeCmd), Description: commands.FlagHTTPProbeCmdUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeCmdFile), Description: commands.FlagHTTPProbeCmdFileUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeStartWait), Description: commands.FlagHTTPProbeStartWaitUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeRetryCount), Description: commands.FlagHTTPProbeRetryCountUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeRetryWait), Description: commands.FlagHTTPProbeRetryWaitUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbePorts), Description: commands.FlagHTTPProbePortsUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeFull), Description: commands.FlagHTTPProbeFullUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeExitOnFailure), Description: commands.FlagHTTPProbeExitOnFailureUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeCrawl), Description: commands.FlagHTTPProbeCrawlUsage}, {Text: commands.FullFlagName(commands.FlagHTTPCrawlMaxDepth), Description: commands.FlagHTTPCrawlMaxDepthUsage}, {Text: commands.FullFlagName(commands.FlagHTTPCrawlMaxPageCount), Description: commands.FlagHTTPCrawlMaxPageCountUsage}, {Text: commands.FullFlagName(commands.FlagHTTPCrawlConcurrency), Description: commands.FlagHTTPCrawlConcurrencyUsage}, {Text: commands.FullFlagName(commands.FlagHTTPMaxConcurrentCrawlers), Description: commands.FlagHTTPMaxConcurrentCrawlersUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeAPISpec), Description: commands.FlagHTTPProbeAPISpecUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeAPISpecFile), Description: commands.FlagHTTPProbeAPISpecFileUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeExec), Description: commands.FlagHTTPProbeExecUsage}, {Text: commands.FullFlagName(commands.FlagHTTPProbeExecFile), Description: commands.FlagHTTPProbeExecFileUsage}, {Text: commands.FullFlagName(commands.FlagPublishPort), Description: commands.FlagPublishPortUsage}, {Text: commands.FullFlagName(commands.FlagPublishExposedPorts), Description: commands.FlagPublishExposedPortsUsage}, {Text: commands.FullFlagName(commands.FlagRunTargetAsUser), Description: commands.FlagRunTargetAsUserUsage}, {Text: commands.FullFlagName(commands.FlagCopyMetaArtifacts), Description: commands.FlagCopyMetaArtifactsUsage}, {Text: commands.FullFlagName(commands.FlagRemoveFileArtifacts), Description: commands.FlagRemoveFileArtifactsUsage}, {Text: commands.FullFlagName(commands.FlagUser), Description: commands.FlagUserUsage}, {Text: commands.FullFlagName(commands.FlagEntrypoint), Description: commands.FlagEntrypointUsage}, {Text: commands.FullFlagName(commands.FlagCmd), Description: commands.FlagCmdUsage}, {Text: commands.FullFlagName(commands.FlagWorkdir), Description: commands.FlagWorkdirUsage}, {Text: commands.FullFlagName(commands.FlagEnv), Description: commands.FlagEnvUsage}, {Text: commands.FullFlagName(commands.FlagLabel), Description: commands.FlagLabelUsage}, {Text: commands.FullFlagName(commands.FlagVolume), Description: commands.FlagVolumeUsage}, {Text: commands.FullFlagName(commands.FlagLink), Description: commands.FlagLinkUsage}, {Text: commands.FullFlagName(commands.FlagEtcHostsMap), Description: commands.FlagEtcHostsMapUsage}, {Text: commands.FullFlagName(commands.FlagContainerDNS), Description: commands.FlagContainerDNSUsage}, {Text: commands.FullFlagName(commands.FlagContainerDNSSearch), Description: commands.FlagContainerDNSSearchUsage}, {Text: commands.FullFlagName(commands.FlagNetwork), Description: commands.FlagNetworkUsage}, {Text: commands.FullFlagName(commands.FlagHostname), Description: commands.FlagHostnameUsage}, {Text: commands.FullFlagName(commands.FlagExpose), Description: commands.FlagExposeUsage}, {Text: commands.FullFlagName(commands.FlagExcludeMounts), Description: commands.FlagExcludeMountsUsage}, {Text: commands.FullFlagName(commands.FlagExcludePattern), Description: commands.FlagExcludePatternUsage}, {Text: commands.FullFlagName(commands.FlagMount), Description: commands.FlagMountUsage}, {Text: commands.FullFlagName(commands.FlagContinueAfter), Description: commands.FlagContinueAfterUsage}, {Text: commands.FullFlagName(commands.FlagUseLocalMounts), Description: commands.FlagUseLocalMountsUsage}, {Text: commands.FullFlagName(commands.FlagUseSensorVolume), Description: commands.FlagUseSensorVolumeUsage}, {Text: commands.FullFlagName(commands.FlagSensorIPCMode), Description: commands.FlagSensorIPCModeUsage}, {Text: commands.FullFlagName(commands.FlagSensorIPCEndpoint), Description: commands.FlagSensorIPCEndpointUsage}, }, Values: map[string]commands.CompleteValue{ commands.FullFlagName(commands.FlagPull): commands.CompleteBool, commands.FullFlagName(commands.FlagShowPullLogs): commands.CompleteBool, commands.FullFlagName(commands.FlagTarget): commands.CompleteTarget, commands.FullFlagName(commands.FlagShowContainerLogs): commands.CompleteBool, commands.FullFlagName(commands.FlagPublishExposedPorts): commands.CompleteBool, commands.FullFlagName(commands.FlagHTTPProbeOff): commands.CompleteBool, commands.FullFlagName(commands.FlagHTTPProbe): commands.CompleteTBool, commands.FullFlagName(commands.FlagHTTPProbeCmdFile): commands.CompleteFile, commands.FullFlagName(commands.FlagHTTPProbeExecFile): commands.CompleteFile, commands.FullFlagName(commands.FlagHTTPProbeFull): commands.CompleteBool, commands.FullFlagName(commands.FlagHTTPProbeExitOnFailure): commands.CompleteTBool, commands.FullFlagName(commands.FlagHTTPProbeCrawl): commands.CompleteTBool, commands.FullFlagName(commands.FlagHTTPProbeAPISpecFile): commands.CompleteFile, commands.FullFlagName(commands.FlagRunTargetAsUser): commands.CompleteTBool, commands.FullFlagName(commands.FlagRemoveFileArtifacts): commands.CompleteBool, commands.FullFlagName(commands.FlagNetwork): commands.CompleteNetwork, commands.FullFlagName(commands.FlagExcludeMounts): commands.CompleteTBool, commands.FullFlagName(commands.FlagContinueAfter): commands.CompleteContinueAfter, commands.FullFlagName(commands.FlagUseLocalMounts): commands.CompleteBool, commands.FullFlagName(commands.FlagUseSensorVolume): commands.CompleteVolume, commands.FullFlagName(commands.FlagCROHostConfigFile): commands.CompleteFile, commands.FullFlagName(commands.FlagSensorIPCMode): commands.CompleteIPCMode, }, }
View Source
var CommandSuggestion = prompt.Suggest{ Text: Name, Description: Usage, }
Functions ¶
func OnCommand ¶
func OnCommand( xc *app.ExecutionContext, gparams *commands.GenericParams, targetRef string, doPull bool, dockerConfigPath string, registryAccount string, registrySecret string, doShowPullLogs bool, crOpts *config.ContainerRunOptions, doHTTPProbe bool, httpProbeCmds []config.HTTPProbeCmd, httpProbeStartWait int, httpProbeRetryCount int, httpProbeRetryWait int, httpProbePorts []uint16, httpCrawlMaxDepth int, httpCrawlMaxPageCount int, httpCrawlConcurrency int, httpMaxConcurrentCrawlers int, doHTTPProbeFull bool, doHTTPProbeExitOnFailure bool, httpProbeAPISpecs []string, httpProbeAPISpecFiles []string, httpProbeApps []string, portBindings map[docker.Port][]docker.PortBinding, doPublishExposedPorts bool, doRmFileArtifacts bool, copyMetaArtifactsLocation string, doRunTargetAsUser bool, doShowContainerLogs bool, overrides *config.ContainerOverrides, links []string, etcHostsMaps []string, dnsServers []string, dnsSearchDomains []string, explicitVolumeMounts map[string]config.VolumeMount, excludePatterns map[string]*fsutil.AccessInfo, doUseLocalMounts bool, doUseSensorVolume string, continueAfter *config.ContinueAfter, sensorIPCEndpoint string, sensorIPCMode string, logLevel string, logFormat string)
OnCommand implements the 'profile' docker-slim command
func RegisterCommand ¶
func RegisterCommand()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.