本文整理匯總了Golang中github.com/google/go-github/github.Hook類的典型用法代碼示例。如果您正苦於以下問題:Golang Hook類的具體用法?Golang Hook怎麽用?Golang Hook使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Hook類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateHook
// CreateHook is a helper function that creates a post-commit hook
// for the specified repository.
func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error) {
var hook = new(github.Hook)
hook.Name = github.String("web")
hook.Events = []string{"issue_comment", "status", "pull_request"}
hook.Config = map[string]interface{}{}
hook.Config["url"] = url
hook.Config["content_type"] = "json"
created, _, err := client.Repositories.CreateHook(owner, name, hook)
return created, err
}
示例2: runCreateCmd
func runCreateCmd(cmd *commander.Command, args []string) error {
if err := validateSubUsage(cmd, args); err != nil {
return err
}
c, err := Client()
if err != nil {
return err
}
hookSchema, _, err := GetHookSchema(c, args[2])
if err != nil {
return err
}
hook := new(github.Hook)
hook.Name = hookSchema.Name
active := true
hook.Active = &active
events := make([]string, 0)
for _, event := range hookSchema.Events {
events = append(events, event)
}
hook.Events = events
hook.Config = make(map[string]interface{})
newHook, err := edit(
hook,
hookSchema,
)
if err != nil {
return err
}
if _, _, err := c.Repositories.CreateHook(args[0], args[1], newHook); err != nil {
return err
}
return nil
}
示例3: createHookFromToml
func createHookFromToml(reader io.Reader) (*github.Hook, error) {
tomlHook := new(TomlHook)
if _, err := toml.DecodeReader(reader, tomlHook); err != nil {
return nil, err
}
hook := new(github.Hook)
if tomlHook.Name != nil {
hook.Name = tomlHook.Name
}
if tomlHook.Active != nil {
hook.Active = tomlHook.Active
}
if tomlHook.Events != nil {
hook.Events = tomlHook.Events
}
if tomlHook.Config != nil {
hook.Config = tomlHook.Config
}
return hook, nil
}