Merge pull request #4027 from XiShanYongYe-Chang/fix-dependencies-lua-script-bug
fix depndencies lua scrpit bug
This commit is contained in:
commit
5a583c2c9f
|
@ -52,7 +52,7 @@ spec:
|
||||||
to interpret the dependencies of a specific resource. The
|
to interpret the dependencies of a specific resource. The
|
||||||
script should implement a function as follows: luaScript:
|
script should implement a function as follows: luaScript:
|
||||||
> function GetDependencies(desiredObj) dependencies = {}
|
> function GetDependencies(desiredObj) dependencies = {}
|
||||||
if desiredObj.spec.serviceAccountName ~= \"\" and desiredObj.spec.serviceAccountName
|
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName
|
||||||
~= \"default\" then dependency = {} dependency.apiVersion
|
~= \"default\" then dependency = {} dependency.apiVersion
|
||||||
= \"v1\" dependency.kind = \"ServiceAccount\" dependency.name
|
= \"v1\" dependency.kind = \"ServiceAccount\" dependency.name
|
||||||
= desiredObj.spec.serviceAccountName dependency.namespace
|
= desiredObj.spec.serviceAccountName dependency.namespace
|
||||||
|
|
|
@ -275,7 +275,7 @@ type DependencyInterpretation struct {
|
||||||
// luaScript: >
|
// luaScript: >
|
||||||
// function GetDependencies(desiredObj)
|
// function GetDependencies(desiredObj)
|
||||||
// dependencies = {}
|
// dependencies = {}
|
||||||
// if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
|
// if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
|
||||||
// dependency = {}
|
// dependency = {}
|
||||||
// dependency.apiVersion = "v1"
|
// dependency.apiVersion = "v1"
|
||||||
// dependency.kind = "ServiceAccount"
|
// dependency.kind = "ServiceAccount"
|
||||||
|
|
|
@ -1781,7 +1781,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 luaScript: >\n function GetDependencies(desiredObj)\n dependencies = {}\n if desiredObj.spec.serviceAccountName ~= \"\" 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\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 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\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: "",
|
||||||
|
|
|
@ -543,7 +543,7 @@ func TestGetDeployPodDependencies(t *testing.T) {
|
||||||
luaScript: `function GetDependencies(desiredObj)
|
luaScript: `function GetDependencies(desiredObj)
|
||||||
dependentSas = {}
|
dependentSas = {}
|
||||||
refs = {}
|
refs = {}
|
||||||
if desiredObj.spec.template.spec.serviceAccountName ~= '' and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
|
if desiredObj.spec.template.spec.serviceAccountName ~= nil and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
|
||||||
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
|
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
|
||||||
end
|
end
|
||||||
local idx = 1
|
local idx = 1
|
||||||
|
|
|
@ -351,7 +351,7 @@ 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 ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
|
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
|
||||||
dependency = {}
|
dependency = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
|
|
|
@ -571,7 +571,7 @@ 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 ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
|
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
|
||||||
dependency = {}
|
dependency = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
|
|
|
@ -376,7 +376,7 @@ end
|
||||||
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
|
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependencies = {}
|
dependencies = {}
|
||||||
if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
|
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
|
||||||
dependency = {}
|
dependency = {}
|
||||||
dependency.apiVersion = "v1"
|
dependency.apiVersion = "v1"
|
||||||
dependency.kind = "ServiceAccount"
|
dependency.kind = "ServiceAccount"
|
||||||
|
|
|
@ -935,7 +935,7 @@ var _ = framework.SerialDescribe("Resource interpreter customization testing", f
|
||||||
function GetDependencies(desiredObj)
|
function GetDependencies(desiredObj)
|
||||||
dependentSas = {}
|
dependentSas = {}
|
||||||
refs = {}
|
refs = {}
|
||||||
if desiredObj.spec.template.spec.serviceAccountName ~= '' and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
|
if desiredObj.spec.template.spec.serviceAccountName ~= nil and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
|
||||||
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
|
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
|
||||||
end
|
end
|
||||||
local idx = 1
|
local idx = 1
|
||||||
|
|
Loading…
Reference in New Issue