当前位置: 首页>>代码示例>>Golang>>正文


Golang Settings.String方法代码示例

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


在下文中一共展示了Settings.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: guessApplicationID

func guessApplicationID(c util.Settings, e *util.Environment, name string) string {
	id, _ := c.String("application-id")
	if id == "" {
		id = name
	}
	return id
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:7,代码来源:options.go

示例2: NewDeployOptions

// NewDeployOptions constructor
func NewDeployOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error) {
	pipelineOpts, err := NewPipelineOptions(c, e)
	if err != nil {
		return nil, err
	}
	// default to last build output if none defined
	target, _ := c.String("target")
	if target == "" {
		found, err := util.Exists("./.wercker/latest/output")
		if err == nil && found {
			util.RootLogger().Println("No target specified, using recent build output.")
			pipelineOpts.ProjectPath, _ = filepath.Abs("./.wercker/latest/output")
		}
	}

	// if the deploy target path does not have a wercker.yml, use the current one
	werckerYml, _ := c.String("wercker-yml")
	if werckerYml == "" {
		found, _ := util.Exists(filepath.Join(pipelineOpts.ProjectPath, "wercker.yml"))
		if !found {
			pipelineOpts.WerckerYml = "./wercker.yml"
		}
	}

	if pipelineOpts.RunID == "" {
		pipelineOpts.RunID = uuid.NewRandom().String()
	}
	return pipelineOpts, nil
}
开发者ID:wercker,项目名称:wercker,代码行数:30,代码来源:options.go

示例3: guessProjectURL

