本文整理匯總了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()
}
}
示例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
}
}
示例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)
}
}
示例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
}
}
示例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
}
}
示例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)
}
}
示例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)...)
}
示例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)
}
}
示例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
}
}
示例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)
}
}
示例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)
}
}
示例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
}
}
}
示例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)
}
}
示例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)
}
}
示例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)
}
}