feat(actions): simplify macro parsing (#560)

* refactor(action): parse macros

* feat(action): add ctx to arr clients and test
This commit is contained in:
ze0s 2022-12-10 21:48:19 +01:00 committed by GitHub
parent f6e68fae2b
commit 839eb9f3f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 323 additions and 334 deletions

View file

@ -1,6 +1,7 @@
package radarr
import (
"context"
"encoding/json"
"fmt"
"io"
@ -25,8 +26,8 @@ type Config struct {
}
type Client interface {
Test() (*SystemStatusResponse, error)
Push(release Release) ([]string, error)
Test(ctx context.Context) (*SystemStatusResponse, error)
Push(ctx context.Context, release Release) ([]string, error)
}
type client struct {
@ -88,8 +89,8 @@ func (r *BadRequestResponse) String() string {
return fmt.Sprintf("[%v: %v] %v: %v - got value: %v", r.Severity, r.ErrorCode, r.PropertyName, r.ErrorMessage, r.AttemptedValue)
}
func (c *client) Test() (*SystemStatusResponse, error) {
status, res, err := c.get("system/status")
func (c *client) Test(ctx context.Context) (*SystemStatusResponse, error) {
status, res, err := c.get(ctx, "system/status")
if err != nil {
return nil, errors.Wrap(err, "radarr error running test")
}
@ -108,8 +109,8 @@ func (c *client) Test() (*SystemStatusResponse, error) {
return &response, nil
}
func (c *client) Push(release Release) ([]string, error) {
status, res, err := c.postBody("release/push", release)
func (c *client) Push(ctx context.Context, release Release) ([]string, error) {
status, res, err := c.postBody(ctx, "release/push", release)
if err != nil {
return nil, errors.Wrap(err, "error push release")
}