"os"
"path/filepath"
+ "github.com/xeipuuv/gojsonschema"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
)
VALUES_YAML = "values.yaml"
CHART_YAML = "Chart.yaml"
+ ENV_CHART_WORKSPACE_PATH = "CHART_WORKSPACE_PATH"
+
SERVING_VERSION_ALPHA = "serving.kubeflow.org/v1alpha2"
SERVING_VERSION_BETA = "serving.kubeflow.org/v1beta1"
- RESOURCE_ALPHA = "'resources/xapp-inf-alpha'"
- RESOURCE_BETA = "'resources/xapp-inf-beta'"
+ RESOURCE_ALPHA = "resources/inf-alpha"
+ RESOURCE_BETA = "resources/inf-beta"
)
type HelmChartBuilder interface {
chartBuilder.chartName = chartBuilder.config.XappName
chartBuilder.chartVersion = chartBuilder.config.Version
- chartBuilder.chartWorkspacePath = os.Getenv("CHART_WORKSPACE_PATH") + "/" + chartBuilder.chartName + "-" + chartBuilder.chartVersion
+ chartBuilder.chartWorkspacePath = os.Getenv(ENV_CHART_WORKSPACE_PATH) + "/" + chartBuilder.chartName + "-" + chartBuilder.chartVersion
_, err = os.Stat(chartBuilder.chartWorkspacePath)
if err != nil {
if !os.IsNotExist(err) {
os.RemoveAll(chartBuilder.chartWorkspacePath)
- os.Mkdir(chartBuilder.chartWorkspacePath, os.FileMode(644))
}
}
+ err = os.Mkdir(chartBuilder.chartWorkspacePath, os.FileMode(0744))
+ if err != nil {
+ logger.Logging(logger.ERROR, err.Error())
+ return nil
+ }
+
resourceVersionMap := map[string]string{
SERVING_VERSION_ALPHA: RESOURCE_ALPHA,
SERVING_VERSION_BETA: RESOURCE_BETA,
_, err = os.Stat(dest)
if err != nil && !os.IsNotExist(err) {
- return
- }
- if err == nil {
return fmt.Errorf("destination(%s) is already exists", dest)
}
- err = os.MkdirAll(dest, srcInfo.Mode())
- if err != nil {
+
+ err = os.Mkdir(dest, os.FileMode(0744))
+ if err != nil && !os.IsExist(err) {
return
}
entries, err := ioutil.ReadDir(src)
logger.Logging(logger.ERROR, err.Error())
return
}
+ config.configFile = configFile
return
}
logger.Logging(logger.ERROR, err.Error())
return
}
+
+ schema.schemaFile = schemaFile
return
}
func (c *ChartBuilder) changeChartNameVersion() (err error) {
return errors.New("not yet implemented")
}
+
+func (c *ChartBuilder) ValidateChartMaterials() (err error) {
+
+ schemaLoader := gojsonschema.NewReferenceLoader("file://" + c.schema.schemaFile)
+ configLoader := gojsonschema.NewReferenceLoader("file://" + c.config.configFile)
+
+ result, err := gojsonschema.Validate(schemaLoader, configLoader)
+
+ if err != nil {
+ return
+ }
+
+ if !result.Valid() {
+ for _, desc := range result.Errors() {
+ logger.Logging(logger.ERROR, fmt.Sprintf("[Invalid Config] - %s\n", desc))
+ }
+ return errors.New("Invalid Config")
+ }
+ return
+}
{
- "definitions": {},
- "$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://example.com/root.json",
- "type": "object",
- "title": "The Root Schema",
- "required": [
- "service_ports",
- "rmr",
- "envs"
- ],
- "properties": {
- "service_ports": {
- "$id": "#/properties/service_ports",
- "type": "object",
- "title": "The Service_ports Schema",
- "required": [
- "xapp_port",
- "rmr_port"
- ],
- "properties": {
- "xapp_port": {
- "$id": "#/properties/service_ports/properties/xapp_port",
- "type": "integer",
- "title": "The Xapp_port Schema",
- "default": 0,
- "examples": [
- 4560
- ]
- },
- "rmr_port": {
- "$id": "#/properties/service_ports/properties/rmr_port",
- "type": "integer",
- "title": "The Rmr_port Schema",
- "default": 0,
- "examples": [
- 4561
- ]
- }
- }
- },
- "rmr": {
- "$id": "#/properties/rmr",
- "type": "object",
- "title": "The Rmr Schema",
- "required": [
- "protPort",
- "maxSize",
- "numWorkers",
- "txMessages",
- "rxMessages",
- "file_path",
- "contents"
- ],
- "properties": {
- "protPort": {
- "$id": "#/properties/rmr/properties/protPort",
- "type": "string",
- "title": "The Protport Schema",
- "default": "",
- "examples": [
- "tcp:4560"
- ],
- "pattern": "^(.*)$"
- },
- "maxSize": {
- "$id": "#/properties/rmr/properties/maxSize",
- "type": "integer",
- "title": "The Maxsize Schema",
- "default": 0,
- "examples": [
- 2072
- ]
- },
- "numWorkers": {
- "$id": "#/properties/rmr/properties/numWorkers",
- "type": "integer",
- "title": "The Numworkers Schema",
- "default": 0,
- "examples": [
- 1
- ]
- },
- "txMessages": {
- "$id": "#/properties/rmr/properties/txMessages",
- "type": "array",
- "title": "The Txmessages Schema",
- "items": {
- "$id": "#/properties/rmr/properties/txMessages/items",
+ "definitions": {},
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "http://example.com/root.json",
+ "type": "object",
+ "title": "The Root Schema",
+ "required": [
+ "xapp_name",
+ "xapp_type",
+ "version",
+ "sa_name",
+ "inferenceservice"
+ ],
+ "properties": {
+ "inferenceservice": {
+ "$id": "#/properties/inferenceservice",
+ "type": "object",
+ "title": "The Inferenceservice Schema",
+ "required": [
+ "engine",
+ "storage_uri",
+ "api_version",
+ "min_replicas",
+ "max_replicas"
+ ],
+ "properties": {
+ "engine": {
+ "$id": "#/properties/inferenceservice/properties/engine",
"type": "string",
- "title": "The Items Schema",
+ "title": "The Engine Schema",
"default": "",
"examples": [
- "RIC_SUB_REQ",
- "RIC_SUB_DEL_REQ"
- ],
- "pattern": "^(.*)$"
- }
- },
- "rxMessages": {
- "$id": "#/properties/rmr/properties/rxMessages",
- "type": "array",
- "title": "The Rxmessages Schema",
- "items": {
- "$id": "#/properties/rmr/properties/rxMessages/items",
+ "tensorflow"
+ ]
+ },
+ "storage_uri": {
+ "$id": "#/properties/inferenceservice/properties/storage_uri",
+ "type": "string",
+ "title": "The Storage_uri Schema",
+ "default": "",
+ "examples": [
+ "s3://mlpipeline/artifacts/sample-rl-pipeline-bbzh4/sample-rl-pipeline-bbzh4-949264085/sample-training-saved-model.tgz"
+ ]
+ },
+ "api_version": {
+ "$id": "#/properties/inferenceservice/properties/api_version",
"type": "string",
- "title": "The Items Schema",
+ "title": "The Api_version Schema",
"default": "",
"examples": [
- "RIC_SUB_RESP",
- "RIC_SUB_FAILURE",
- "RIC_SUB_DEL_RESP",
- "RIC_SUB_DEL_FAILURE",
- "RIC_INDICATION"
- ],
- "pattern": "^(.*)$"
+ "serving.kubeflow.org/v1alpha2",
+ "serving.kubeflow.org/v1beta1"
+ ]
+ },
+ "min_replicas": {
+ "$id": "#/properties/inferenceservice/properties/min_replicas",
+ "type": "integer",
+ "title": "The Min_replicas Schema",
+ "default": 0,
+ "examples": [
+ 1
+ ]
+ },
+ "max_replicas": {
+ "$id": "#/properties/inferenceservice/properties/max_replicas",
+ "type": "integer",
+ "title": "The Max_replicas Schema",
+ "default": 0,
+ "examples": [
+ 1
+ ]
}
- },
- "file_path": {
- "$id": "#/properties/rmr/properties/file_path",
- "type": "string",
- "title": "The File_path Schema",
- "default": "",
- "examples": [
- "/tmp/routeinfo/routes.txt"
- ],
- "pattern": "^(.*)$"
- },
- "contents": {
- "$id": "#/properties/rmr/properties/contents",
- "type": "string",
- "title": "The Contents Schema",
- "default": "",
- "examples": [
- "newrt|start\nrte|0|localhost:4560\nrte|2|localhost:4591\nrte|10002|localhost:4560\nrte|10005|localhost:4560\nrte|10003|localhost:4591\nrte|12010|localhost:4591\nrte|12020|localhost:4591\nrte|12011|localhost:4560\nrte|12012|localhost:4560\nrte|12021|localhost:4560\nrte|12022|localhost:4560\nrte|20000|localhost:4560\nrte|20001|localhost:4566\nnewrt|end "
- ],
- "pattern": "^(.*)$"
- }
- }
- },
- "envs": {
- "$id": "#/properties/envs",
- "type": "object",
- "title": "The Envs Schema",
- "required": [
- "gNodeB",
- "THREADS",
- "A1_SCHEMA_FILE",
- "VES_SCHEMA_FILE",
- "SAMPLE_FILE",
- "VES_COLLECTOR_URL",
- "VES_MEAUSUREMENT_INTERVAL"
- ],
- "properties": {
- "gNodeB": {
- "$id": "#/properties/envs/properties/gNodeB",
- "type": "string",
- "title": "The Gnodeb Schema",
- "default": "",
- "examples": [
- "NYC123"
- ],
- "pattern": "^(.*)$"
- },
- "THREADS": {
- "$id": "#/properties/envs/properties/THREADS",
- "type": "string",
- "title": "The Threads Schema",
- "default": "",
- "examples": [
- "1"
- ],
- "pattern": "^(.*)$"
- },
- "A1_SCHEMA_FILE": {
- "$id": "#/properties/envs/properties/A1_SCHEMA_FILE",
- "type": "string",
- "title": "The A1_schema_file Schema",
- "default": "",
- "examples": [
- "/etc/xapp/adm-ctrl-xapp-schema.json"
- ],
- "pattern": "^(.*)$"
- },
- "VES_SCHEMA_FILE": {
- "$id": "#/properties/envs/properties/VES_SCHEMA_FILE",
- "type": "string",
- "title": "The Ves_schema_file Schema",
- "default": "",
- "examples": [
- "/etc/xapp/ves_schema.json"
- ],
- "pattern": "^(.*)$"
- },
- "SAMPLE_FILE": {
- "$id": "#/properties/envs/properties/SAMPLE_FILE",
- "type": "string",
- "title": "The Sample_file Schema",
- "default": "",
- "examples": [
- "/etc/xapp/samples.json"
- ],
- "pattern": "^(.*)$"
- },
- "VES_COLLECTOR_URL": {
- "$id": "#/properties/envs/properties/VES_COLLECTOR_URL",
- "type": "string",
- "title": "The Ves_collector_url Schema",
- "default": "",
- "examples": [
- "127.0.0.1:6350"
- ],
- "pattern": "^(.*)$"
- },
- "VES_MEAUSUREMENT_INTERVAL": {
- "$id": "#/properties/envs/properties/VES_MEAUSUREMENT_INTERVAL",
- "type": "string",
- "title": "The Ves_meausurement_interval Schema",
- "default": "",
- "examples": [
- "10"
- ],
- "pattern": "^(.*)$"
}
}
}
}
-}
-
+
+
\ No newline at end of file