Documentation ¶
Overview ¶
Copyright 2022 The KCL Authors. All rights reserved.
Index ¶
- Constants
- Variables
- func FindPackageByModSpec(root string, modSpec *ModSpec) (string, error)
- func ParseSourceUrlFrom(sourceStr string, settings *settings.Settings) (*url.URL, error)
- type CredClient
- type DepDownloader
- type DownloadOptions
- type Downloader
- type Git
- func (git *Git) FromString(gitStr string) error
- func (git *Git) GetPackage() string
- func (g *Git) GetRef() string
- func (git *Git) GetValidGitReference() (string, error)
- func (g *Git) Hash() (string, error)
- func (git *Git) MarshalTOML() string
- func (g *Git) NoRef() bool
- func (git *Git) ToFilePath() (string, error)
- func (git *Git) ToString() (string, error)
- func (git *Git) UnmarshalModTOML(data interface{}) error
- type GitDownloader
- type Local
- func (local *Local) FindRootPath() (string, error)
- func (local *Local) FromString(localStr string) error
- func (l *Local) Hash() (string, error)
- func (local *Local) IsDir() bool
- func (local *Local) IsLocalKPath() bool
- func (local *Local) IsLocalTarPath() bool
- func (local *Local) IsLocalTgzPath() bool
- func (local *Local) MarshalTOML() string
- func (local *Local) ToFilePath() (string, error)
- func (local *Local) ToString() (string, error)
- func (local *Local) UnmarshalModTOML(data interface{}) error
- type ModSpec
- type Oci
- func (oci *Oci) FromString(ociStr string) error
- func (o *Oci) GetRef() string
- func (o *Oci) Hash() (string, error)
- func (oci *Oci) IntoOciUrl() stringdeprecated
- func (oci *Oci) MarshalTOML() string
- func (o *Oci) NoRef() bool
- func (oci *Oci) ToFilePath() (string, error)
- func (oci *Oci) ToString() (string, error)
- func (oci *Oci) UnmarshalModTOML(data interface{}) error
- type OciDownloader
- type Option
- func WithCachePath(cachePath string) Option
- func WithCredsClient(credsClient *CredClient) Option
- func WithEnableCache(enableCache bool) Option
- func WithInsecureSkipTLSverify(insecureSkipTLSverify bool) Option
- func WithLocalPath(localPath string) Option
- func WithLogWriter(logWriter io.Writer) Option
- func WithOffline(offline bool) Option
- func WithSettings(settings settings.Settings) Option
- func WithSource(source Source) Option
- type Platform
- type Source
- func (s *Source) CachePath(root string) string
- func (source *Source) FindRootPath() (string, error)
- func (source *Source) FromString(sourceStr string) error
- func (s *Source) Hash() (string, error)
- func (source *Source) IsLocalPath() bool
- func (source *Source) IsLocalPkg() bool
- func (source *Source) IsLocalTarPath() bool
- func (source *Source) IsLocalTgzPath() bool
- func (source *Source) IsNilSource() bool
- func (source *Source) IsPackaged() bool
- func (source *Source) IsRemote() bool
- func (s *Source) LocalPath(root string) string
- func (source *Source) MarshalTOML() string
- func (s *Source) SpecOnly() bool
- func (source *Source) ToFilePath() (string, error)
- func (source *Source) ToString() (string, error)
- func (s *Source) Type() string
- func (source *Source) UnmarshalModTOML(data interface{}) error
Constants ¶
const DEP_PATTERN = "%s = %s"
const GIT_BRANCH_FLAG = "branch"
const GIT_BRANCH_PATTERN = "branch = \"%s\""
const GIT_COMMIT_FLAG = "commit"
const GIT_COMMIT_PATTERN = "commit = \"%s\""
const GIT_PACKAGE = "package = \"%s\""
const GIT_PACKAGE_FLAG = "package"
const GIT_URL_FLAG = "git"
const GIT_URL_PATTERN = "git = \"%s\""
const LOCAL_PATH_FLAG = "path"
const LOCAL_PATH_PATTERN = "path = %s"
const NEWLINE = "\n"
const OCI_URL_PATTERN = "oci = \"%s\""
const SEPARATOR = ", "
const SOURCE_PATTERN = "{ %s }"
const SPEC_PATTERN = "%s = %q"
const TAG_FLAG = "tag"
const TAG_PATTERN = "tag = \"%s\""
const VERSION_PATTERN = "version = \"%s\""
Variables ¶
var ErrNotFoundAndOffline = errors.New("not found and offline")
Functions ¶
func FindPackageByModSpec ¶ added in v0.11.0
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
func (*DepDownloader) LatestVersion ¶ added in v0.11.0
func (d *DepDownloader) LatestVersion(opts *DownloadOptions) (string, error)
type DownloadOptions ¶
type DownloadOptions struct { // LocalPath is the local path to download the package. LocalPath string // CachePath is the cache path to download the package. CachePath string // EnableCache is the flag to enable the cache. // If `EnableCache` is false, this will not result in increasing disk usage. EnableCache bool // 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 // InsecureSkipTLSverify is the flag to skip the verification of the certificate. InsecureSkipTLSverify bool // Offline is the flag to download the package offline. Offline bool // 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 // Get the latest version of the remote source // For the git source, it will return the latest commit // For the OCI source, it will return the latest tag LatestVersion(opts *DownloadOptions) (string, 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"` Package string `toml:"package,omitempty"` }
Git is the package source from git registry.
func (*Git) FromString ¶ added in v0.9.0
func (*Git) GetPackage ¶ added in v0.10.0
func (*Git) GetValidGitReference ¶ added in v0.9.0
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) ToFilePath ¶ added in v0.9.0
func (*Git) UnmarshalModTOML ¶ added in v0.9.0
type GitDownloader ¶
type GitDownloader struct{}
GitDownloader is the downloader for the git source.
func (*GitDownloader) Download ¶
func (d *GitDownloader) Download(opts *DownloadOptions) error
func (*GitDownloader) LatestVersion ¶ added in v0.11.0
func (d *GitDownloader) LatestVersion(opts *DownloadOptions) (string, 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) FromString ¶ added in v0.9.0
func (*Local) IsLocalKPath ¶ added in v0.9.0
func (*Local) IsLocalTarPath ¶ added in v0.9.0
func (*Local) IsLocalTgzPath ¶ added in v0.9.1
func (*Local) MarshalTOML ¶ added in v0.9.0
func (*Local) ToFilePath ¶ added in v0.9.0
func (*Local) UnmarshalModTOML ¶ added in v0.9.0
type ModSpec ¶ added in v0.11.0
The KCL module.
func (*ModSpec) FromString ¶ added in v0.11.0
func (*ModSpec) MarshalTOML ¶ added in v0.11.0
func (*ModSpec) UnmarshalModTOML ¶ added in v0.11.0
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) IntoOciUrl
deprecated
added in
v0.9.0
func (*Oci) MarshalTOML ¶ added in v0.9.0
func (*Oci) NoRef ¶ added in v0.11.0
If the OCI source has no reference, return true. TODO: add digest support.
func (*Oci) ToFilePath ¶ added in v0.9.0
func (*Oci) UnmarshalModTOML ¶ added in v0.9.0
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
func (*OciDownloader) LatestVersion ¶ added in v0.11.0
func (d *OciDownloader) LatestVersion(opts *DownloadOptions) (string, error)
type Option ¶
type Option func(*DownloadOptions)
func WithCachePath ¶ added in v0.10.0
func WithCredsClient ¶ added in v0.9.1
func WithCredsClient(credsClient *CredClient) Option
func WithEnableCache ¶ added in v0.10.0
func WithInsecureSkipTLSverify ¶ added in v0.10.0
func WithLocalPath ¶
func WithLogWriter ¶
func WithOffline ¶ added in v0.11.0
func WithSettings ¶
func WithSource ¶
type Source ¶ added in v0.9.0
Source is the module source. It can be from git, oci, local path. `ModSpec` is used to represent the module in the source. If there are more than one module from the source, use `ModSpec` to specify the module. If the `ModSpec` is nil, it means the source is one module.
func NewSourceFromStr ¶ added in v0.9.0
func (*Source) FindRootPath ¶ added in v0.9.0
func (*Source) FromString ¶ added in v0.9.0
func (*Source) IsLocalPath ¶ added in v0.9.0
func (*Source) IsLocalPkg ¶ added in v0.10.0
If the source is a local path, check if it is a real local package(a directory with kcl.mod file).