downloader

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 7

Documentation

Overview

Copyright 2022 The KCL Authors. All rights reserved.

Index

Constants

View Source
const GIT_BRANCH_FLAG = "branch"
View Source
const GIT_BRANCH_PATTERN = "branch = \"%s\""
View Source
const GIT_COMMIT_FLAG = "commit"
View Source
const GIT_COMMIT_PATTERN = "commit = \"%s\""
View Source
const GIT_URL_FLAG = "git"
View Source
const GIT_URL_PATTERN = "git = \"%s\""
View Source
const LOCAL_PATH_FLAG = "path"
View Source
const LOCAL_PATH_PATTERN = "path = %s"
View Source
const NEWLINE = "\n"
View Source
const OCI_URL_PATTERN = "oci = \"%s\""
View Source
const SEPARATOR = ", "
View Source
const SOURCE_PATTERN = "{ %s }"
View Source
const TAG_FLAG = "tag"
View Source
const TAG_PATTERN = "tag = \"%s\""
View Source
const VERSION_PATTERN = "version = \"%s\""

Variables

This section is empty.

Functions

func ParseSourceUrlFrom added in v0.9.0

func ParseSourceUrlFrom(sourceStr string, settings *settings.Settings) (*url.URL, error)

Types

type CredClient added in v0.9.1

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

CredClient is the client to get the credentials.

func LoadCredentialFile added in v0.9.1

func LoadCredentialFile(filepath string) (*CredClient, error)

LoadCredentialFile loads the credential file and return the CredClient.

func (*CredClient) Credential added in v0.9.1

func (cred *CredClient) Credential(hostName string) (*remoteauth.Credential, error)

Credential will reture the credential info cache in CredClient

func (*CredClient) GetAuthClient added in v0.9.1

func (cred *CredClient) GetAuthClient() *dockerauth.Client

GetAuthClient returns the auth client.

type DepDownloader

type DepDownloader struct {
	*OciDownloader
	*GitDownloader
}

DepDownloader is the downloader for the package. Only support the OCI and git source.

func NewOciDownloader

func NewOciDownloader(platform string) *DepDownloader

func (*DepDownloader) Download

func (d *DepDownloader) Download(opts DownloadOptions) error

type DownloadOptions

type DownloadOptions struct {
	// LocalPath is the local path to download the package.
	LocalPath string
	// Source is the source of the package. including git, oci, local.
	Source Source
	// Settings is the default settings and authrization information.
	Settings settings.Settings
	// LogWriter is the writer to write the log.
	LogWriter io.Writer
	// contains filtered or unexported fields
}

DownloadOptions is the options for downloading a package.

func NewDownloadOptions

func NewDownloadOptions(opts ...Option) *DownloadOptions

type Downloader

type Downloader interface {
	Download(opts DownloadOptions) error
}

Downloader is the interface for downloading a package.

type Git added in v0.9.0

type Git struct {
	Url     string `toml:"url,omitempty"`
	Branch  string `toml:"branch,omitempty"`
	Commit  string `toml:"commit,omitempty"`
	Tag     string `toml:"git_tag,omitempty"`
	Version string `toml:"version,omitempty"`
}

Git is the package source from git registry.

func (*Git) FromString added in v0.9.0

func (git *Git) FromString(gitStr string) error

func (*Git) GetValidGitReference added in v0.9.0

func (git *Git) GetValidGitReference() (string, error)

GetValidGitReference will get the valid git reference from git source. Only one of branch, tag or commit is allowed.

func (*Git) MarshalTOML added in v0.9.0

func (git *Git) MarshalTOML() string

func (*Git) ToFilePath added in v0.9.0

func (git *Git) ToFilePath() (string, error)

func (*Git) ToString added in v0.9.0

func (git *Git) ToString() (string, error)

func (*Git) UnmarshalModTOML added in v0.9.0

func (git *Git) UnmarshalModTOML(data interface{}) error

type GitDownloader

type GitDownloader struct{}

GitDownloader is the downloader for the git source.

func (*GitDownloader) Download

func (d *GitDownloader) Download(opts DownloadOptions) error

type Local added in v0.9.0

type Local struct {
	Path string `toml:"path,omitempty"`
}

func (*Local) FindRootPath added in v0.9.0

func (local *Local) FindRootPath() (string, error)

func (*Local) FromString added in v0.9.0

func (local *Local) FromString(localStr string) error

func (*Local) IsDir added in v0.9.0

func (local *Local) IsDir() bool

func (*Local) IsLocalKPath added in v0.9.0

func (local *Local) IsLocalKPath() bool

