feat: Add actions policies endpoints - #4604
Bobrovskii wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4604 +/- ##
==========================================
+ Coverage 98.60% 98.61% +0.01%
==========================================
Files 198 199 +1
Lines 18538 18647 +109
==========================================
+ Hits 18279 18389 +110
+ Misses 259 258 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Bobrovskii - please fix the linter errors by running |
|
Fixed the linter issues and the missing test coverage. Thanks |
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @Bobrovskii!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
| return policies, resp, nil | ||
| } | ||
|
|
||
| func (s *ActionsService) createPolicy(ctx context.Context, u string, body ActionsPolicy) (*ActionsPolicy, *Response, error) { |
There was a problem hiding this comment.
ActionsPolicy contains some extra fields that aren't needed when creating a policy. Can we introduce a new request struct for this?
| return policy, resp, nil | ||
| } | ||
|
|
||
| func (s *ActionsService) updatePolicy(ctx context.Context, u string, body ActionsPolicy) (*ActionsPolicy, *Response, error) { |
There was a problem hiding this comment.
Same here, some extra fields that aren't needed when updating a policy.
| type ActionsPolicy struct { | ||
| ID *int64 `json:"id,omitempty"` | ||
| Name *string `json:"name,omitempty"` | ||
| Target *ActionsPolicyTarget `json:"target,omitempty"` | ||
| SourceType *RulesetSourceType `json:"source_type,omitempty"` | ||
| Source *string `json:"source,omitempty"` | ||
| Enforcement *RulesetEnforcement `json:"enforcement,omitempty"` | ||
| Conditions *ActionsPolicyConditions `json:"conditions,omitempty"` | ||
| Rules []*ActionsPolicyRule `json:"rules,omitzero"` | ||
| NodeID *string `json:"node_id,omitempty"` | ||
| Links *RepositoryRulesetLinks `json:"_links,omitempty"` | ||
| CreatedAt *Timestamp `json:"created_at,omitempty"` | ||
| UpdatedAt *Timestamp `json:"updated_at,omitempty"` | ||
| } |
There was a problem hiding this comment.
| type ActionsPolicy struct { | |
| ID *int64 `json:"id,omitempty"` | |
| Name *string `json:"name,omitempty"` | |
| Target *ActionsPolicyTarget `json:"target,omitempty"` | |
| SourceType *RulesetSourceType `json:"source_type,omitempty"` | |
| Source *string `json:"source,omitempty"` | |
| Enforcement *RulesetEnforcement `json:"enforcement,omitempty"` | |
| Conditions *ActionsPolicyConditions `json:"conditions,omitempty"` | |
| Rules []*ActionsPolicyRule `json:"rules,omitzero"` | |
| NodeID *string `json:"node_id,omitempty"` | |
| Links *RepositoryRulesetLinks `json:"_links,omitempty"` | |
| CreatedAt *Timestamp `json:"created_at,omitempty"` | |
| UpdatedAt *Timestamp `json:"updated_at,omitempty"` | |
| } | |
| type ActionsPolicy struct { | |
| ID int64 `json:"id"` | |
| Name string `json:"name"` | |
| Target ActionsPolicyTarget `json:"target"` | |
| SourceType RulesetSourceType `json:"source_type"` | |
| Source string `json:"source"` | |
| Enforcement RulesetEnforcement `json:"enforcement"` | |
| Conditions *ActionsPolicyConditions `json:"conditions,omitempty"` | |
| Rules []*ActionsPolicyRule `json:"rules,omitzero"` | |
| NodeID *string `json:"node_id,omitempty"` | |
| Links *RepositoryRulesetLinks `json:"_links,omitempty"` | |
| CreatedAt *Timestamp `json:"created_at,omitempty"` | |
| UpdatedAt *Timestamp `json:"updated_at,omitempty"` | |
| } |
We don't use omitempty with required fields.
"required": [
"id",
"name",
"target",
"source_type",
"source",
"enforcement"
],
Add actions policies endpoints
Fixes: #4583