modfile

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2022 The KCL Authors. All rights reserved.

Copyright 2022 The KCL Authors. All rights reserved.

Because the same dependency package will be serialized into toml files in different formats in kcl.mod and kcl.mod.lock, the toml library 'github.com/BurntSushi/toml' is encapsulated in this file, and two different format are provided according to different files.

In kcl.mod, the dependency toml looks like:

<dependency_name> = { git = "<git_url>", tag = "<git_tag>" }

In kcl.mod.lock, the dependency toml looks like:

[dependencies.<dependency_name>] name = "<dependency_name>" full_name = "<dependency_fullname>" version = "<dependency_version>" sum = "yNADGqn3jclWtfpwvWMHBsgkAKzOaMWg/VYxfcOJs64=" url = "https://github.com/xxxx" tag = "<dependency_tag>"

Index

Constants

View Source
const (
	MOD_FILE      = "kcl.mod"
	MOD_LOCK_FILE = "kcl.mod.lock"
)
View Source
const DEPS_FLAG = "dependencies"
View Source
const DEPS_PATTERN = "[dependencies]"
View Source
const DEP_PATTERN = "%s = %s"
View Source
const EDITION_FLAG = "edition"
View Source
const GTI_TAG_FLAG = "tag"
View Source
const GTI_TAG_PATTERN = "tag = \"%s\""
View Source
const GTI_URL_FLAG = "git"
View Source
const GTI_URL_PATTERN = "git = \"%s\""
View Source
const NAME_FLAG = "name"
View Source
const NEWLINE = "\n"
View Source
const PACKAGE_FLAG = "package"
View Source
const PACKAGE_PATTERN = "[package]"
View Source
const PKG_NAME_PATTERN = "%s_%s"
View Source
const PROFILES_FLAG = "profile"
View Source
const PROFILE_PATTERN = "[profile]"
View Source
const SEPARATOR = ", "
View Source
const SOURCE_PATTERN = "{ %s }"
View Source
const VERSION_FLAG = "version"

Variables

This section is empty.

Functions

func ModFileExists

func ModFileExists(path string) (bool, error)

ModFileExists returns whether a 'kcl.mod' file exists in the path.

func ModLockFileExists

func ModLockFileExists(path string) (bool, error)

ModLockFileExists returns whether a 'kcl.mod.lock' file exists in the path.

func ParseRepoFullNameFromGitSource

func ParseRepoFullNameFromGitSource(gitSrc Git) string

ParseRepoFullNameFromGitSource will extract the kcl package name from the git url.

func ParseRepoNameFromGitSource

func ParseRepoNameFromGitSource(gitSrc Git) string

ParseRepoNameFromGitSource will extract the kcl package name from the git url.

Types

type Dependencies

type Dependencies struct {
	Deps map[string]Dependency `json:"packages" toml:"dependencies,omitempty"`
}

'Dependencies' is dependencies section of 'kcl.mod'.

func LoadLockDeps

func LoadLockDeps(homePath string) (*Dependencies, error)

LoadLockDeps will load all dependencies from 'kcl.mod.lock'.

func (*Dependencies) MarshalLockTOML

func (dep *Dependencies) MarshalLockTOML() (string, error)

func (*Dependencies) MarshalTOML

func (dep *Dependencies) MarshalTOML() string

func (*Dependencies) UnmarshalLockTOML

func (dep *Dependencies) UnmarshalLockTOML(data string) error

func (*Dependencies) UnmarshalModTOML

func (deps *Dependencies) UnmarshalModTOML(data interface{}) error

type Dependency

type Dependency struct {
	Name     string `json:"name" toml:"name,omitempty"`
	FullName string `json:"-" toml:"full_name,omitempty"`
	Version  string `json:"-" toml:"version,omitempty"`
	Sum      string `json:"-" toml:"sum,omitempty"`
	// The actual local path of the package.
	// In vendor mode is "current_kcl_package/vendor"
	// In non-vendor mode is "$KCL_PKG_PATH"
	LocalFullPath string `json:"manifest_path" toml:"-"`
	Source        `json:"-"`
}

