gitlab

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClientError added in v0.0.7

func IsClientError(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsServerError added in v0.0.7

func IsServerError(err error) bool

func IsUnauthorized added in v0.0.7

func IsUnauthorized(err error) bool

Types

type CacheOptions

type CacheOptions struct {
	CacheTTL      time.Duration
	CacheErrorTTL time.Duration
}

CacheOptions holds cache behaviour configuration.

type CachingClient

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

CachingClient wraps ClientInterface to add caching.

func NewCachingClient

func NewCachingClient(client ClientInterface, agentInfoCacheOptions CacheOptions, projectInfoCacheOptions CacheOptions) *CachingClient

func (*CachingClient) GetAgentInfo

func (c *CachingClient) GetAgentInfo(ctx context.Context, agentMeta *api.AgentMeta) (*api.AgentInfo, error)

func (*CachingClient) GetProjectInfo

func (c *CachingClient) GetProjectInfo(ctx context.Context, agentMeta *api.AgentMeta, projectId string) (*api.ProjectInfo, error)

func (*CachingClient) Run

func (c *CachingClient) Run(ctx context.Context)

func (*CachingClient) SendUsage added in v0.0.4

func (c *CachingClient) SendUsage(ctx context.Context, data *UsageData) error

type Client

type Client struct {
	Backend    *url.URL
	HTTPClient HTTPClient
	AuthSecret []byte
	UserAgent  string
}

func NewClient

func NewClient(backend *url.URL, authSecret []byte, opts ...ClientOption) *Client

func (*Client) GetAgentInfo

func (c *Client) GetAgentInfo(ctx context.Context, meta *api.AgentMeta) (*api.AgentInfo, error)

func (*Client) GetProjectInfo

func (c *Client) GetProjectInfo(ctx context.Context, meta *api.AgentMeta, projectId string) (*api.ProjectInfo, error)

func (*Client) SendUsage added in v0.0.4

func (c *Client) SendUsage(ctx context.Context, data *UsageData) error

type ClientError

type ClientError struct {
	Kind       ErrorKind
	StatusCode int
}

func (*ClientError) Error

func (c *ClientError) Error() string

type ClientInterface

type ClientInterface interface {
	GetAgentInfo(ctx context.Context, agentMeta *api.AgentMeta) (*api.AgentInfo, error)
	GetProjectInfo(ctx context.Context, agentMeta *api.AgentMeta, projectId string) (*api.ProjectInfo, error)
	SendUsage(ctx context.Context, data *UsageData) error
}

type ClientOption added in v0.0.7

type ClientOption func(*clientConfig)

ClientOption to configure the client.

func WithCorrelationClientName added in v0.0.7

func WithCorrelationClientName(clientName string) ClientOption

WithCorrelationClientName configures the X-GitLab-Client-Name header on the http client.

func WithLogger added in v0.0.7

func WithLogger(log *zap.Logger) ClientOption

WithLogger sets the log to use.

func WithTracer added in v0.0.7

func WithTracer(tracer opentracing.Tracer) ClientOption

WithTracer sets a custom tracer to be used, otherwise the opentracing.GlobalTracer is used.

func WithUserAgent added in v0.0.7

func WithUserAgent(userAgent string) ClientOption

WithUserAgent configures the User-Agent header on the http client.

type ErrorKind

type ErrorKind int
const (
	ErrorKindOther ErrorKind = iota
	ErrorKindForbidden
	ErrorKindUnauthorized
)

type HTTPClient

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

type UsageData added in v0.0.4

type UsageData struct {
	GitopsSyncCount int64 `json:"gitops_sync_count"`
}

Directories

Path Synopsis
Mocks for GitLab client.
Mocks for GitLab client.

Jump to

Keyboard shortcuts

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