feat: artifacts client
All checks were successful
default / ensure tests work (push) Successful in 29s
All checks were successful
default / ensure tests work (push) Successful in 29s
This commit is contained in:
parent
24ad00274d
commit
402ecfd760
1 changed files with 1162 additions and 6 deletions
33
artifact/client.go
Normal file
33
artifact/client.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Package artifact provides a client for the GitHub Actions results service.
|
||||
// The results service exposes the ArtifactService twirp API and the Azure
|
||||
// block-blob storage used to upload and download workflow artifacts.
|
||||
package artifact
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.geekeey.de/actions/sdk"
|
||||
)
|
||||
|
||||
// Client talks to the results service. It authorizes every request with the
|
||||
// action runtime token and resolves relative URLs against the results URL.
|
||||
type Client struct {
|
||||
http *sdk.Client
|
||||
}
|
||||
|
||||
// NewClient returns a client that authenticates against the results service at
|
||||
// base using the given runtime token.
|
||||
func NewClient(base, runtimeToken string) *Client {
|
||||
return &Client{http: sdk.NewClient(base, runtimeToken)}
|
||||
}
|
||||
|
||||
// NewClientFromEnv returns a client configured from the ACTIONS_RESULTS_URL and
|
||||
// ACTIONS_RUNTIME_TOKEN environment variables.
|
||||
func NewClientFromEnv(env func(string) string) *Client {
|
||||
return NewClient(env("ACTIONS_RESULTS_URL"), env("ACTIONS_RUNTIME_TOKEN"))
|
||||
}
|
||||
|
||||
// Do implements the request executor used by the twirp methods.
|
||||
func (c *Client) Do(req *http.Request) (*http.Response, error) {
|
||||
return c.http.Do(req)
|
||||
}
|
||||
Loading…
Reference in a new issue