api

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const KCL_PKG_TAR = "*.tar"

Variables

This section is empty.

Functions

func GetKclPkgPath

func GetKclPkgPath() (string, error)

GetKclPkgPath will return the value of $KCL_PKG_PATH.

If $KCL_PKG_PATH does not exist, it will return '$HOME/.kcl/kpm' by default.

func IsSchema

func IsSchema(kt *KclType) bool

IsSchema returns true if the type is schema.

func IsSchemaInstance

func IsSchemaInstance(kt *KclType) bool

IsSchemaInstance returns true if the type is schema instance.

func IsSchemaNamed

func IsSchemaNamed(kt *KclType, name string) bool

IsSchemaNamed returns true if the type is schema and the name is equal to the given name.

func IsSchemaType

func IsSchemaType(kt *KclType) bool

IsSchemaType returns true if the type is schema type.

func RunOci

func RunOci(ociRef, version string, opts *opt.CompileOptions) (*kcl.KCLResultList, error)

RunOci will compile the kcl package from an OCI reference.

func RunPkg

func RunPkg(opts *opt.CompileOptions) (*kcl.KCLResultList, error)

RunPkg will compile current kcl package.

func RunPkgInPath

func RunPkgInPath(opts *opt.CompileOptions) (*kcl.KCLResultList, error)

RunPkgInPath will load the 'KclPkg' from path 'pkgPath'. And run the kcl package with entry file in 'entryFilePath' in 'vendorMode'.

func RunTar

func RunTar(tarPath string, opts *opt.CompileOptions) (*kcl.KCLResultList, error)

RunTar will compile the kcl package from a kcl package tar.

Types

type KclPackage

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

The KCL Package

func GetKclPackage

func GetKclPackage(pkgPath string) (*KclPackage, error)

GetKclPackage returns the kcl package infomation.

'pkgPath' is the root path of the package where the 'kcl.mod' is located in.

'kcl_pkg_path' is the path of dependencies download by kpm.

func (*KclPackage) GetAllSchemaTypeMapping

func (pkg *KclPackage) GetAllSchemaTypeMapping() (map[string]map[string]*KclType, error)

GetAllSchemaTypeMapping returns all the schema types of the package.

It will return a map of schema types, the key is the relative path to the package home path.

And, the value is a map of schema types, the key is the schema name, the value is the schema type.

func (*KclPackage) GetDependencies

func (pkg *KclPackage) GetDependencies() pkg.Dependencies

GetDependencies returns the dependencies of the package.

func (*KclPackage) GetEdition

func (pkg *KclPackage) GetEdition() string

GetPkgEdition returns the kcl compiler edition of the package.

func (*KclPackage) GetPkgHomePath

func (pkg *KclPackage) GetPkgHomePath() string

GetPkgHomePath returns the home path of the package.

func (*KclPackage) GetPkgName

func (pkg *KclPackage) GetPkgName() string

GetPkgName returns the name of the package.

func (*KclPackage) GetPkgProfile

func (pkg *KclPackage) GetPkgProfile() pkg.Profile

GetPkgProfile returns the profile of the package.

func (*KclPackage) GetSchemaTypeMappingNamed

func (pkg *KclPackage) GetSchemaTypeMappingNamed(schemaName string) (map[string]map[string]*KclType, error)

GetSchemaTypeMappingNamed returns the schema type filtered by schema name.

If 'schemaName' is empty, it will return all the schema types.

func (*KclPackage) GetSchemaTypeMappingWithFilters

func (pkg *KclPackage) GetSchemaTypeMappingWithFilters(fileterFuncs []KclTypeFilterFunc) (map[string]map[string]*KclType, error)

GetSchemaTypeMappingWithFilters returns the schema type filtered by the filter functions.

func (*KclPackage) GetVersion

func (pkg *KclPackage) GetVersion() string

GetPkgVersion returns the version of the package.

func (*KclPackage) UpdateDependencyInPath

func (pkg *KclPackage) UpdateDependencyInPath(pkg_path string) error

UpdateDependencyInPath updates the dependencies in the path.

'pkg_path' is the path of dependencies download by kpm.

type KclType

type KclType struct {
	Name    string
	RelPath string
	*gpyrpc.KclType
}

An additional field 'Name' is added to the original 'KclType'.

'Name' is the name of the kcl type.

'RelPath' is the relative path to the package home path.

func NewKclTypes

func NewKclTypes(name, path string, tys *gpyrpc.KclType) *KclType

NewKclTypes returns a new KclType.

type KclTypeFilterFunc

type KclTypeFilterFunc func(kt *KclType) bool

Jump to

Keyboard shortcuts

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