func guessProjectURL(c util.Settings, e *util.Environment) string {
	target, _ := c.String("target")
	if !looksLikeURL(target) {
		return ""
	}
	return target
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:7,代码来源:options.go

示例4: guessGitCommit

func guessGitCommit(c util.Settings, e *util.Environment) string {
	commit, _ := c.String("git-commit")
	if commit != "" {
		return commit
	}

	projectPath := guessProjectPath(c, e)
	if projectPath == "" {
		return ""
	}
	cwd, err := os.Getwd()
	if err != nil {
		return ""
	}
	defer os.Chdir(cwd)
	os.Chdir(projectPath)

	git, err := exec.LookPath("git")
	if err != nil {
		return ""
	}

	var out bytes.Buffer
	cmd := exec.Command(git, "rev-parse", "HEAD")
	cmd.Stdout = &out
	err = cmd.Run()
	if err != nil {
		return ""
	}
	return strings.Trim(out.String(), "\n")
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:31,代码来源:options.go

示例5: guessApplicationName

// Some logic to guess the application name
func guessApplicationName(c util.Settings, e *util.Environment) (string, error) {
	applicationName, _ := c.String("application-name")
	if applicationName != "" {
		return applicationName, nil
	}

	// Otherwise, check our build target, it can be a url...
	target, _ := c.String("target")
	projectURL := ""
	if strings.HasPrefix(target, "http://") || strings.HasPrefix(target, "https://") {
		projectURL = target
		base := path.Base(projectURL)
		// Special handling for github tarballs
		if base == "tarball" {
			base = path.Base(path.Dir(projectURL))
		}
		ext := path.Ext(base)
		base = base[:len(ext)]
		return base, nil
	}

	// ... or a file path
	if target == "" {
		target = "."
	}
	stat, err := os.Stat(target)
	if err != nil || !stat.IsDir() {
		return "", fmt.Errorf("target '%s' is not a directory", target)
	}
	abspath, err := filepath.Abs(target)
	if err != nil {
		return "", err
	}
	return filepath.Base(abspath), nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:36,代码来源:options.go

示例6: guessTag

func guessTag(c util.Settings, e *util.Environment) string {
	tag, _ := c.String("tag")
	if tag == "" {
		tag = guessGitBranch(c, e)
	}
	tag = strings.Replace(tag, "/", "_", -1)
	return tag
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:8,代码来源:options.go

示例7: guessProjectID

func guessProjectID(c util.Settings, e *util.Environment) string {
	projectID, _ := c.String("project-id")
	if projectID != "" {
		return projectID
	}

	// If this was going to fail it already failed and we exited
	name, _ := guessApplicationName(c, e)
	return name
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:10,代码来源:options.go

示例8: guessProjectPath

func guessProjectPath(c util.Settings, e *util.Environment) string {
	target, _ := c.String("target")
	if looksLikeURL(target) {
		return ""
	}
	if target == "" {
		target = "."
	}
	abs, _ := filepath.Abs(target)
	return abs
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:11,代码来源:options.go

示例9: guessGitRepository

func guessGitRepository(c util.Settings, e *util.Environment) string {
	repository, _ := c.String("git-repository")
	if repository != "" {
		return repository
	}
	// repository, err := guessApplicationName(c, env)
	// if err != nil {
	//   return ""
	// }
	return repository
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:11,代码来源:options.go

示例10: guessGitOwner

func guessGitOwner(c util.Settings, e *util.Environment) string {
	owner, _ := c.String("git-owner")
	if owner != "" {
		return owner
	}

	u, err := user.Current()
	if err == nil {
		owner = u.Username
	}
	return owner
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:12,代码来源:options.go

示例11: guessApplicationOwnerName

func guessApplicationOwnerName(c util.Settings, e *util.Environment) string {
	name, _ := c.String("application-owner-name")
	if name == "" {
		u, err := user.Current()
		if err == nil {
			name = u.Username
		}
	}
	if name == "" {
		name = "wercker"
	}
	return name
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:13,代码来源:options.go

示例12: NewGitOptions

// NewGitOptions constructor
func NewGitOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*GitOptions, error) {
	gitBranch := guessGitBranch(c, e)
	gitCommit := guessGitCommit(c, e)
	gitDomain, _ := c.String("git-domain")
	gitOwner := guessGitOwner(c, e)
	gitRepository := guessGitRepository(c, e)

	return &GitOptions{
		GlobalOptions: globalOpts,
		GitBranch:     gitBranch,
		GitCommit:     gitCommit,
		GitDomain:     gitDomain,
		GitOwner:      gitOwner,
		GitRepository: gitRepository,
	}, nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:17,代码来源:options.go

示例13: NewReporterOptions

// NewReporterOptions constructor
func NewReporterOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*ReporterOptions, error) {
	shouldReport, _ := c.Bool("report")
	reporterHost, _ := c.String("wercker-host")
	reporterKey, _ := c.String("wercker-token")

	if shouldReport {
		if reporterKey == "" {
			return nil, errors.New("wercker-token is required")
		}

		if reporterHost == "" {
			return nil, errors.New("wercker-host is required")
		}
	}

	return &ReporterOptions{
		GlobalOptions: globalOpts,
		ReporterHost:  reporterHost,
		ReporterKey:   reporterKey,
		ShouldReport:  shouldReport,
	}, nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:23,代码来源:options.go

示例14: NewKeenOptions

// NewKeenOptions constructor
func NewKeenOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*KeenOptions, error) {
	keenMetrics, _ := c.Bool("keen-metrics")
	keenProjectWriteKey, _ := c.String("keen-project-write-key")
	keenProjectID, _ := c.String("keen-project-id")

	if keenMetrics {
		if keenProjectWriteKey == "" {
			return nil, errors.New("keen-project-write-key is required")
		}

		if keenProjectID == "" {
			return nil, errors.New("keen-project-id is required")
		}
	}

	return &KeenOptions{
		GlobalOptions:       globalOpts,
		KeenProjectID:       keenProjectID,
		KeenProjectWriteKey: keenProjectWriteKey,
		ShouldKeenMetrics:   keenMetrics,
	}, nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:23,代码来源:options.go

示例15: NewAWSOptions

// NewAWSOptions constructor
func NewAWSOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*AWSOptions, error) {
	awsAccessKeyID, _ := c.String("aws-access-key")
	awsRegion, _ := c.String("aws-region")
	awsSecretAccessKey, _ := c.String("aws-secret-key")
	s3Bucket, _ := c.String("s3-bucket")

	return &AWSOptions{
		GlobalOptions:      globalOpts,
		AWSAccessKeyID:     awsAccessKeyID,
		AWSRegion:          awsRegion,
		AWSSecretAccessKey: awsSecretAccessKey,
		S3Bucket:           s3Bucket,
		S3PartSize:         100 * 1024 * 1024, // 100 MB
	}, nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:16,代码来源:options.go


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