repositoryhosts

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Host       string
	OAuthToken string
}

Credential holds repository credential data

type ErrResourceNotFound

type ErrResourceNotFound string

ErrResourceNotFound indicated that a resource was not found

func (ErrResourceNotFound) Error

func (e ErrResourceNotFound) Error() string

type Registry

type Registry interface {
	Get(uri string) (RepositoryHost, error)
	LogRateLimits(ctx context.Context)
}

Registry can register and return resource repoHosts for an url

func NewRegistry

func NewRegistry(resourcerepoHosts ...RepositoryHost) Registry

NewRegistry creates Registry object, optionally loading it with resourcerepoHosts if provided

type RepositoryHost

type RepositoryHost interface {
	//ManifestFromURL Gets the manifest content from a given url
	ManifestFromURL(url string) (string, error)
	//FileTreeFromURL Get files that are present in the given url tree
	FileTreeFromURL(url string) ([]string, error)
	//ToAbsLink Builds the abs link given where it is referenced
	ToAbsLink(source, link string) (string, error)
	// Accept accepts manifests if this RepositoryHost can manage the type of resources identified by the URI scheme of uri.
	Accept(uri string) bool
	// Read a resource content at uri into a byte array
	Read(ctx context.Context, uri string) ([]byte, error)
	// ReadGitInfo reads git info for the resource
	ReadGitInfo(ctx context.Context, uri string) ([]byte, error)
	// GetRawFormatLink returns a link to an embeddable object (image) in raw format.
	// If the provided link is not referencing an embeddable object, the function returns absLink without changes.
	GetRawFormatLink(absLink string) (string, error)
	// Name of repository host
	Name() string
	// GetClient returns an HTTP client for accessing handler's resources
	GetClient() httpclient.Client
	// GetRateLimit returns rate limit and remaining API calls for the resource handler backend (e.g. GitHub RateLimit)
	// returns negative values if RateLimit is not applicable
	GetRateLimit(ctx context.Context) (int, int, time.Time, error)
}

RepositoryHost does resource specific operations on a type of objects identified by an uri schema that it accepts to handle

type RepositoryHostOptions

type RepositoryHostOptions struct {
	CacheHomeDir     string            `mapstructure:"cache-dir"`
	Credentials      map[string]string `mapstructure:"github-oauth-token-map"`
	ResourceMappings map[string]string `mapstructure:"resourceMappings"`
	Hugo             bool              `mapstructure:"hugo"`
}

RepositoryHostOptions options for the resource handler

Directories

Path Synopsis
githubhttpcachefakes
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors

Jump to

Keyboard shortcuts

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