Skip to content

Commit

Permalink
Merge pull request karmada-io#4027 from XiShanYongYe-Chang/fix-depend…
Browse files Browse the repository at this point in the history
…encies-lua-script-bug

fix depndencies lua scrpit bug
  • Loading branch information
karmada-bot authored Sep 6, 2023
2 parents 7c96e0d + 734cf3a commit 5a583c2
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
to interpret the dependencies of a specific resource. The
script should implement a function as follows: luaScript:
> 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
= \"v1\" dependency.kind = \"ServiceAccount\" dependency.name
= desiredObj.spec.serviceAccountName dependency.namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ type DependencyInterpretation struct {
// luaScript: >
// function GetDependencies(desiredObj)
// dependencies = {}
// if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
// if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
// dependency = {}
// dependency.apiVersion = "v1"
// dependency.kind = "ServiceAccount"
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func TestGetDeployPodDependencies(t *testing.T) {
luaScript: `function GetDependencies(desiredObj)
dependentSas = {}
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
end
local idx = 1
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/interpreter/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (d *dependencyInterpretationRule) Document() string {
The script should implement a function as follows:
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/interpreter/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func TestDependencyInterpretationRule_Document(t *testing.T) {
The script should implement a function as follows:
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ end
DependencyInterpretation: &configv1alpha1.DependencyInterpretation{LuaScript: `
function GetDependencies(desiredObj)
dependencies = {}
if desiredObj.spec.serviceAccountName ~= "" and desiredObj.spec.serviceAccountName ~= "default" then
if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
dependency = {}
dependency.apiVersion = "v1"
dependency.kind = "ServiceAccount"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/resourceinterpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ var _ = framework.SerialDescribe("Resource interpreter customization testing", f
function GetDependencies(desiredObj)
dependentSas = {}
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
end
local idx = 1
Expand Down

0 comments on commit 5a583c2

Please sign in to comment.