fix demo for dependencyInterpretation

Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
chaosi-zju 2024-05-29 15:11:06 +08:00
parent 6058fe124f
commit 3c731e5d08
7 changed files with 26 additions and 26 deletions

View File

@ -17605,7 +17605,7 @@
],
"properties": {
"luaScript": {
"description": "LuaScript holds the Lua script that is used to interpret the dependencies of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function GetDependencies(desiredObj)\n dependencies = {}\n if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= \"default\" then\n dependency = {}\n dependency.apiVersion = \"v1\"\n dependency.kind = \"ServiceAccount\"\n dependency.name = desiredObj.spec.serviceAccountName\n dependency.namespace = desiredObj.namespace\n dependencies[1] = {}\n dependencies[1] = dependency\n end\n return dependencies\n end\n```\n\nThe content of the LuaScript needs to be a whole function including both declaration and implementation.\n\nThe parameters will be supplied by the system:\n - desiredObj: the object represents the configuration to be applied\n to the member cluster.\n\nThe returned value should be expressed by a slice of DependentObjectReference.",
"description": "LuaScript holds the Lua script that is used to interpret the dependencies of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function GetDependencies(desiredObj)\n dependencies = {}\n serviceAccountName = desiredObj.spec.template.spec.serviceAccountName\n if serviceAccountName ~= nil and serviceAccountName ~= \"default\" then\n dependency = {}\n dependency.apiVersion = \"v1\"\n dependency.kind = \"ServiceAccount\"\n dependency.name = serviceAccountName\n dependency.namespace = desiredObj.metadata.namespace\n dependencies[1] = dependency\n end\n return dependencies\n end\n```\n\nThe content of the LuaScript needs to be a whole function including both declaration and implementation.\n\nThe parameters will be supplied by the system:\n - desiredObj: the object represents the configuration to be applied\n to the member cluster.\n\nThe returned value should be expressed by a slice of DependentObjectReference.",
"type": "string",
"default": ""
}

View File

@ -69,13 +69,13 @@ spec:
luaScript: >
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
serviceAccountName = desiredObj.spec.template.spec.serviceAccountName
if serviceAccountName ~= nil and serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
dependency.name = desiredObj.spec.serviceAccountName
dependency.namespace = desiredObj.namespace
dependencies[1] = {}
dependency.name = serviceAccountName
dependency.namespace = desiredObj.metadata.namespace
dependencies[1] = dependency
end
return dependencies

View File

@ -322,13 +322,13 @@ type DependencyInterpretation struct {
// luaScript: >
// function GetDependencies(desiredObj)
// dependencies = {}
// if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
// serviceAccountName = desiredObj.spec.template.spec.serviceAccountName
// if serviceAccountName ~= nil and serviceAccountName ~= "default" then
// dependency = {}
// dependency.apiVersion = "v1"
// dependency.kind = "ServiceAccount"
// dependency.name = desiredObj.spec.serviceAccountName
// dependency.namespace = desiredObj.namespace
// dependencies[1] = {}
// dependency.name = serviceAccountName
// dependency.namespace = desiredObj.metadata.namespace
// dependencies[1] = dependency
// end
// return dependencies

View File

@ -2112,7 +2112,7 @@ func schema_pkg_apis_config_v1alpha1_DependencyInterpretation(ref common.Referen
Properties: map[string]spec.Schema{
"luaScript": {
SchemaProps: spec.SchemaProps{
Description: "LuaScript holds the Lua script that is used to interpret the dependencies of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: >\n function GetDependencies(desiredObj)\n dependencies = {}\n if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= \"default\" then\n dependency = {}\n dependency.apiVersion = \"v1\"\n dependency.kind = \"ServiceAccount\"\n dependency.name = desiredObj.spec.serviceAccountName\n dependency.namespace = desiredObj.namespace\n dependencies[1] = {}\n dependencies[1] = dependency\n end\n return dependencies\n end\n```\n\nThe content of the LuaScript needs to be a whole function including both declaration and implementation.\n\nThe parameters will be supplied by the system:\n - desiredObj: the object represents the configuration to be applied\n to the member cluster.\n\nThe returned value should be expressed by a slice of DependentObjectReference.",
Description: "LuaScript holds the Lua script that is used to interpret the dependencies of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: >\n function GetDependencies(desiredObj)\n dependencies = {}\n serviceAccountName = desiredObj.spec.template.spec.serviceAccountName\n if serviceAccountName ~= nil and serviceAccountName ~= \"default\" then\n dependency = {}\n dependency.apiVersion = \"v1\"\n dependency.kind = \"ServiceAccount\"\n dependency.name = serviceAccountName\n dependency.namespace = desiredObj.metadata.namespace\n dependencies[1] = dependency\n end\n return dependencies\n end\n```\n\nThe content of the LuaScript needs to be a whole function including both declaration and implementation.\n\nThe parameters will be supplied by the system:\n - desiredObj: the object represents the configuration to be applied\n to the member cluster.\n\nThe returned value should be expressed by a slice of DependentObjectReference.",
Default: "",
Type: []string{"string"},
Format: "",

View File

@ -367,14 +367,14 @@ func (d *dependencyInterpretationRule) Document() string {
The script should implement a function as follows:
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
serviceAccountName = desiredObj.spec.template.spec.serviceAccountName
if serviceAccountName ~= nil and serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
dependency.name = desiredObj.spec.serviceAccountName
dependency.namespace = desiredObj.namespace
dependencies[0] = {}
dependencies[0] = dependency
dependency.name = serviceAccountName
dependency.namespace = desiredObj.metadata.namespace
dependencies[1] = dependency
end
return dependencies
end`

View File

@ -587,14 +587,14 @@ func TestDependencyInterpretationRule_Document(t *testing.T) {
The script should implement a function as follows:
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
serviceAccountName = desiredObj.spec.template.spec.serviceAccountName
if serviceAccountName ~= nil and serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
dependency.name = desiredObj.spec.serviceAccountName
dependency.namespace = desiredObj.namespace
dependencies[0] = {}
dependencies[0] = dependency
dependency.name = serviceAccountName
dependency.namespace = desiredObj.metadata.namespace
dependencies[1] = dependency
end
return dependencies
end`

View File

@ -391,15 +391,15 @@ end
`},
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
dependencies = {}
serviceAccountName = desiredObj.spec.template.spec.serviceAccountName
if serviceAccountName ~= nil and serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
dependency.name = desiredObj.spec.serviceAccountName
dependency.namespace = desiredObj.namespace
dependencies[0] = {}
dependencies[0] = dependency
dependency.name = serviceAccountName
dependency.namespace = desiredObj.metadata.namespace
dependencies[1] = dependency
end
return dependencies
end