MCPcopy Create free account
hub / github.com/cloudbase/garm / GetEntityHook

Method GetEntityHook

util/github/client.go:75–102  ·  view source on GitHub ↗
(ctx context.Context, id int64)

Source from the content-addressed store, hash-verified

73}
74
75func (g *githubClient) GetEntityHook(ctx context.Context, id int64) (ret *github.Hook, err error) {
76 metrics.GithubOperationCount.WithLabelValues(
77 "GetHook", // label: operation
78 g.entity.LabelScope(), // label: scope
79 ).Inc()
80 defer func() {
81 if err != nil {
82 metrics.GithubOperationFailedCount.WithLabelValues(
83 "GetHook", // label: operation
84 g.entity.LabelScope(), // label: scope
85 ).Inc()
86 }
87 }()
88 var response *github.Response
89 switch g.entity.EntityType {
90 case params.ForgeEntityTypeRepository:
91 ret, response, err = g.repo.GetHook(ctx, g.entity.Owner, g.entity.Name, id)
92 case params.ForgeEntityTypeOrganization:
93 ret, response, err = g.org.GetHook(ctx, g.entity.Owner, id)
94 default:
95 return nil, errors.New("invalid entity type")
96 }
97
98 if err == nil && response != nil {
99 g.recordLimits(response.Rate)
100 }
101 return ret, err
102}
103
104func (g *githubClient) createGithubEntityHook(ctx context.Context, hook *github.Hook) (ret *github.Hook, err error) {
105 metrics.GithubOperationCount.WithLabelValues(

Callers

nothing calls this directly

Calls 2

recordLimitsMethod · 0.95
LabelScopeMethod · 0.80

Tested by

no test coverage detected