feat!: Replace actions env secret endpoints#4335
Conversation
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
| if body.Name == "" { | ||
| return nil, errors.New("secret name must be provided") |
There was a problem hiding this comment.
We usually don't add such checks to other endpoint methods.
The field Name is without omitempty, which means "required".
There was a problem hiding this comment.
It's used to construct the URL, which is why I think the previous signature had nil checks (although an uninitialized struct would still cause issues).
There was a problem hiding this comment.
Now I understand. In that way, we should add a new parameter.
There was a problem hiding this comment.
A new parameter or a new request type (as per below)?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4335 +/- ##
==========================================
+ Coverage 97.48% 97.50% +0.01%
==========================================
Files 193 193
Lines 19417 19451 +34
==========================================
+ Hits 18929 18965 +36
+ Misses 270 269 -1
+ Partials 218 217 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body *EncryptedSecret) (*Response, error) { | ||
| if body == nil { | ||
| return nil, errors.New("encrypted secret must be provided") | ||
| func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body EncryptedSecret) (*Response, error) { |
There was a problem hiding this comment.
| func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body EncryptedSecret) (*Response, error) { | |
| func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo, secretName string, body CreateOrUpdateRepoSecretRequest) (*Response, error) { |
type CreateOrUpdateRepoSecretRequest struct {
KeyID string `json:"key_id"`
EncryptedValue string `json:"encrypted_value"`
}
There was a problem hiding this comment.
The similar for other endpoints
There was a problem hiding this comment.
Yeah, I'd considered doing this but didn't want to shave the yak, but I think that boat has sailed now. How about SecretRequest (for repo and env) and OrgSecretRequest; I'd like to think that this endpoint will eventually be replaced with separate endpoints for create and update. The Dependabot endpoints could use the same types, although I'm not sure we want to make that change in this PR?
There was a problem hiding this comment.
Currently, these ActionsService endpoints are completely broken. We can fix them whenever needed. And adding new structs won't break Dependabot endpoints.
This PR updates the actions environment secrets functions to use the documented and supported endpoints, it also changes all actions secret create/update functions to use a value parameter (#3644).