本文整理汇总了Golang中github.com/wercker/wercker/util.NewCLISettings函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCLISettings函数的具体用法?Golang NewCLISettings怎么用?Golang NewCLISettings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCLISettings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestEmptyPipelineOptionsEmptyDir
func (s *OptionsSuite) TestEmptyPipelineOptionsEmptyDir() {
tmpDir, err := ioutil.TempDir("", "empty-directory")
s.Nil(err)
defer os.RemoveAll(tmpDir)
basename := filepath.Base(tmpDir)
currentUser, err := user.Current()
s.Nil(err)
username := currentUser.Username
// Target the path
args := defaultArgs(tmpDir)
test := func(c *cli.Context) {
opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(basename, opts.ApplicationID)
s.Equal(basename, opts.ApplicationName)
s.Equal(username, opts.ApplicationOwnerName)
s.Equal(username, opts.ApplicationStartedByName)
s.Equal(tmpDir, opts.ProjectPath)
s.Equal(basename, opts.ProjectID)
// Pretty much all the git stuff should be empty
s.Equal("", opts.GitBranch)
s.Equal("", opts.GitCommit)
s.Equal("", opts.GitDomain)
s.Equal(username, opts.GitOwner)
s.Equal("", opts.GitRepository)
cmd.DumpOptions(opts)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例2: TestGuessAuthToken
func (s *OptionsSuite) TestGuessAuthToken() {
tmpFile, err := ioutil.TempFile("", "test-auth-token")
s.Nil(err)
token := uuid.NewRandom().String()
_, err = tmpFile.Write([]byte(token))
s.Nil(err)
tokenStore := tmpFile.Name()
defer os.Remove(tokenStore)
defer tmpFile.Close()
args := []string{
"wercker",
"--auth-token-store", tokenStore,
"test",
}
test := func(c *cli.Context) {
opts, err := core.NewGlobalOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(token, opts.AuthToken)
}
run(s, globalFlags, emptyFlags, test, args)
}
示例3: TestReporterOptions
func (s *OptionsSuite) TestReporterOptions() {
args := defaultArgs(
"--report",
"--wercker-host", "http://example.com/wercker-host",
"--wercker-token", "test-token",
)
test := func(c *cli.Context) {
e := emptyEnv()
gOpts, err := core.NewGlobalOptions(util.NewCLISettings(c), e)
opts, err := core.NewReporterOptions(util.NewCLISettings(c), e, gOpts)
s.Nil(err)
s.Equal(true, opts.ShouldReport)
s.Equal("http://example.com/wercker-host", opts.ReporterHost)
s.Equal("test-token", opts.ReporterKey)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例4: TestKeenOptions
func (s *OptionsSuite) TestKeenOptions() {
args := defaultArgs(
"--keen-metrics",
"--keen-project-id", "test-id",
"--keen-project-write-key", "test-key",
)
test := func(c *cli.Context) {
e := emptyEnv()
gOpts, err := core.NewGlobalOptions(util.NewCLISettings(c), e)
opts, err := core.NewKeenOptions(util.NewCLISettings(c), e, gOpts)
s.Nil(err)
s.Equal(true, opts.ShouldKeenMetrics)
s.Equal("test-key", opts.KeenProjectWriteKey)
s.Equal("test-id", opts.KeenProjectID)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例5: TestTagEscaping
func (s *OptionsSuite) TestTagEscaping() {
args := defaultArgs("--tag", "feature/foo")
test := func(c *cli.Context) {
opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal("feature_foo", opts.Tag)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例6: TestDeployOptions
func (s *OptionsSuite) TestDeployOptions() {
args := defaultArgs("--run-id", "fake-deploy-id")
test := func(c *cli.Context) {
opts, err := core.NewDeployOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal("fake-deploy-id", opts.RunID)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例7: TestEmptyBuildOptions
func (s *OptionsSuite) TestEmptyBuildOptions() {
args := defaultArgs()
test := func(c *cli.Context) {
opts, err := core.NewBuildOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.NotEqual("", opts.RunID)
s.Equal(opts.RunID, opts.RunID)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例8: TestBuildOptions
func (s *OptionsSuite) TestBuildOptions() {
args := defaultArgs("--build-id", "fake-build-id")
test := func(c *cli.Context) {
opts, err := core.NewBuildOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal("fake-build-id", opts.PipelineID)
s.Equal("fake-build-id", opts.BuildID)
s.Equal("", opts.DeployID)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例9: TestGlobalOptions
func (s *OptionsSuite) TestGlobalOptions() {
args := defaultArgs()
test := func(c *cli.Context) {
opts, err := core.NewGlobalOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(true, opts.Debug)
s.Equal("http://example.com/base-url", opts.BaseURL)
s.Equal("test-token", opts.AuthToken)
s.Equal("/tmp/.wercker/test-token", opts.AuthTokenStore)
}
run(s, globalFlags, emptyFlags, test, args)
}
示例10: TestReporterMissingOptions
func (s *OptionsSuite) TestReporterMissingOptions() {
test := func(c *cli.Context) {
e := emptyEnv()
gOpts, err := core.NewGlobalOptions(util.NewCLISettings(c), e)
_, err = core.NewReporterOptions(util.NewCLISettings(c), e, gOpts)
s.NotNil(err)
}
missingHost := defaultArgs(
"--report",
"--wercker-token", "test-token",
)
missingKey := defaultArgs(
"--report",
"--wercker-host", "http://example.com/wercker-host",
)
run(s, globalFlags, cmd.ReporterFlags, test, missingHost)
run(s, globalFlags, cmd.ReporterFlags, test, missingKey)
}
示例11: TestKeenMissingOptions
func (s *OptionsSuite) TestKeenMissingOptions() {
test := func(c *cli.Context) {
e := emptyEnv()
gOpts, err := core.NewGlobalOptions(util.NewCLISettings(c), e)
_, err = core.NewKeenOptions(util.NewCLISettings(c), e, gOpts)
s.NotNil(err)
}
missingID := defaultArgs(
"--keen-metrics",
"--keen-project-write-key", "test-key",
)
missingKey := defaultArgs(
"--keen-metrics",
"--keen-project-id", "test-id",
)
run(s, globalFlags, cmd.KeenFlags, test, missingID)
run(s, globalFlags, cmd.KeenFlags, test, missingKey)
}
示例12: TestWorkingDirCWD
func (s *OptionsSuite) TestWorkingDirCWD() {
args := defaultArgs()
cwd, err := filepath.Abs(".")
s.Nil(err)
test := func(c *cli.Context) {
opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(filepath.Join(cwd, ".wercker"), opts.WorkingDir)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例13: TestWorkingDir
func (s *OptionsSuite) TestWorkingDir() {
tempDir, err := ioutil.TempDir("", "wercker-test-")
s.Nil(err)
defer os.RemoveAll(tempDir)
args := defaultArgs("--working-dir", tempDir)
test := func(c *cli.Context) {
opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(tempDir, opts.WorkingDir)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例14: TestWorkingDirGetsSet
func (s *OptionsSuite) TestWorkingDirGetsSet() {
tempDir, err := ioutil.TempDir("", "wercker-test-")
s.Nil(err)
defer os.RemoveAll(tempDir)
// This ignores the _build part, we're only concerned about the working dir
args := defaultArgs("--build-dir", filepath.Join(tempDir, "_build"))
test := func(c *cli.Context) {
opts, err := core.NewPipelineOptions(util.NewCLISettings(c), emptyEnv())
s.Nil(err)
s.Equal(tempDir, opts.WorkingDir)
}
run(s, globalFlags, pipelineFlags, test, args)
}
示例15: getOptions
func (b *DockerBuilder) getOptions(env *util.Environment, config *core.BoxConfig) (*core.PipelineOptions, error) {
c, err := b.configURL(config)
if err != nil {
return nil, err
}
servicePath := filepath.Join(c.Host, c.Path)
if !filepath.IsAbs(servicePath) {
servicePath, err = filepath.Abs(
filepath.Join(b.options.ProjectPath, servicePath))
if err != nil {
return nil, err
}
}
flagSet := func(name string, flags []cli.Flag) *flag.FlagSet {
set := flag.NewFlagSet(name, flag.ContinueOnError)
for _, f := range flags {
f.Apply(set)
}
return set
}
set := flagSet("runservice", FlagsFor(PipelineFlagSet, WerckerInternalFlagSet))
args := []string{
servicePath,
}
if err := set.Parse(args); err != nil {
return nil, err
}
ctx := cli.NewContext(nil, set, set)
settings := util.NewCLISettings(ctx)
newOptions, err := core.NewBuildOptions(settings, env)
if err != nil {
return nil, err
}
newOptions.GlobalOptions = b.options.GlobalOptions
newOptions.ShouldCommit = true
newOptions.PublishPorts = b.options.PublishPorts
// TODO(termie): PACKAGING these moved
// newOptions.DockerLocal = true
// newOptions.DockerOptions = s.dockerOptions
newOptions.Pipeline = c.Fragment
return newOptions, nil
}