1 Star 0 Fork 0

叮当他爸 / source-to-image

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 20.32 KB
一键复制 编辑 原始数据 按行查看 历史
Jim Minter 提交于 2017-04-25 15:00 . use only one engine client instance
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
package main
import (
"bytes"
"flag"
"fmt"
"io"
"math/rand"
"os"
"path/filepath"
"runtime"
"strings"
"time"
log "github.com/golang/glog"
utilglog "github.com/openshift/source-to-image/pkg/util/glog"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/openshift/source-to-image/pkg/api"
"github.com/openshift/source-to-image/pkg/api/describe"
"github.com/openshift/source-to-image/pkg/api/validation"
"github.com/openshift/source-to-image/pkg/build"
"github.com/openshift/source-to-image/pkg/build/strategies"
"github.com/openshift/source-to-image/pkg/build/strategies/sti"
cmdutil "github.com/openshift/source-to-image/pkg/cmd"
"github.com/openshift/source-to-image/pkg/config"
"github.com/openshift/source-to-image/pkg/create"
"github.com/openshift/source-to-image/pkg/docker"
s2ierr "github.com/openshift/source-to-image/pkg/errors"
"github.com/openshift/source-to-image/pkg/run"
"github.com/openshift/source-to-image/pkg/tar"
"github.com/openshift/source-to-image/pkg/util"
"github.com/openshift/source-to-image/pkg/version"
)
// glog is a placeholder until the builders pass an output stream down
// client facing libraries should not be using glog
var glog = utilglog.StderrLog
func newCmdVersion() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Display version",
Long: "Display version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("s2i %v\n", version.Get())
},
}
}
func newCmdBuild(cfg *api.Config) *cobra.Command {
useConfig := false
oldScriptsFlag := ""
oldDestination := ""
buildCmd := &cobra.Command{
Use: "build <source> <image> [<tag>]",
Short: "Build a new image",
Long: "Build a new Docker image named <tag> (if provided) from a source repository and base image.",
Example: `
# Build a Docker image from a remote Git repository
$ s2i build https://github.com/openshift/ruby-hello-world centos/ruby-22-centos7 hello-world-app
# Build from a local directory
$ s2i build . centos/ruby-22-centos7 hello-world-app
`,
Run: func(cmd *cobra.Command, args []string) {
glog.V(1).Infof("Running S2I version %q\n", version.Get())
// Attempt to restore the build command from the configuration file
if useConfig {
config.Restore(cfg, cmd)
}
// If user specifies the arguments, then we override the stored ones
if len(args) >= 2 {
cfg.Source = args[0]
cfg.BuilderImage = args[1]
if len(args) >= 3 {
cfg.Tag = args[2]
}
}
if cfg.Incremental && len(cfg.RuntimeImage) > 0 {
fmt.Fprintln(os.Stderr, "ERROR: Incremental build with runtime image isn't supported")
os.Exit(1)
}
//set default image pull policy
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
if len(cfg.RuntimeImagePullPolicy) == 0 {
cfg.RuntimeImagePullPolicy = api.DefaultRuntimeImagePullPolicy
}
if errs := validation.ValidateConfig(cfg); len(errs) > 0 {
for _, e := range errs {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", e)
}
fmt.Println()
cmd.Help()
os.Exit(1)
}
// Persists the current command line options and config into .s2ifile
if useConfig {
config.Save(cfg, cmd)
}
// Attempt to read the .dockercfg and extract the authentication for
// docker pull
if r, err := os.Open(cfg.DockerCfgPath); err == nil {
defer r.Close()
auths := docker.LoadImageRegistryAuth(r)
cfg.PullAuthentication = docker.GetImageRegistryAuth(auths, cfg.BuilderImage)
if cfg.Incremental {
cfg.IncrementalAuthentication = docker.GetImageRegistryAuth(auths, cfg.Tag)
}
if len(cfg.RuntimeImage) > 0 {
cfg.RuntimeAuthentication = docker.GetImageRegistryAuth(auths, cfg.RuntimeImage)
}
}
if len(cfg.EnvironmentFile) > 0 {
result, err := util.ReadEnvironmentFile(cfg.EnvironmentFile)
if err != nil {
glog.Warningf("Unable to read environment file %q: %v", cfg.EnvironmentFile, err)
} else {
for name, value := range result {
cfg.Environment = append(cfg.Environment, api.EnvironmentSpec{Name: name, Value: value})
}
}
}
if len(oldScriptsFlag) != 0 {
glog.Warning("DEPRECATED: Flag --scripts is deprecated, use --scripts-url instead")
cfg.ScriptsURL = oldScriptsFlag
}
if len(oldDestination) != 0 {
glog.Warning("DEPRECATED: Flag --location is deprecated, use --destination instead")
cfg.Destination = oldDestination
}
client, err := docker.NewEngineAPIClient(cfg.DockerConfig)
if err != nil {
glog.Fatal(err)
}
d := docker.New(client, cfg.PullAuthentication)
err = d.CheckReachable()
if err != nil {
glog.Fatal(err)
}
glog.V(2).Infof("\n%s\n", describe.Config(client, cfg))
builder, _, err := strategies.GetStrategy(client, cfg)
s2ierr.CheckError(err)
result, err := builder.Build(cfg)
if err != nil {
glog.V(0).Infof("Build failed")
s2ierr.CheckError(err)
} else {
glog.V(0).Infof("Build completed successfully")
}
for _, message := range result.Messages {
glog.V(1).Infof(message)
}
if cfg.RunImage {
runner := run.New(client, cfg)
err = runner.Run(cfg)
s2ierr.CheckError(err)
}
},
}
cmdutil.AddCommonFlags(buildCmd, cfg)
buildCmd.Flags().BoolVar(&(cfg.RunImage), "run", false, "Run resulting image as part of invocation of this command")
buildCmd.Flags().BoolVar(&(cfg.IgnoreSubmodules), "ignore-submodules", false, "Ignore all git submodules when cloning application repository")
buildCmd.Flags().VarP(&(cfg.Environment), "env", "e", "Specify an single environment variable in NAME=VALUE format")
buildCmd.Flags().StringVarP(&(cfg.Ref), "ref", "r", "", "Specify a ref to check-out")
buildCmd.Flags().StringVarP(&(cfg.AssembleUser), "assemble-user", "", "", "Specify the user to run assemble with")
buildCmd.Flags().StringVarP(&(cfg.ContextDir), "context-dir", "", "", "Specify the sub-directory inside the repository with the application sources")
buildCmd.Flags().StringVarP(&(cfg.ExcludeRegExp), "exclude", "", tar.DefaultExclusionPattern.String(), "Regular expression for selecting files from the source tree to exclude from the build, where the default excludes the '.git' directory (see https://golang.org/pkg/regexp for syntax, but note that \"\" will be interpreted as allow all files and exclude no files)")
buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble, assemble-runtime and run scripts")
buildCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "DEPRECATED: Specify a URL for the assemble and run scripts")
buildCmd.Flags().BoolVar(&(useConfig), "use-config", false, "Store command line options to .s2ifile")
buildCmd.Flags().StringVarP(&(cfg.EnvironmentFile), "environment-file", "E", "", "Specify the path to the file with environment")
buildCmd.Flags().StringVarP(&(cfg.DisplayName), "application-name", "n", "", "Specify the display name for the application (default: output image name)")
buildCmd.Flags().StringVarP(&(cfg.Description), "description", "", "", "Specify the description of the application")
buildCmd.Flags().VarP(&(cfg.AllowedUIDs), "allowed-uids", "u", "Specify a range of allowed user ids for the builder and runtime images")
buildCmd.Flags().VarP(&(cfg.Injections), "inject", "i", "Specify a directory to inject into the assemble container")
buildCmd.Flags().StringArrayVarP(&(cfg.BuildVolumes), "volume", "v", []string{}, "Specify a volume to mount into the assemble container")
buildCmd.Flags().StringSliceVar(&(cfg.DropCapabilities), "cap-drop", []string{}, "Specify a comma-separated list of capabilities to drop when running Docker containers")
buildCmd.Flags().StringVarP(&(oldDestination), "location", "l", "",
"DEPRECATED: Specify a destination location for untar operation")
buildCmd.Flags().BoolVarP(&(cfg.ForceCopy), "copy", "c", false, "Use local file system copy instead of git cloning the source url")
buildCmd.Flags().StringVar(&(cfg.RuntimeImage), "runtime-image", "", "Image that will be used as the base for the runtime image")
buildCmd.Flags().VarP(&(cfg.RuntimeArtifacts), "runtime-artifact", "a", "Specify a file or directory to be copied from the builder to the runtime image")
return buildCmd
}
func newCmdRebuild(cfg *api.Config) *cobra.Command {
buildCmd := &cobra.Command{
Use: "rebuild <image> [<new-tag>]",
Short: "Rebuild an existing image",
Long: "Rebuild an existing application image that was built by S2I previously.",
Run: func(cmd *cobra.Command, args []string) {
// If user specifies the arguments, then we override the stored ones
if len(args) >= 1 {
cfg.Tag = args[0]
} else {
cmd.Help()
os.Exit(1)
}
var auths *docker.AuthConfigurations
r, err := os.Open(cfg.DockerCfgPath)
if err == nil {
defer r.Close()
auths = docker.LoadImageRegistryAuth(r)
}
cfg.PullAuthentication = docker.GetImageRegistryAuth(auths, cfg.Tag)
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
client, err := docker.NewEngineAPIClient(cfg.DockerConfig)
s2ierr.CheckError(err)
pr, err := docker.GetRebuildImage(client, cfg)
s2ierr.CheckError(err)
err = build.GenerateConfigFromLabels(cfg, pr)
s2ierr.CheckError(err)
if len(args) >= 2 {
cfg.Tag = args[1]
}
cfg.PullAuthentication = docker.GetImageRegistryAuth(auths, cfg.BuilderImage)
glog.V(2).Infof("\n%s\n", describe.Config(client, cfg))
builder, _, err := strategies.GetStrategy(client, cfg)
s2ierr.CheckError(err)
result, err := builder.Build(cfg)
s2ierr.CheckError(err)
for _, message := range result.Messages {
glog.V(1).Infof(message)
}
},
}
cmdutil.AddCommonFlags(buildCmd, cfg)
return buildCmd
}
func newCmdCreate() *cobra.Command {
return &cobra.Command{
Use: "create <imageName> <destination>",
Short: "Bootstrap a new S2I image repository",
Long: "Bootstrap a new S2I image with given imageName inside the destination directory",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 2 {
cmd.Help()
os.Exit(1)
}
b := create.New(args[0], args[1])
b.AddSTIScripts()
b.AddDockerfile()
b.AddReadme()
b.AddTests()
},
}
}
var (
completionShells = map[string]func(out io.Writer, cmd *cobra.Command) error{
"bash": runCompletionBash,
"zsh": runCompletionZsh,
}
)
func newCmdCompletion(root *cobra.Command) *cobra.Command {
shells := []string{}
for s := range completionShells {
shells = append(shells, s)
}
return &cobra.Command{
Use: "completion SHELL",
Short: "Generate completion for the s2i command (bash or zsh)",
Long: "Generate completion for the s2i command into standard output (bash or zsh)",
Run: func(cmd *cobra.Command, args []string) {
// TODO: The version of cobra we vendor takes a
// *bytes.Buffer, while newer versions take an
// io.Writer. The code below could be simplified to a
// single line `root.GenBashCompletion(os.Stdout)` when
// we update cobra.
var out bytes.Buffer
err := RunCompletion(&out, cmd, root, args)
if err != nil {
s2ierr.CheckError(err)
} else {
fmt.Print(out.String())
}
},
ValidArgs: shells,
}
}
// RunCompletion first checks args[0] to decide compose zsh or bash
// then write the content into the out bytes.Buffer
// if command input error will call UsageError with `cmd cobra.Command`
// `root cobra.Command` mainly for GenBashCompletion function
func RunCompletion(out io.Writer, cmd *cobra.Command, root *cobra.Command, args []string) error {
var msg string
if len(args) == 0 {
msg = fmt.Sprintf("shell not specified.\nSee '%s -h' for help and examples.", cmd.CommandPath())
return s2ierr.UsageError(msg)
}
if len(args) > 1 {
msg = fmt.Sprintf("too many arguments. Expected only the shell type.\nSee '%s -h' for help and examples.", cmd.CommandPath())
return s2ierr.UsageError(msg)
}
run, found := completionShells[args[0]]
if !found {
msg = fmt.Sprintf("unsupported shell type %q.\nSee '%s -h' for help and examples.", args[0], cmd.CommandPath())
return s2ierr.UsageError(msg)
}
return run(out, root)
}
func runCompletionBash(out io.Writer, root *cobra.Command) error {
return root.GenBashCompletion(out)
}
func runCompletionZsh(out io.Writer, root *cobra.Command) error {
zshInitialization := `# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__kubectl_bash_source() {
alias shopt=':'
alias _expand=_bash_expand
alias _complete=_bash_comp
emulate -L sh
setopt kshglob noshglob braceexpand
source "$@"
}
__kubectl_type() {
# -t is not supported by zsh
if [ "$1" == "-t" ]; then
shift
# fake Bash 4 to disable "complete -o nospace". Instead
# "compopt +-o nospace" is used in the code to toggle trailing
# spaces. We don't support that, but leave trailing spaces on
# all the time
if [ "$1" = "__kubectl_compopt" ]; then
echo builtin
return 0
fi
fi
type "$@"
}
__kubectl_compgen() {
local completions w
completions=( $(compgen "$@") ) || return $?
# filter by given word as prefix
while [[ "$1" = -* && "$1" != -- ]]; do
shift
shift
done
if [[ "$1" == -- ]]; then
shift
fi
for w in "${completions[@]}"; do
if [[ "${w}" = "$1"* ]]; then
echo "${w}"
fi
done
}
__kubectl_compopt() {
true # don't do anything. Not supported by bashcompinit in zsh
}
__kubectl_declare() {
if [ "$1" == "-F" ]; then
whence -w "$@"
else
builtin declare "$@"
fi
}
__kubectl_ltrim_colon_completions()
{
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
# Remove colon-word prefix from COMPREPLY items
local colon_word=${1%${1##*:}}
local i=${#COMPREPLY[*]}
while [[ $((--i)) -ge 0 ]]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
done
fi
}
__kubectl_get_comp_words_by_ref() {
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[${COMP_CWORD}-1]}"
words=("${COMP_WORDS[@]}")
cword=("${COMP_CWORD[@]}")
}
__kubectl_filedir() {
local RET OLD_IFS w qw
__debug "_filedir $@ cur=$cur"
if [[ "$1" = \~* ]]; then
# somehow does not work. Maybe, zsh does not call this at all
eval echo "$1"
return 0
fi
OLD_IFS="$IFS"
IFS=$'\n'
if [ "$1" = "-d" ]; then
shift
RET=( $(compgen -d) )
else
RET=( $(compgen -f) )
fi
IFS="$OLD_IFS"
IFS="," __debug "RET=${RET[@]} len=${#RET[@]}"
for w in ${RET[@]}; do
if [[ ! "${w}" = "${cur}"* ]]; then
continue
fi
if eval "[[ \"\${w}\" = *.$1 || -d \"\${w}\" ]]"; then
qw="$(__kubectl_quote "${w}")"
if [ -d "${w}" ]; then
COMPREPLY+=("${qw}/")
else
COMPREPLY+=("${qw}")
fi
fi
done
}
__kubectl_quote() {
if [[ $1 == \'* || $1 == \"* ]]; then
# Leave out first character
printf %q "${1:1}"
else
printf %q "$1"
fi
}
autoload -U +X bashcompinit && bashcompinit
# use word boundary patterns for BSD or GNU sed
LWORD='[[:<:]]'
RWORD='[[:>:]]'
if sed --help 2>&1 | grep -q GNU; then
LWORD='\<'
RWORD='\>'
fi
__kubectl_convert_bash_to_zsh() {
sed \
-e 's/declare -F/whence -w/' \
-e 's/local \([a-zA-Z0-9_]*\)=/local \1; \1=/' \
-e 's/flags+=("\(--.*\)=")/flags+=("\1"); two_word_flags+=("\1")/' \
-e 's/must_have_one_flag+=("\(--.*\)=")/must_have_one_flag+=("\1")/' \
-e "s/${LWORD}_filedir${RWORD}/__kubectl_filedir/g" \
-e "s/${LWORD}_get_comp_words_by_ref${RWORD}/__kubectl_get_comp_words_by_ref/g" \
-e "s/${LWORD}__ltrim_colon_completions${RWORD}/__kubectl_ltrim_colon_completions/g" \
-e "s/${LWORD}compgen${RWORD}/__kubectl_compgen/g" \
-e "s/${LWORD}compopt${RWORD}/__kubectl_compopt/g" \
-e "s/${LWORD}declare${RWORD}/__kubectl_declare/g" \
-e "s/\\\$(type${RWORD}/\$(__kubectl_type/g" \
<<'BASH_COMPLETION_EOF'
`
out.Write([]byte(zshInitialization))
buf := new(bytes.Buffer)
root.GenBashCompletion(buf)
out.Write(buf.Bytes())
zshTail := `
BASH_COMPLETION_EOF
}
__kubectl_bash_source <(__kubectl_convert_bash_to_zsh)
`
out.Write([]byte(zshTail))
return nil
}
func newCmdUsage(cfg *api.Config) *cobra.Command {
oldScriptsFlag := ""
oldDestination := ""
usageCmd := &cobra.Command{
Use: "usage <image>",
Short: "Print usage of the assemble script associated with the image",
Long: "Create and start a container from the image and invoke its usage script.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
os.Exit(1)
}
cfg.Usage = true
cfg.BuilderImage = args[0]
if len(oldScriptsFlag) != 0 {
glog.Warning("DEPRECATED: Flag --scripts is deprecated, use --scripts-url instead")
cfg.ScriptsURL = oldScriptsFlag
}
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
client, err := docker.NewEngineAPIClient(cfg.DockerConfig)
s2ierr.CheckError(err)
uh, err := sti.NewUsage(client, cfg)
s2ierr.CheckError(err)
err = uh.Show()
s2ierr.CheckError(err)
},
}
usageCmd.Flags().StringVarP(&(oldDestination), "location", "l", "",
"Specify a destination location for untar operation")
cmdutil.AddCommonFlags(usageCmd, cfg)
return usageCmd
}
// setupGlog makes --loglevel reflect in glog's -v flag
func setupGlog(flags *pflag.FlagSet) {
from := flag.CommandLine
if fflag := from.Lookup("v"); fflag != nil {
level := fflag.Value.(*log.Level)
loglevelPtr := (*int32)(level)
flags.Int32Var(loglevelPtr, "loglevel", 0, "Set the level of log output (0-5)")
}
// FIXME currently glog has only option to redirect output to stderr
// the preferred for S2I would be to redirect to stdout
flag.CommandLine.Set("logtostderr", "true")
}
func main() {
rand.Seed(time.Now().UnixNano())
// Applying partial glog flag initialization workaround from: https://github.com/kubernetes/kubernetes/issues/17162
// Without this fake command line parse, glog will compain its flags have not been interpreted
flag.CommandLine.Parse([]string{})
cfg := &api.Config{}
s2iCmd := &cobra.Command{
Use: "s2i",
Long: "Source-to-image (S2I) is a tool for building repeatable docker images.\n\n" +
"A command line interface that injects and assembles source code into a docker image.\n" +
"Complete documentation is available at http://github.com/openshift/source-to-image",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
},
}
cfg.DockerConfig = docker.GetDefaultDockerConfig()
s2iCmd.PersistentFlags().StringVarP(&(cfg.DockerConfig.Endpoint), "url", "U", cfg.DockerConfig.Endpoint, "Set the url of the docker socket to use")
s2iCmd.PersistentFlags().StringVar(&(cfg.DockerConfig.CertFile), "cert", cfg.DockerConfig.CertFile, "Set the path of the docker TLS certificate file")
s2iCmd.PersistentFlags().StringVar(&(cfg.DockerConfig.KeyFile), "key", cfg.DockerConfig.KeyFile, "Set the path of the docker TLS key file")
s2iCmd.PersistentFlags().StringVar(&(cfg.DockerConfig.CAFile), "ca", cfg.DockerConfig.CAFile, "Set the path of the docker TLS ca file")
s2iCmd.PersistentFlags().BoolVar(&(cfg.DockerConfig.UseTLS), "tls", cfg.DockerConfig.UseTLS, "Use TLS to connect to docker; implied by --tlsverify")
s2iCmd.PersistentFlags().BoolVar(&(cfg.DockerConfig.TLSVerify), "tlsverify", cfg.DockerConfig.TLSVerify, "Use TLS to connect to docker and verify the remote")
s2iCmd.AddCommand(newCmdVersion())
s2iCmd.AddCommand(newCmdBuild(cfg))
s2iCmd.AddCommand(newCmdRebuild(cfg))
s2iCmd.AddCommand(newCmdUsage(cfg))
s2iCmd.AddCommand(newCmdCreate())
setupGlog(s2iCmd.PersistentFlags())
basename := filepath.Base(os.Args[0])
// Make case-insensitive and strip executable suffix if present
if runtime.GOOS == "windows" {
basename = strings.ToLower(basename)
basename = strings.TrimSuffix(basename, ".exe")
}
if basename == "sti" {
glog.Warning("sti binary is deprecated, use s2i instead")
}
s2iCmd.AddCommand(newCmdCompletion(s2iCmd))
err := s2iCmd.Execute()
if err != nil {
os.Exit(1)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yanjingtu/source-to-image.git
git@gitee.com:yanjingtu/source-to-image.git
yanjingtu
source-to-image
source-to-image
v1.1.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891