Skip to content

kcl.GetSchemaTypeMapping API support to resolve a kpm package path #158

@amyXia1994

Description

@amyXia1994

Enhancement

the kcl.GetSchemaTypeMapping API now only support resolving schema types from a filepath or the parent directory of the filepath that contains the schema types.

But a KCL package may not contain schema definitions directly under the package's root path(may be deep inside the sub packages), for example, the k8s package:

➜  tree  -L 2 ~/.kcl/kpm/k8s_1.27
k8s_1.27
├── api
│   ├── admissionregistration
│   ├── apiserverinternal
│   ├── apps
│   ├── authentication
│   ├── authorization
│   ├── autoscaling
│   ├── batch
│   ├── certificates
│   ├── coordination
│   ├── core
│   ├── discovery
│   ├── events
│   ├── flowcontrol
│   ├── networking
│   ├── node
│   ├── policy
│   ├── rbac
│   ├── resource
│   ├── scheduling
│   └── storage
├── apiextensions_apiserver
│   └── pkg
├── apimachinery
│   └── pkg
├── kcl.mod
├── kcl.mod.lock
├── kube_aggregator
│   └── pkg
└── vendor

To get all the schema types in a kpm package, we would like the kcl.GetSchemaTypeMapping API to support resolving package paths

Steps to use the API

to demonstrate the feature, here's an example to show the steps to use the API and the result:

  1. make sure you have konfig repo locally in path , then create a getschema.json file with content(replace the to the real path):
{
    "file": "konfig/base/pkg"
}
  1. call the API
curl -X POST \
    http://127.0.0.1:2021/api:protorpc/KclvmService.GetSchemaType \
-H  "accept: application/json" \
--data @./getschema.json
  1. the expected result

all the schema Types within the base/pkg package recursively

  1. the result got from the current API
{
	"error": "No input KCL files",
	"result": null
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions