fix demo for dependencyInterpretation
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
parent
6058fe124f
commit
3c731e5d08
|
@ -17605,7 +17605,7 @@
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"luaScript": {
|
"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",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,13 +69,13 @@ spec:
|
||||||
luaScript: >
|
luaScript: >
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependencies = {}
|
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 = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
dependency.name = desiredObj.spec.serviceAccountName
|
dependency.name = serviceAccountName
|
||||||
dependency.namespace = desiredObj.namespace
|
dependency.namespace = desiredObj.metadata.namespace
|
||||||
dependencies[1] = {}
|
|
||||||
dependencies[1] = dependency
|
dependencies[1] = dependency
|
||||||
end
|
end
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
|
@ -322,13 +322,13 @@ type DependencyInterpretation struct {
|
||||||
// luaScript: >
|
// luaScript: >
|
||||||
// function GetDependencies(desiredObj)
|
// function GetDependencies(desiredObj)
|
||||||
// dependencies = {}
|
// 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 = {}
|
||||||
// dependency.apiVersion = "v1"
|
// dependency.apiVersion = "v1"
|
||||||
// dependency.kind = "ServiceAccount"
|
// dependency.kind = "ServiceAccount"
|
||||||
// dependency.name = desiredObj.spec.serviceAccountName
|
// dependency.name = serviceAccountName
|
||||||
// dependency.namespace = desiredObj.namespace
|
// dependency.namespace = desiredObj.metadata.namespace
|
||||||
// dependencies[1] = {}
|
|
||||||
// dependencies[1] = dependency
|
// dependencies[1] = dependency
|
||||||
// end
|
// end
|
||||||
// return dependencies
|
// return dependencies
|
||||||
|
|
|
@ -2112,7 +2112,7 @@ func schema_pkg_apis_config_v1alpha1_DependencyInterpretation(ref common.Referen
|
||||||
Properties: map[string]spec.Schema{
|
Properties: map[string]spec.Schema{
|
||||||
"luaScript": {
|
"luaScript": {
|
||||||
SchemaProps: spec.SchemaProps{
|
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: "",
|
Default: "",
|
||||||
Type: []string{"string"},
|
Type: []string{"string"},
|
||||||
Format: "",
|
Format: "",
|
||||||
|
|
|
@ -367,14 +367,14 @@ func (d *dependencyInterpretationRule) Document() string {
|
||||||
The script should implement a function as follows:
|
The script should implement a function as follows:
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependencies = {}
|
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 = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
dependency.name = desiredObj.spec.serviceAccountName
|
dependency.name = serviceAccountName
|
||||||
dependency.namespace = desiredObj.namespace
|
dependency.namespace = desiredObj.metadata.namespace
|
||||||
dependencies[0] = {}
|
dependencies[1] = dependency
|
||||||
dependencies[0] = dependency
|
|
||||||
end
|
end
|
||||||
return dependencies
|
return dependencies
|
||||||
end`
|
end`
|
||||||
|
|
|
@ -587,14 +587,14 @@ func TestDependencyInterpretationRule_Document(t *testing.T) {
|
||||||
The script should implement a function as follows:
|
The script should implement a function as follows:
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependencies = {}
|
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 = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
dependency.name = desiredObj.spec.serviceAccountName
|
dependency.name = serviceAccountName
|
||||||
dependency.namespace = desiredObj.namespace
|
dependency.namespace = desiredObj.metadata.namespace
|
||||||
dependencies[0] = {}
|
dependencies[1] = dependency
|
||||||
dependencies[0] = dependency
|
|
||||||
end
|
end
|
||||||
return dependencies
|
return dependencies
|
||||||
end`
|
end`
|
||||||
|
|
|
@ -392,14 +392,14 @@ end
|
||||||
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
|
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependencies = {}
|
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 = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
dependency.name = desiredObj.spec.serviceAccountName
|
dependency.name = serviceAccountName
|
||||||
dependency.namespace = desiredObj.namespace
|
dependency.namespace = desiredObj.metadata.namespace
|
||||||
dependencies[0] = {}
|
dependencies[1] = dependency
|
||||||
dependencies[0] = dependency
|
|
||||||
end
|
end
|
||||||
return dependencies
|
return dependencies
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue