• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang util.NewCLISettings函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/wercker/wercker/util.NewCLISettings函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCLISettings函数的具体用法?Golang NewCLISettings怎么用?Golang NewCLISettings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewCLISettings函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:31,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:26,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:17,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:17,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:9,代码来源:options_test.go


示例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)
}
开发者ID:wercker,项目名称:wercker,代码行数:9,代码来源:options_test.go


示例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)
}
开发者ID:wercker,项目名称:wercker,代码行数:10,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:11,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:12,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:21,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:21,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:13,代码来源:options_test.go


示例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)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:15,代码来源:options_test.go


示例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)
}
开发者ID:hughker,项目名称:wercker,代码行数:16,代码来源:options_test.go


示例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
}
开发者ID:hughker,项目名称:wercker,代码行数:46,代码来源:builder.go


示例16:

	"golang.org/x/sys/unix"
)

var (
	cliLogger    = util.RootLogger().WithField("Logger", "CLI")
	buildCommand = cli.Command{
		Name:      "build",
		ShortName: "b",
		Usage:     "build a project",
		Action: func(c *cli.Context) {
			envfile := c.GlobalString("environment")
			_ = godotenv.Load(envfile)

			env := util.NewEnvironment(os.Environ()...)

			settings := util.NewCLISettings(c)
			opts, err := core.NewBuildOptions(settings, env)
			if err != nil {
				cliLogger.Errorln("Invalid options\n", err)
				os.Exit(1)
			}
			dockerOptions, err := dockerlocal.NewDockerOptions(settings, env)
			if err != nil {
				cliLogger.Errorln("Invalid options\n", err)
				os.Exit(1)
			}
			_, err = cmdBuild(context.Background(), opts, dockerOptions)
			if err != nil {
				cliLogger.Fatal(err)
			}
		},
开发者ID:rlugojr,项目名称:wercker,代码行数:31,代码来源:main.go



注:本文中的github.com/wercker/wercker/util.NewCLISettings函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.NewTimer函数代码示例发布时间:2022-05-28
下一篇:
Golang core.Step类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap