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


Golang plugin.Param函数代码示例

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


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

示例1: main

func main() {
	var repo = drone.Repo{}
	var build = drone.Build{}
	var vargs = struct {
		Urls []string `json:"urls"`
	}{}

	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.Parse()

	// data structure
	data := struct {
		Repo  drone.Repo  `json:"repo"`
		Build drone.Build `json:"build"`
	}{repo, build}

	// json payload that will be posted
	payload, err := json.Marshal(&data)
	if err != nil {
		os.Exit(1)
	}

	// post payload to each url
	for _, url := range vargs.Urls {
		resp, err := http.Post(url, "application/json", bytes.NewBuffer(payload))
		if err != nil {
			os.Exit(1)
		}
		resp.Body.Close()
	}
}
开发者ID:ipedrazas,项目名称:drone-webhook,代码行数:33,代码来源:main.go

示例2: main

func main() {
	fmt.Printf("Drone Rubygems Plugin built from %s\n", buildCommit)

	workspace := drone.Workspace{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}

	plugin.Param("workspace", &workspace)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if (len(vargs.Username) == 0 || len(vargs.Password) == 0) && len(vargs.APIKey) == 0 {
		fmt.Println("Please provide an API key or username/password credentials")

		os.Exit(1)
		return
	}

	dpl := buildDpl(&workspace, &repo, &build, &vargs)

	dpl.Dir = workspace.Path
	dpl.Stderr = os.Stderr
	dpl.Stdout = os.Stdout

	if err := dpl.Run(); err != nil {
		fmt.Println(err)

		os.Exit(1)
		return
	}
}
开发者ID:drone-plugins,项目名称:drone-rubygems,代码行数:34,代码来源:main.go

示例3: main

func main() {
	var (
		repo      = new(drone.Repo)
		build     = new(drone.Build)
		sys       = new(drone.System)
		workspace = new(drone.Workspace)
		vargs     = new(Vargs)
	)

	plugin.Param("build", build)
	plugin.Param("repo", repo)
	plugin.Param("system", sys)
	plugin.Param("workspace", workspace)
	plugin.Param("vargs", vargs)

	err := plugin.Parse()
	if err != nil {
		log.Fatal(err)
	}

	vargs.TerraformVarsFile = strings.Join([]string{vargs.TerraformVarsFile, "\nbuild_number = \"", strconv.Itoa(build.Number), "\""}, "")

	err = CheckDeploy(vargs)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	} else {
		os.Exit(0)
	}

}
开发者ID:asteris-llc,项目名称:mantl-drone-plugin,代码行数:31,代码来源:mantl-testing.go

示例4: main

func main() {
	fmt.Printf("Drone Deis Plugin built from %s\n", buildCommit)

	workspace := drone.Workspace{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}

	plugin.Param("workspace", &workspace)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if len(vargs.Controller) == 0 {
		fmt.Println("Please provide a controller")

		os.Exit(1)
		return
	}

	if len(vargs.Application) == 0 {
		vargs.Application = repo.Name
	}

	err := run(&workspace, &build, &vargs)

	if err != nil {
		fmt.Println(err)

		os.Exit(1)
		return
	}
}
开发者ID:drone-plugins,项目名称:drone-deis,代码行数:34,代码来源:main.go

示例5: main

func main() {
	fmt.Printf("Drone Heroku Plugin built at %s\n", buildDate)

	workspace := drone.Workspace{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}

	plugin.Param("workspace", &workspace)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if len(vargs.Application) == 0 {
		vargs.Application = repo.Name
	}

	err := run(&workspace, &build, &vargs)

	if err != nil {
		fmt.Println(err)

		os.Exit(1)
		return
	}
}
开发者ID:Inza,项目名称:drone-heroku,代码行数:27,代码来源:main.go

示例6: main

func main() {
	fmt.Printf("\nDrone Bintray plugin version %s %s\n", version, buildDate)
	var workspace = drone.Workspace{}

	plugin.Param("workspace", &workspace)
	plugin.Param("vargs", &bintray)
	if err := plugin.Parse(); err != nil {
		fmt.Printf("ERROR Can't parse yaml config: %s", err.Error())
		os.Exit(1)
	}

	if bintray.Host == "" {
		bintray.Host = defaultHost
	}

	if bintray.Debug {
		saveApikey := bintray.APIKey
		bintray.APIKey = "******"
		fmt.Printf("DEBUG plugin input:\n%#v\n%#v\n", workspace, bintray)
		bintray.APIKey = saveApikey
	}
	if len(bintray.Branch) == 0 || bintray.Branch == "master" {
		fmt.Printf("\nPublishing %d artifacts to Bintray for user %s\n", len(bintray.Artifacts), bintray.Username)
	} else {
		fmt.Printf("\nPublishing %d artifacts on branch %s to Bintray for user %s\n", len(bintray.Artifacts), bintray.Branch, bintray.Username)
	}
	for i, artifact := range bintray.Artifacts {
		artifact.Version = fmt.Sprintf("%v", artifact.Versioni)
		fmt.Printf("\nUploading file %d %s to %s\n", i+1,
			artifact.File, artifact.getEndpoint())
		artifact.Upload(workspace.Path)
	}
}
开发者ID:jackspirou,项目名称:drone-bintray,代码行数:33,代码来源:main.go

示例7: main

func main() {
	fmt.Printf("Drone Cloud Foundry Plugin built from %s\n", buildCommit)

	workspace := drone.Workspace{}
	cfargs := CloudFoundry{}

	plugin.Param("workspace", &workspace)
	plugin.Param("vargs", &cfargs)
	plugin.MustParse()

	cli := cfcli{
		Dir: workspace.Path,
	}

	cli.Exec(
		api(cfargs.API)...)
	cli.Exec(
		login(cfargs.Credentials)...)
	cli.Exec(
		target(cfargs.Target)...)
	cli.Exec(
		push(
			workspace,
			cfargs.App,
			cfargs.Route,
			cfargs.Flags)...)
}
开发者ID:drone-plugins,项目名称:drone-cloudfoundry,代码行数:27,代码来源:main.go

示例8: main

func main() {
	fmt.Printf("Drone Pushover Plugin built from %s\n", buildCommit)

	system := drone.System{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}

	plugin.Param("system", &system)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if vargs.Retry == 0 {
		vargs.Retry = 60 * time.Second
	}

	if vargs.Expire == 0 {
		vargs.Expire = 3600 * time.Second
	}

	if vargs.Token == "" {
		fmt.Println("Please provide a app token")
		os.Exit(1)
	}

	if vargs.User == "" {
		fmt.Println("Please provide a user token")
		os.Exit(1)
	}

	client := pushover.New(vargs.Token)

	resp, err := client.SendMessage(
		&pushover.Message{
			Title:      BuildTitle(system, repo, build, vargs.Title),
			Message:    BuildBody(system, repo, build, vargs.Body),
			URL:        fmt.Sprintf("%s/%s/%d", system.Link, repo.FullName, build.Number),
			URLTitle:   "Link to the Build",
			DeviceName: vargs.Device,
			Sound:      vargs.Sound,
			Priority:   vargs.Priority,
			Retry:      vargs.Retry,
			Expire:     vargs.Expire,
			Timestamp:  time.Now().Unix(),
		},
		pushover.NewRecipient(
			vargs.User,
		),
	)

	fmt.Println(resp)

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
开发者ID:drone-plugins,项目名称:drone-pushover,代码行数:59,代码来源:main.go

示例9: main

func main() {
	fmt.Printf("Drone Anynines Plugin built from %s\n", buildCommit)

	workspace := drone.Workspace{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}

	plugin.Param("workspace", &workspace)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if len(vargs.Username) == 0 {
		fmt.Println("Please provide a username")

		os.Exit(1)
		return
	}

	if len(vargs.Password) == 0 {
		fmt.Println("Please provide a password")

		os.Exit(1)
		return
	}

	if len(vargs.Organization) == 0 {
		fmt.Println("Please provide an organization")

		os.Exit(1)
		return
	}

	if len(vargs.Space) == 0 {
		fmt.Println("Please provide a space")

		os.Exit(1)
		return
	}

	dpl := buildDpl(&workspace, &repo, &build, &vargs)

	dpl.Dir = workspace.Path
	dpl.Stderr = os.Stderr
	dpl.Stdout = os.Stdout

	trace(dpl)

	if err := dpl.Run(); err != nil {
		fmt.Println(err)

		os.Exit(1)
		return
	}
}
开发者ID:drone-plugins,项目名称:drone-anynines,代码行数:57,代码来源:main.go

示例10: main

func main() {
	repo := drone.Repo{}
	build := drone.Build{}
	workspace := drone.Workspace{}
	vargs := Nonstop{}

	plugin.Param("build", &build)
	plugin.Param("repo", &repo)
	plugin.Param("workspace", &workspace)
	plugin.Param("vargs", &vargs)

	// parse the parameters
	if err := plugin.Parse(); err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	// check for required parameters
	if len(vargs.Index) == 0 {
		fmt.Println("Index Host/IP not provided")
		os.Exit(1)
	}

	if len(vargs.Port) == 0 {
		fmt.Println("Index Port not provided")
		os.Exit(1)
	}

	if len(vargs.Token) == 0 {
		fmt.Println("Index Auth Token not provided")
		os.Exit(1)
	}

	if len(vargs.Url) == 0 {
		fmt.Println("Index Url not provided")
		os.Exit(1)
	}

	//set up commands
	var cmd *exec.Cmd
	cmd = publishCommand(vargs)
	cmd.Dir = workspace.Path
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if vargs.Secure {
		c := []string{"ns", "upload", "--latest", "--secure", "--index", vargs.Index, "--port", vargs.Port, "--url", vargs.Url, "--token", "***********"}
		fmt.Println("$", strings.Join(c, " "))
	} else {
		c := []string{"ns", "upload", "--latest", "--index", vargs.Index, "--port", vargs.Port, "--url", vargs.Url, "--token", "***********"}
		fmt.Println("$", strings.Join(c, " "))
	}
	err := cmd.Run()
	if err != nil {
		os.Exit(1)
	}
}
开发者ID:jgreat,项目名称:drone-nonstop,代码行数:56,代码来源:main.go

示例11: main

func main() {
	w := drone.Workspace{}
	v := Params{}
	plugin.Param("workspace", &w)
	plugin.Param("vargs", &v)
	plugin.MustParse()

	err := v.Deploy(&w)
	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:msteinert,项目名称:drone-pypi,代码行数:12,代码来源:main.go

示例12: main

func main() {
	w := new(drone.Workspace)
	v := new(Rsync)
	plugin.Param("workspace", w)
	plugin.Param("vargs", v)
	if err := plugin.Parse(); err != nil {
		fmt.Println("Rsync: unable to parse invalid plugin input.")
		os.Exit(1)
	}

	// write the rsa private key if provided
	if err := writeKey(w); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// default values
	if v.Port == 0 {
		v.Port = 22
	}
	if len(v.User) == 0 {
		v.User = "root"
	}
	if len(v.Source) == 0 {
		v.Source = "./"
	}

	// execute for each host
	for _, host := range v.Hosts.Slice() {
		// sync the files on the remote machine
		rs := v.buildRsync(host, w.Path)
		rs.Stderr = os.Stderr
		rs.Stdout = os.Stdout
		trace(rs)
		err := rs.Run()
		if err != nil {
			os.Exit(1)
			return
		}

		// continue if no commands
		if len(v.Commands) == 0 {
			continue
		}

		// execute commands on remote server (reboot instance, etc)
		if err := v.run(w.Keys, host); err != nil {
			os.Exit(1)
			return
		}
	}
}
开发者ID:msteinert,项目名称:drone-rsync,代码行数:52,代码来源:main.go

示例13: main

func main() {
	w := new(drone.Workspace)
	v := new(Rsync)
	plugin.Param("workspace", w)
	plugin.Param("vargs", v)
	if err := plugin.Parse(); err != nil {
		fmt.Println("Rsync: unable to parse invalid plugin input.")
		os.Exit(1)
	}
	if err := rsync(w, v); err != nil {
		fmt.Printf("Rsync: %s\n", err)
		os.Exit(1)
	}
}
开发者ID:andreas-venturini,项目名称:drone-rsync,代码行数:14,代码来源:main.go

示例14: main

func main() {
	v := new(Params)
	b := new(drone.Build)
	w := new(drone.Workspace)
	plugin.Param("build", b)
	plugin.Param("workspace", w)
	plugin.Param("vargs", &v)
	plugin.MustParse()

	err := run(b, w, v)
	if err != nil {
		os.Exit(1)
	}
}
开发者ID:daxroc,项目名称:drone-git-push,代码行数:14,代码来源:main.go

示例15: main

func main() {

	system := drone.System{}
	repo := drone.Repo{}
	build := drone.Build{}
	vargs := Params{}
	workspace := drone.Workspace{}

	plugin.Param("system", &system)
	plugin.Param("workspace", &workspace)
	plugin.Param("repo", &repo)
	plugin.Param("build", &build)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	if vargs.Debug {
		debug = true
	}

	if debug {
		log.Println("Workspace Root: " + workspace.Root)
		log.Println("Workspace Path: " + workspace.Path)

		log.Println("Tag: " + vargs.Tag)
	}

	// Iterate over rcs and svcs
	for _, rc := range vargs.ReplicationControllers {
		artifact, err := readArtifactFromFile(workspace.Path, rc, vargs.ApiServer, vargs.Namespace, vargs.Tag)
		if err != nil {
			log.Fatal(err)
		}
		if debug {
			log.Println("Artifact loaded: " + artifact.Url)
		}
		if b, _ := existsArtifact(artifact, vargs.Token); b {
			deleteArtifact(artifact, vargs.Token)
			time.Sleep(time.Second * 5)
		}
		createArtifact(artifact, vargs.Token)
	}
	for _, rc := range vargs.Services {
		artifact, err := readArtifactFromFile(workspace.Path, rc, vargs.ApiServer, vargs.Namespace, vargs.Tag)
		if err != nil {
			log.Fatal(err)
		}
		createArtifact(artifact, vargs.Token)
	}
}
开发者ID:UKHomeOffice,项目名称:drone-kubernetes,代码行数:49,代码来源:main.go


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