admin

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg Config, opts ...Option) (*Client, error)

func (*Client) DoJSON

func (c *Client) DoJSON(ctx context.Context, method, path string, in, out any) error

func (*Client) DoUnsigned

func (c *Client) DoUnsigned(ctx context.Context, method, rawURL string) (RawResponse, error)

DoUnsigned performs an unsigned request for server-generated signed URLs, such as cookbook and sandbox blob download links returned by Chef APIs.

func (*Client) NewJSONRequest

func (c *Client) NewJSONRequest(ctx context.Context, method, path string, body []byte) (*http.Request, error)

type Config

type Config struct {
	ServerURL        string
	RequestorName    string
	RequestorType    string
	PrivateKeyPath   string
	DefaultOrg       string
	ServerAPIVersion string
}

func LoadConfigFromEnv

func LoadConfigFromEnv() Config

func (*Config) BindFlags

func (c *Config) BindFlags(fs *flag.FlagSet)

func (Config) String

func (c Config) String() string

type Error

type Error struct {
	Code    ErrorCode
	Message string
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string
const (
	CodeInvalidConfiguration ErrorCode = "invalid_configuration"
	CodeRequestFailed        ErrorCode = "request_failed"
	CodeDecodeFailed         ErrorCode = "decode_failed"
	CodeSigningFailed        ErrorCode = "signing_failed"
)

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

type Option

type Option func(*Client)

func WithHTTPDoer

func WithHTTPDoer(doer HTTPDoer) Option

func WithNow

func WithNow(now func() time.Time) Option

func WithPrivateKey

func WithPrivateKey(key *rsa.PrivateKey) Option

type RawResponse

type RawResponse struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

RawResponse carries the minimal response data admin tooling needs when it follows non-JSON signed blob URLs during migration validation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL