Documentation ¶
Index ¶
- Constants
- func IsRelative(link string) bool
- func IsResourceURL(link string) bool
- func RawURL(resourceURL string) (string, error)
- func ReadGitInfo(ctx context.Context, repositories Repositories, r URL) ([]byte, error)
- type Credential
- type ErrResourceNotFound
- type Git
- type GitInfo
- type InitOptions
- type Interface
- type Local
- func (l *Local) Accept(link string) bool
- func (l *Local) GetClient() httpclient.Client
- func (l *Local) GetRateLimit(ctx context.Context) (int, int, time.Time, error)
- func (l *Local) LoadRepository(ctx context.Context, resourceURL string) error
- func (l *Local) Name() string
- func (l *Local) Read(_ context.Context, resource URL) ([]byte, error)
- func (l *Local) Repositories() Repositories
- func (l *Local) ResolveRelativeLink(source URL, relativeLink string) (string, error)
- func (l *Local) ResourceURL(resourceURL string) (*URL, error)
- func (l *Local) Tree(resource URL) ([]string, error)
- type ParsingOptions
- type RateLimitSource
- type Repositories
- type URL
- func (r URL) GetDifferentType(newType string) (string, error)
- func (r URL) GetHost() string
- func (r URL) GetOwner() string
- func (r URL) GetRef() string
- func (r URL) GetRepo() string
- func (r URL) GetResourcePath() string
- func (r URL) GetResourceSuffix() string
- func (r URL) GetResourceType() string
- func (r URL) ReferenceURL() URL
- func (r URL) ResolveRelativeLink(relativeLink string) (string, string, error)
- func (r URL) ResourceURL() string
- func (r URL) String() string
Constants ¶
const (
// DateFormat defines format for LastModifiedDate & PublishDate
DateFormat = "2006-01-02 15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
func IsRelative ¶
IsRelative is a helper function that checks if a link is relative
func IsResourceURL ¶
IsResourceURL checks if link is resource URL
func RawURL ¶
RawURL returns the GitHub raw URL if the resource is 'blob', otherwise returns the origin URL
func ReadGitInfo ¶
ReadGitInfo reads the git info for a given resource URL
Types ¶
type Credential ¶
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
Error returns "resource r not found" error
type Git ¶
type Git interface { GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *github.Response, error) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*github.Tree, *github.Response, error) }
Git is an interface needed for faking
type GitInfo ¶
type GitInfo struct { LastModifiedDate *string `json:"lastmod,omitempty"` PublishDate *string `json:"publishdate,omitempty"` Author *github.User `json:"author,omitempty"` Contributors []*github.User `json:"contributors,omitempty"` WebURL *string `json:"weburl,omitempty"` SHA *string `json:"sha,omitempty"` SHAAlias *string `json:"shaalias,omitempty"` Path *string `json:"path,omitempty"` }
GitInfo defines git resource attributes
type InitOptions ¶
type InitOptions 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"` }
InitOptions options for the resource handler
type Interface ¶
type Interface interface { // ResourceURL returns a valid resource url object from a string url ResourceURL(resourceURL string) (*URL, error) // ResolveRelativeLink resolves a relative link given a source resource url ResolveRelativeLink(source URL, relativeLink string) (string, error) // LoadRepository loads the content of the repository of a given url LoadRepository(ctx context.Context, resourceURL string) error // Tree returns files that are present in the given url tree Tree(resource URL) ([]string, error) // Accept accepts manifests if this RepositoryHost can manage the type of resources identified by the URI scheme of uri. Accept(link string) bool // Read a resource content at uri into a byte array Read(ctx context.Context, resource URL) ([]byte, error) // Name of repository host Name() string // Repositories returns the repositories object Repositories() Repositories // 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) }
Interface does resource specific operations on a type of objects identified by an uri schema that it accepts to handle
func NewGHC ¶
func NewGHC(hostName string, rateLimit RateLimitSource, repositories Repositories, git Git, client httpclient.Client, acceptedHosts []string, options ParsingOptions) Interface
NewGHC creates new GHC resource handler
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local represents a local repository defined by respurce mapping
func (*Local) GetRateLimit ¶
GetRateLimit is not implemented
func (*Local) LoadRepository ¶
LoadRepository does nothing
func (*Local) ResolveRelativeLink ¶
ResolveRelativeLink resolves a relative link given a source resource url
func (*Local) ResourceURL ¶
ResourceURL returns a valid resource url object from a string url
type ParsingOptions ¶
type ParsingOptions struct { ExtractedFilesFormats []string `mapstructure:"extracted-files-formats"` Hugo bool `mapstructure:"hugo"` }
ParsingOptions are options when parsing
type RateLimitSource ¶
type RateLimitSource interface {
RateLimits(ctx context.Context) (*github.RateLimits, *github.Response, error)
}
RateLimitSource is an interface needed for faking
type Repositories ¶
type Repositories interface { ListCommits(ctx context.Context, owner, repo string, opts *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error) Get(ctx context.Context, owner, repo string) (*github.Repository, *github.Response, error) }
Repositories is an interface needed for faking
type URL ¶
type URL struct {
// contains filtered or unexported fields
}
URL represents an repsource url
func (URL) GetDifferentType ¶
GetDifferentType returns the url string of the given resource but with a different type
func (URL) GetResourcePath ¶
GetResourcePath returns the resource path of the URL
func (URL) GetResourceSuffix ¶
GetResourceSuffix returns the resource suffix of the URL
func (URL) GetResourceType ¶
GetResourceType returns the resource type of the URL
func (URL) ReferenceURL ¶
ReferenceURL returns the reference url object
func (URL) ResolveRelativeLink ¶
ResolveRelativeLink returns the possible blob and tree url string of a given relative link
func (URL) ResourceURL ¶
ResourceURL returns the resource url without resource suffix
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
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 |