本文整理匯總了Golang中github.com/drone/drone-go/drone.Client類的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BuildLogCmd
func BuildLogCmd(c *cli.Context, client drone.Client) error {
var (
nameParam = c.Args().Get(0)
numParam = c.Args().Get(1)
jobParam = c.Args().Get(2)
err error
owner string
name string
num int
job int
)
num, err = strconv.Atoi(numParam)
if err != nil {
return fmt.Errorf("Invalid or missing build number")
}
job, err = strconv.Atoi(jobParam)
if err != nil {
return fmt.Errorf("Invalid or missing job number")
}
owner, name, err = parseRepo(nameParam)
if err != nil {
return err
}
rc, err := client.BuildLogs(owner, name, num, job)
if err != nil {
return err
}
defer rc.Close()
io.Copy(os.Stdout, rc)
return nil
}
示例2: SecureYamlCmd
func SecureYamlCmd(c *cli.Context, client drone.Client) error {
var (
repo = c.String("repo")
inFile = c.String("in")
outFile = c.String("out")
ymlFile = c.String("yaml")
checksum = c.BoolT("checksum")
)
owner, name, err := parseRepo(repo)
if err != nil {
return err
}
keypair, err := client.RepoKey(owner, name)
if err != nil {
return err
}
key, err := toPublicKey(keypair.Public)
if err != nil {
return err
}
// read the .drone.sec.yml file (plain text)
plaintext, err := readInput(inFile)
if err != nil {
return err
}
// parse the .drone.sec.yml file
sec := new(secure.Secure)
err = yaml.Unmarshal(plaintext, sec)
if err != nil {
return err
}
// read the .drone.yml file and caclulate the
// checksum. add to the .drone.sec.yml file.
yml, err := ioutil.ReadFile(ymlFile)
if err == nil && checksum {
sec.Checksum = sha256sum(string(yml))
}
// re-marshal the .drone.sec.yml file since we've
// added the checksum
plaintext, err = yaml.Marshal(sec)
if err != nil {
return err
}
// encrypt the .drone.sec.yml file
ciphertext, err := encrypt(plaintext, key)
if err != nil {
return err
}
// write the encrypted .drone.sec.yml file to .drone.sec
return writeOutput(outFile, ciphertext)
}
示例3: BuildLastCmd
func BuildLastCmd(c *cli.Context, client drone.Client) error {
var (
nameParam = c.Args().Get(0)
branchParam = c.Args().Get(1)
)
owner, name, err := parseRepo(nameParam)
if err != nil {
return err
}
build, err := client.BuildLast(owner, name, branchParam)
if err != nil {
return err
}
fmt.Println(build.Number)
fmt.Println(build.Event)
fmt.Println(build.Status)
fmt.Println(build.Created)
fmt.Println(build.Started)
fmt.Println(build.Enqueued)
fmt.Println(build.Finished)
fmt.Println(build.Commit)
fmt.Println(build.Ref)
fmt.Println(build.Author)
fmt.Println(build.Message)
return nil
}
示例4: BuildStartCmd
func BuildStartCmd(c *cli.Context, client drone.Client) error {
var (
nameParam = c.Args().Get(0)
numParam = c.Args().Get(1)
err error
owner string
name string
num int
)
num, err = strconv.Atoi(numParam)
if err != nil {
return fmt.Errorf("Invalid or missing build number")
}
owner, name, err = parseRepo(nameParam)
if err != nil {
return err
}
build, err := client.BuildStart(owner, name, num)
if err != nil {
return err
}
fmt.Println(build.Number)
fmt.Println(build.Status)
return nil
}
示例5: UserSelfCmd
func UserSelfCmd(c *cli.Context, client drone.Client) error {
user, err := client.Self()
if err != nil {
return err
}
fmt.Println(user.Login)
return nil
}
示例6: RepoListCmd
func RepoListCmd(c *cli.Context, client drone.Client) error {
repos, err := client.RepoList()
if err != nil {
return err
}
for _, repo := range repos {
fmt.Println(repo.FullName)
}
return nil
}
示例7: NodeListCmd
func NodeListCmd(c *cli.Context, client drone.Client) error {
nodes, err := client.NodeList()
if err != nil {
return err
}
for _, node := range nodes {
fmt.Println(node.ID, node.Addr)
}
return nil
}
示例8: RepoAddCmd
func RepoAddCmd(c *cli.Context, client drone.Client) error {
owner, name, err := parseRepo(c.Args().Get(0))
if err != nil {
return err
}
repo, err := client.RepoPost(owner, name)
if err != nil {
return err
}
fmt.Printf("Successfully added %s\n", repo.FullName)
return nil
}
示例9: UserAddCmd
func UserAddCmd(c *cli.Context, client drone.Client) error {
login := c.Args().Get(0)
if len(login) == 0 {
return fmt.Errorf("Missing or invalid user login")
}
user, err := client.UserPost(&drone.User{Login: login})
if err != nil {
return err
}
fmt.Printf("Successfully added user %s\n", user.Login)
return nil
}
示例10: UserDelCmd
func UserDelCmd(c *cli.Context, client drone.Client) error {
login := c.Args().Get(0)
if len(login) == 0 {
return fmt.Errorf("Missing or invalid user login")
}
err := client.UserDel(login)
if err != nil {
return err
}
fmt.Printf("Successfully removed user %s\n", login)
return nil
}
示例11: RepoInfoCmd
func RepoInfoCmd(c *cli.Context, client drone.Client) error {
owner, name, err := parseRepo(c.Args().Get(0))
if err != nil {
return err
}
repo, err := client.Repo(owner, name)
if err != nil {
return err
}
fmt.Println(repo.FullName)
return nil
}
示例12: RepoDelCmd
func RepoDelCmd(c *cli.Context, client drone.Client) error {
owner, name, err := parseRepo(c.Args().Get(0))
if err != nil {
return err
}
err = client.RepoDel(owner, name)
if err != nil {
return err
}
fmt.Printf("Successfully removed %s/%s\n", owner, name)
return nil
}
示例13: NodeInfoCmd
func NodeInfoCmd(c *cli.Context, client drone.Client) error {
id, err := strconv.ParseInt(c.Args().Get(0), 0, 64)
if err != nil {
return fmt.Errorf("Invalid or missing node id. Must be an integer")
}
node, err := client.Node(id)
if err != nil {
return fmt.Errorf("Endpoint is not yet supported")
}
fmt.Println(node.Addr)
return nil
}
示例14: UserListCmd
func UserListCmd(c *cli.Context, client drone.Client) error {
users, err := client.UserList()
if err != nil || len(users) == 0 {
return err
}
w := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)
fmt.Fprintln(w, "username\temail\tadmin\tactive")
fmt.Fprintln(w, "--------\t-----\t-----\t------")
for _, user := range users {
fmt.Fprintf(w, "%s\t%s\t%v\t%v\n", user.Login, user.Email, user.Admin, user.Active)
}
w.Flush()
return nil
}
示例15: NodeDelCmd
func NodeDelCmd(c *cli.Context, client drone.Client) error {
id, err := strconv.ParseInt(c.Args().Get(0), 0, 64)
if err != nil {
return fmt.Errorf("Invalid or missing node id. Must be an integer")
}
err = client.NodeDel(id)
if err != nil {
return err
}
fmt.Printf("Successfully removed node %d\n", id)
return nil
}