本文整理匯總了Golang中github.com/drone/drone-go/plugin.MustParse函數的典型用法代碼示例。如果您正苦於以下問題:Golang MustParse函數的具體用法?Golang MustParse怎麽用?Golang MustParse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MustParse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
}
示例2: 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
}
}
示例3: 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
}
}
示例4: 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)...)
}
示例5: 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)
}
}
示例6: 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
}
}
示例7: 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)
}
}
示例8: 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)
}
}
示例9: 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)
}
}
示例10: main
func main() {
fmt.Printf("Drone Capistrano Plugin built at %s\n", buildDate)
workspace := drone.Workspace{}
vargs := Params{}
dw := DeployWorkspace{workspace}
plugin.Param("workspace", &workspace)
plugin.Param("vargs", &vargs)
plugin.MustParse()
log("Installing Drone's ssh key")
if err := repo.WriteKey(&workspace); err != nil {
fmt.Println(err)
os.Exit(1)
}
os.Setenv("BUILD_PATH", workspace.Path)
os.Setenv("GIT_SSH_KEY", privateKeyPath)
tasks := strings.Fields(vargs.Tasks)
if len(tasks) == 0 {
fmt.Println("Please provide Capistrano tasks to execute")
os.Exit(1)
return
}
log("Running Bundler")
bundle := dw.bundle(bundlerArgs(vargs)...)
if err := bundle.Run(); err != nil {
fmt.Println(err)
os.Exit(1)
return
}
log("Running Capistrano")
capistrano := dw.cap(tasks...)
if err := capistrano.Run(); err != nil {
fmt.Println(err)
os.Exit(1)
return
}
}
示例11: main
func main() {
fmt.Printf("Drone Azure Web Apps 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 an username")
os.Exit(1)
return
}
if len(vargs.Password) == 0 {
fmt.Println("Please provide a password")
os.Exit(1)
return
}
if len(vargs.Site) == 0 {
vargs.Site = repo.Name
}
if len(vargs.Slot) == 0 {
vargs.Slot = vargs.Site
}
err := run(&workspace, &build, &vargs)
if err != nil {
fmt.Println(err)
os.Exit(1)
return
}
}
示例12: main
func main() {
fmt.Printf("Drone cloudControl 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.Email) == 0 {
fmt.Println("Please provide an email")
os.Exit(1)
return
}
if len(vargs.Password) == 0 {
fmt.Println("Please provide a password")
os.Exit(1)
return
}
if len(vargs.Application) == 0 {
vargs.Application = repo.Name
}
if len(vargs.Deployment) == 0 {
vargs.Deployment = "default"
}
err := run(&workspace, &build, &vargs)
if err != nil {
fmt.Println(err)
os.Exit(1)
return
}
}
示例13: main
func main() {
fmt.Printf("Drone Cache Plugin built from %s\n", buildCommit)
workspace := drone.Workspace{}
repo := drone.Repo{}
build := drone.Build{}
job := drone.Job{}
vargs := Cache{}
plugin.Param("workspace", &workspace)
plugin.Param("repo", &repo)
plugin.Param("build", &build)
plugin.Param("job", &job)
plugin.Param("vargs", &vargs)
plugin.MustParse()
// mount paths are relative to the workspace.
// if the workspace doesn't exist, create it
os.MkdirAll(workspace.Path, 0755)
os.Chdir(workspace.Path)
// if the job is running we should restore
// the cache
if isRunning(&job) {
for _, mount := range vargs.Mount {
// unique hash for the file
hash_ := hash(mount, build.Branch, job.Environment)
fmt.Println("Restoring cache", mount)
// restore
err := restore(hash_, mount, vargs.Archive)
if err != nil {
fmt.Printf("Unable to restore %s. %s\n", mount, err)
// if a cached file is corrupted we should remove it immediately
// so that subsequent builds don't try to extract.
purge(hash_, vargs.Archive, 0)
}
// restore from repository default branch if possible
if err != nil && build.Branch != repo.Branch {
// recalulate the hash using the default branch
hash_ = hash(mount, repo.Branch, job.Environment)
fmt.Printf("Restoring cache from %s branch\n", repo.Branch)
err = restore(hash_, mount, vargs.Archive) // second time is the charm
if err != nil {
fmt.Printf("Unable to restore %s from %s branch.\n", mount, repo.Branch)
// if a cached file is corrupted we should remove it immediately
// so that subsequent builds don't try to extract.
purge(hash_, vargs.Archive, 0)
}
}
}
}
// if the job is complete and is NOT a pull
// request we should re-build the cache.
if isSuccess(&job) && build.Event == drone.EventPush {
for _, mount := range vargs.Mount {
// unique hash for the file
hash_ := hash(mount, build.Branch, job.Environment)
fmt.Println("Building cache", mount)
// rebuild
err := rebuild(hash_, mount, vargs.Archive)
if err != nil {
fmt.Printf("Unable to rebuild cache for %s. %s\n", mount, err)
}
// purges previously cached files
purge(hash_, vargs.Archive, 1)
}
}
}
示例14: main
func main() {
fmt.Printf("Drone Tutum Plugin built from %s\n", buildCommit)
repo := drone.Repo{}
vargs := Params{}
plugin.Param("repo", &repo)
plugin.Param("vargs", &vargs)
plugin.MustParse()
if vargs.Service == "" {
vargs.Service = repo.Name
}
if vargs.Key == "" {
fmt.Println("Error: Please provide an API key")
os.Exit(1)
}
if vargs.Username == "" {
fmt.Println("Error: Please provide a username")
os.Exit(1)
}
tutum.User = vargs.Username
tutum.ApiKey = vargs.Key
svcs, err := tutum.ListServices()
if err != nil {
fmt.Printf("Error: Failed to get a list of services. %s\n", err)
os.Exit(1)
}
service := vargs.Service
stack := ""
stackURI := ""
if strings.Contains(service, ".") {
parts := strings.Split(service, ".")
if len(parts) != 2 {
fmt.Printf("Error: Failed to parse service name %q.\n", service)
os.Exit(1)
}
service = parts[0]
stack = parts[1]
stacks, err := tutum.ListStacks()
if err != nil {
fmt.Printf("Error: Failed to get a list of the stacks. %s\n", err)
os.Exit(1)
}
foundStack := false
var stk tutum.Stack
for _, stk = range stacks.Objects {
if stk.Name == stack {
foundStack = true
break
}
}
if !foundStack {
fmt.Printf("Error: Failed to find stack %q.\n", stack)
os.Exit(1)
}
stackURI = stk.Resource_uri
}
foundService := false
var svc tutum.Service
for _, svc = range svcs.Objects {
if svc.Name == service {
if stackURI == "" {
foundService = true
break
}
if svc.Stack == stackURI {
foundService = true
break
}
}
}
if !foundService {
fmt.Printf("Error: Failed to find server %s.\n", vargs.Service)
os.Exit(1)
}
if vargs.Image != "" && vargs.Image != svc.Image_name {
err = svc.Update(tutum.ServiceCreateRequest{
Image: vargs.Image,
})
//.........這裏部分代碼省略.........
示例15: main
func main() {
fmt.Printf("Drone AWS ECS 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.AccessKey) == 0 {
fmt.Println("Please provide an access key")
os.Exit(1)
return
}
if len(vargs.SecretKey) == 0 {
fmt.Println("Please provide a secret key")
os.Exit(1)
return
}
if len(vargs.Region) == 0 {
fmt.Println("Please provide a region")
os.Exit(1)
return
}
if len(vargs.Family) == 0 {
fmt.Println("Please provide a task definition family name")
os.Exit(1)
return
}
if len(vargs.Image) == 0 {
fmt.Println("Please provide an image name")
os.Exit(1)
return
}
if len(vargs.Tag) == 0 {
vargs.Tag = "latest"
}
if len(vargs.Service) == 0 {
fmt.Println("Please provide a service name")
os.Exit(1)
return
}
if vargs.Memory == 0 {
vargs.Memory = 128
}
svc := ecs.New(
session.New(&aws.Config{
Region: aws.String(vargs.Region),
Credentials: credentials.NewStaticCredentials(vargs.AccessKey, vargs.SecretKey, ""),
}))
Image := vargs.Image + ":" + vargs.Tag
definition := ecs.ContainerDefinition{
Command: []*string{},
DnsSearchDomains: []*string{},
DnsServers: []*string{},
DockerLabels: map[string]*string{},
DockerSecurityOptions: []*string{},
EntryPoint: []*string{},
Environment: []*ecs.KeyValuePair{},
Essential: aws.Bool(true),
ExtraHosts: []*ecs.HostEntry{},
Image: aws.String(Image),
Links: []*string{},
Memory: aws.Int64(vargs.Memory),
MountPoints: []*ecs.MountPoint{},
Name: aws.String(vargs.Family + "-container"),
PortMappings: []*ecs.PortMapping{},
Ulimits: []*ecs.Ulimit{},
//User: aws.String("String"),
VolumesFrom: []*ecs.VolumeFrom{},
//WorkingDirectory: aws.String("String"),
}
// Port mappings
for _, portMapping := range vargs.PortMappings.Slice() {
cleanedPortMapping := strings.Trim(portMapping, " ")
//.........這裏部分代碼省略.........