func (*Local) IsLocalTarPath added in v0.9.0

func (local *Local) IsLocalTarPath() bool

func (*Local) IsLocalTgzPath added in v0.9.1

func (local *Local) IsLocalTgzPath() bool

func (*Local) MarshalTOML added in v0.9.0

func (local *Local) MarshalTOML() string

func (*Local) ToFilePath added in v0.9.0

func (local *Local) ToFilePath() (string, error)

func (*Local) ToString added in v0.9.0

func (local *Local) ToString() (string, error)

func (*Local) UnmarshalModTOML added in v0.9.0

func (local *Local) UnmarshalModTOML(data interface{}) error

type Oci added in v0.9.0

type Oci struct {
	Reg  string `toml:"reg,omitempty"`
	Repo string `toml:"repo,omitempty"`
	Tag  string `toml:"oci_tag,omitempty"`
}

func (*Oci) FromString added in v0.9.0

func (oci *Oci) FromString(ociStr string) error

func (*Oci) IntoOciUrl deprecated added in v0.9.0

func (oci *Oci) IntoOciUrl() string

Deprecated: Use ToString instead

func (*Oci) MarshalTOML added in v0.9.0

func (oci *Oci) MarshalTOML() string

func (*Oci) ToFilePath added in v0.9.0

func (oci *Oci) ToFilePath() (string, error)

func (*Oci) ToString added in v0.9.0

func (oci *Oci) ToString() (string, error)

func (*Oci) UnmarshalModTOML added in v0.9.0

func (oci *Oci) UnmarshalModTOML(data interface{}) error

type OciDownloader

type OciDownloader struct {
	Platform string
}

OciDownloader is the downloader for the OCI source.

func (*OciDownloader) Download

func (d *OciDownloader) Download(opts DownloadOptions) error

type Option

type Option func(*DownloadOptions)

func WithCredsClient added in v0.9.1

func WithCredsClient(credsClient *CredClient) Option

func WithLocalPath

func WithLocalPath(localPath string) Option

func WithLogWriter

func WithLogWriter(logWriter io.Writer) Option

func WithSettings

func WithSettings(settings settings.Settings) Option

func WithSource

func WithSource(source Source) Option

type Platform

type Platform struct {
	PlatformSpec string
	Platform     *v1.Platform
}

Platform option struct.

type Registry added in v0.9.0

type Registry struct {
	*Oci    `toml:"-"`
	Name    string `toml:"-"`
	Version string `toml:"-"`
}

func (*Registry) FromString added in v0.9.0

func (registry *Registry) FromString(registryStr string) error

default::oci://ghcr.io/kcl-lang/k8s?name=k8s?version=0.1.1

func (*Registry) MarshalTOML added in v0.9.0

func (registry *Registry) MarshalTOML() string

func (*Registry) ToFilePath added in v0.9.0

func (registry *Registry) ToFilePath() (string, error)

func (*Registry) ToString added in v0.9.0

func (registry *Registry) ToString() (string, error)

func (*Registry) UnmarshalModTOML added in v0.9.0

func (reg *Registry) UnmarshalModTOML(data interface{}) error

type Source added in v0.9.0

type Source struct {
	*Registry
	*Git
	*Oci
	*Local `toml:"-"`
}

Source is the package source from registry.

func NewSourceFromStr added in v0.9.0

func NewSourceFromStr(sourceStr string) (*Source, error)

func (*Source) FindRootPath added in v0.9.0

func (source *Source) FindRootPath() (string, error)

func (*Source) FromString added in v0.9.0

func (source *Source) FromString(sourceStr string) error

func (*Source) IsLocalPath added in v0.9.0

func (source *Source) IsLocalPath() bool

func (*Source) IsLocalTarPath added in v0.9.0

func (source *Source) IsLocalTarPath() bool

func (*Source) IsLocalTgzPath added in v0.9.1

func (source *Source) IsLocalTgzPath() bool

func (*Source) IsPackaged added in v0.9.0

func (source *Source) IsPackaged() bool

func (*Source) IsRemote added in v0.9.1

func (source *Source) IsRemote() bool

func (*Source) MarshalTOML added in v0.9.0

func (source *Source) MarshalTOML() string

func (*Source) ToFilePath added in v0.9.0

func (source *Source) ToFilePath() (string, error)

func (*Source) ToString added in v0.9.0

func (source *Source) ToString() (string, error)

func (*Source) UnmarshalModTOML added in v0.9.0

func (source *Source) UnmarshalModTOML(data interface{}) error

Jump to

Keyboard shortcuts

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