mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
Updates for consistency
This commit is contained in:
parent
3141ccdaae
commit
df5d049239
1 changed files with 7 additions and 15 deletions
|
@ -136,7 +136,7 @@ func (c *Client) CreateHook(owner string, name string, callBackLink string) erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hooks := make([]string, 0)
|
var hooks []string
|
||||||
if hookDetails.Enabled {
|
if hookDetails.Enabled {
|
||||||
hookSettings, err := c.GetHooks(owner, name)
|
hookSettings, err := c.GetHooks(owner, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -181,13 +181,9 @@ func (c *Client) GetHookDetails(owner string, name string) (*HookPluginDetails,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
contents, err := ioutil.ReadAll(response.Body)
|
|
||||||
hookDetails := HookPluginDetails{}
|
hookDetails := HookPluginDetails{}
|
||||||
err = json.Unmarshal(contents, &hookDetails)
|
err = json.NewDecoder(response.Body).Decode(&hookDetails)
|
||||||
if err != nil {
|
return &hookDetails, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &hookDetails, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetHooks(owner string, name string) (*HookSettings, error) {
|
func (c *Client) GetHooks(owner string, name string) (*HookSettings, error) {
|
||||||
|
@ -197,13 +193,9 @@ func (c *Client) GetHooks(owner string, name string) (*HookSettings, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
contents, err := ioutil.ReadAll(response.Body)
|
|
||||||
hookSettings := HookSettings{}
|
hookSettings := HookSettings{}
|
||||||
err = json.Unmarshal(contents, &hookSettings)
|
err = json.NewDecoder(response.Body).Decode(&hookSettings)
|
||||||
if err != nil {
|
return &hookSettings, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &hookSettings, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: make these as as general do with the action
|
//TODO: make these as as general do with the action
|
||||||
|
@ -277,7 +269,7 @@ func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func filter(vs []string, f func(string) bool) []string {
|
func filter(vs []string, f func(string) bool) []string {
|
||||||
vsf := make([]string, 0)
|
var vsf []string
|
||||||
for _, v := range vs {
|
for _, v := range vs {
|
||||||
if f(v) {
|
if f(v) {
|
||||||
vsf = append(vsf, v)
|
vsf = append(vsf, v)
|
||||||
|
@ -341,7 +333,7 @@ func arrayToHookSettings(hooks []string) HookSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
func hookSettingsToArray(hookSettings *HookSettings) []string {
|
func hookSettingsToArray(hookSettings *HookSettings) []string {
|
||||||
hooks := make([]string, 0)
|
var hooks []string
|
||||||
|
|
||||||
if hookSettings.HookURL0 != "" {
|
if hookSettings.HookURL0 != "" {
|
||||||
hooks = append(hooks, hookSettings.HookURL0)
|
hooks = append(hooks, hookSettings.HookURL0)
|
||||||
|
|
Loading…
Reference in a new issue