func ParseOpt

func ParseOpt(opt *opt.RegistryOptions) *Dependency

Parse out some information for a Dependency from registry url.

func (*Dependency) Download

func (dep *Dependency) Download(localPath string) (*Dependency, error)

Download will download the kcl package to localPath from registory.

func (*Dependency) FillDepInfo

func (dep *Dependency) FillDepInfo() error

FillDepInfo will fill registry information for a dependency.

func (*Dependency) GenDepFullName

func (dep *Dependency) GenDepFullName() string

GenDepFullName will generate the full name of a dependency by its name and version based on the '<package_name>_<package_tag>' format.

func (*Dependency) MarshalTOML

func (dep *Dependency) MarshalTOML() string

func (*Dependency) UnmarshalModTOML

func (dep *Dependency) UnmarshalModTOML(data interface{}) error

type Git

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

Git is the package source from git registry.

func (*Git) Download

func (dep *Git) Download(localPath string) (string, error)

Download will download the kcl package to localPath from git url.

func (*Git) MarshalTOML

func (git *Git) MarshalTOML() string

func (*Git) UnmarshalModTOML

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

type ModFile

type ModFile struct {
	HomePath string  `toml:"-"`
	Pkg      Package `toml:"package,omitempty"`
	// Whether the current package uses the vendor mode
	// In the vendor mode, kpm will look for the package in the vendor subdirectory
	// in the current package directory.
	VendorMode bool    `toml:"-"`
	Profiles   Profile `toml:"profile"`
	Dependencies
}

'ModFile' is kcl package file 'kcl.mod'.

func LoadModFile

func LoadModFile(homePath string) (*ModFile, error)

LoadModFile load the contents of the 'kcl.mod' file in the path.

func NewModFile

func NewModFile(opts *opt.InitOptions) *ModFile

func (*ModFile) FillDependenciesInfo

func (modFile *ModFile) FillDependenciesInfo() error

FillDependenciesInfo will fill registry information for all dependencies in a kcl.mod.

func (*ModFile) GetModFilePath

func (mfile *ModFile) GetModFilePath() string

Returns the path to the kcl.mod file

func (*ModFile) GetModLockFilePath

func (mfile *ModFile) GetModLockFilePath() string

Returns the path to the kcl.mod.lock file

func (*ModFile) MarshalTOML

func (mod *ModFile) MarshalTOML() string

func (*ModFile) StoreModFile

func (mfile *ModFile) StoreModFile() error

Write the contents of 'ModFile' to 'kcl.mod' file

func (*ModFile) UnmarshalTOML

func (mod *ModFile) UnmarshalTOML(data interface{}) error

type Oci

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

func (*Oci) Download

func (dep *Oci) Download(localPath string) (string, error)

func (*Oci) MarshalTOML

func (oci *Oci) MarshalTOML() string

func (*Oci) UnmarshalModTOML

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

type Package

type Package struct {
	Name    string `toml:"name,omitempty"`    // kcl package name
	Edition string `toml:"edition,omitempty"` // kcl compiler version
	Version string `toml:"version,omitempty"` // kcl package version
}

'Package' is the kcl package section of 'kcl.mod'.

func (*Package) MarshalTOML

func (pkg *Package) MarshalTOML() string

func (*Package) UnmarshalTOML

func (pkg *Package) UnmarshalTOML(data interface{}) error

type Profile

type Profile struct {
	Entries []string `toml:"entries"`
}

Profile is the profile section of 'kcl.mod'. It is used to specify the compilation options of the current package.

func NewProfile

func NewProfile() Profile

NewProfile will create a new profile.

func (*Profile) IntoKclOptions

func (profile *Profile) IntoKclOptions() *kcl.Option

IntoKclOptions will transform the profile into kcl options.

func (*Profile) MarshalTOML

func (p *Profile) MarshalTOML() string

type Source

type Source struct {
	*Git
	*Oci
}

Source is the package source from registry.

func (*Source) MarshalTOML

func (source *Source) MarshalTOML() string

func (*Source) UnmarshalModTOML

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