fix format of lua script in karmada api

Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
chaosi-zju 2023-12-01 17:40:33 +08:00
parent ed07dad2d4
commit 7bc10af1e9
4 changed files with 134 additions and 112 deletions

View File

@ -20639,7 +20639,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 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\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 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.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20653,7 +20653,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to assess the health state of a specific resource. The script should implement a function as follows:\n luaScript: \u003e\n function InterpretHealth(observedObj)\n if observedObj.status.readyReplicas == observedObj.spec.replicas then\n return true\n end\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned boolean value indicates the health status.", "description": "LuaScript holds the Lua script that is used to assess the health state of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function InterpretHealth(observedObj)\n if observedObj.status.readyReplicas == observedObj.spec.replicas then\n return true\n end\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned boolean value indicates the health status.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20667,7 +20667,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to retain runtime values to the desired specification.\n\nThe script should implement a function as follows:\n luaScript: \u003e\n function Retain(desiredObj, observedObj)\n desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo\n return desiredObj\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned object should be a retained configuration which will be applied to member cluster eventually.", "description": "LuaScript holds the Lua script that is used to retain runtime values to the desired specification.\n\nThe script should implement a function as follows:\n\n```\n luaScript: \u003e\n function Retain(desiredObj, observedObj)\n desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo\n return desiredObj\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned object should be a retained configuration which will be applied to member cluster eventually.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20681,7 +20681,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to discover the resource's replica as well as resource requirements\n\nThe script should implement a function as follows:\n luaScript: \u003e\n function GetReplicas(desiredObj)\n replica = desiredObj.spec.replicas\n requirement = {}\n requirement.nodeClaim = {}\n requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector\n requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations\n requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits\n return replica, requirement\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 function expects two return values:\n - replica: the declared replica number\n - requirement: the resource required by each replica expressed with a\n ResourceBindingSpec.ReplicaRequirements.\nThe returned values will be set into a ResourceBinding or ClusterResourceBinding.", "description": "LuaScript holds the Lua script that is used to discover the resource's replica as well as resource requirements\n\nThe script should implement a function as follows:\n\n```\n luaScript: \u003e\n function GetReplicas(desiredObj)\n replica = desiredObj.spec.replicas\n requirement = {}\n requirement.nodeClaim = {}\n requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector\n requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations\n requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits\n return replica, requirement\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 function expects two return values:\n - replica: the declared replica number\n - requirement: the resource required by each replica expressed with a\n ResourceBindingSpec.ReplicaRequirements.\nThe returned values will be set into a ResourceBinding or ClusterResourceBinding.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20695,7 +20695,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to revise replicas in the desired specification. The script should implement a function as follows:\n luaScript: \u003e\n function ReviseReplica(desiredObj, desiredReplica)\n desiredObj.spec.replicas = desiredReplica\n return desiredObj\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 - desiredReplica: the replica number should be applied with.\n\nThe returned object should be a revised configuration which will be applied to member cluster eventually.", "description": "LuaScript holds the Lua script that is used to revise replicas in the desired specification. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function ReviseReplica(desiredObj, desiredReplica)\n desiredObj.spec.replicas = desiredReplica\n return desiredObj\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 - desiredReplica: the replica number should be applied with.\n\nThe returned object should be a revised configuration which will be applied to member cluster eventually.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20955,7 +20955,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to aggregate decentralized statuses to the desired specification. The script should implement a function as follows:\n luaScript: \u003e\n function AggregateStatus(desiredObj, statusItems)\n for i = 1, #statusItems do\n desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas\n end\n return desiredObj\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 a resource template.\n - statusItems: the slice of status expressed with AggregatedStatusItem.\n\nThe returned object should be a whole object with status aggregated.", "description": "LuaScript holds the Lua script that is used to aggregate decentralized statuses to the desired specification. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function AggregateStatus(desiredObj, statusItems)\n for i = 1, #statusItems do\n desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas\n end\n return desiredObj\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 a resource template.\n - statusItems: the slice of status expressed with AggregatedStatusItem.\n\nThe returned object should be a whole object with status aggregated.",
"type": "string", "type": "string",
"default": "" "default": ""
} }
@ -20969,7 +20969,7 @@
], ],
"properties": { "properties": {
"luaScript": { "luaScript": {
"description": "LuaScript holds the Lua script that is used to get the status from the observed specification. The script should implement a function as follows:\n luaScript: \u003e\n function ReflectStatus(observedObj)\n status = {}\n status.readyReplicas = observedObj.status.observedObj\n return status\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned status could be the whole status or part of it and will be set into both Work and ResourceBinding(ClusterResourceBinding).", "description": "LuaScript holds the Lua script that is used to get the status from the observed specification. The script should implement a function as follows:\n\n```\n luaScript: \u003e\n function ReflectStatus(observedObj)\n status = {}\n status.readyReplicas = observedObj.status.observedObj\n return status\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned status could be the whole status or part of it and will be set into both Work and ResourceBinding(ClusterResourceBinding).",
"type": "string", "type": "string",
"default": "" "default": ""
} }

View File

@ -50,14 +50,14 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
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: \n ``` luaScript:
> function GetDependencies(desiredObj) dependencies = {} > function GetDependencies(desiredObj) dependencies = {}
if desiredObj.spec.serviceAccountName ~= nil 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
= desiredObj.namespace dependencies[1] = {} dependencies[1] = desiredObj.namespace dependencies[1] = {} dependencies[1]
= dependency end return dependencies end \n The content = dependency end return dependencies end ``` \n The content
of the LuaScript needs to be a whole function including of the LuaScript needs to be a whole function including
both declaration and implementation. \n The parameters will both declaration and implementation. \n The parameters will
be supplied by the system: - desiredObj: the object represents be supplied by the system: - desiredObj: the object represents
@ -75,10 +75,10 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to assess the health state of a specific resource. The script to assess the health state of a specific resource. The script
should implement a function as follows: luaScript: > function should implement a function as follows: \n ``` luaScript:
InterpretHealth(observedObj) if observedObj.status.readyReplicas > function InterpretHealth(observedObj) if observedObj.status.readyReplicas
== observedObj.spec.replicas then return true end end \n == observedObj.spec.replicas then return true end end ```
The content of the LuaScript needs to be a whole function \n The content of the LuaScript needs to be a whole function
including both declaration and implementation. \n The parameters including both declaration and implementation. \n The parameters
will be supplied by the system: - observedObj: the object will be supplied by the system: - observedObj: the object
represents the configuration that is observed from a specific represents the configuration that is observed from a specific
@ -100,14 +100,14 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to discover the resource's replica as well as resource requirements to discover the resource's replica as well as resource requirements
\n The script should implement a function as follows: luaScript: \n The script should implement a function as follows: \n
> function GetReplicas(desiredObj) replica = desiredObj.spec.replicas ``` luaScript: > function GetReplicas(desiredObj) replica
requirement = {} requirement.nodeClaim = {} requirement.nodeClaim.nodeSelector = desiredObj.spec.replicas requirement = {} requirement.nodeClaim
= desiredObj.spec.template.spec.nodeSelector requirement.nodeClaim.tolerations = {} requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector
= desiredObj.spec.template.spec.tolerations requirement.resourceRequest requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations
= desiredObj.spec.template.spec.containers[1].resources.limits requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits
return replica, requirement end \n The content of the LuaScript return replica, requirement end ``` \n The content of the
needs to be a whole function including both declaration LuaScript needs to be a whole function including both declaration
and implementation. \n The parameters will be supplied by and implementation. \n The parameters will be supplied by
the system: - desiredObj: the object represents the configuration the system: - desiredObj: the object represents the configuration
to be applied to the member cluster. \n The function expects to be applied to the member cluster. \n The function expects
@ -130,12 +130,12 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to revise replicas in the desired specification. The script to revise replicas in the desired specification. The script
should implement a function as follows: luaScript: > function should implement a function as follows: \n ``` luaScript:
ReviseReplica(desiredObj, desiredReplica) desiredObj.spec.replicas > function ReviseReplica(desiredObj, desiredReplica) desiredObj.spec.replicas
= desiredReplica return desiredObj end \n The content of = desiredReplica return desiredObj end ``` \n The content
the LuaScript needs to be a whole function including both of the LuaScript needs to be a whole function including
declaration and implementation. \n The parameters will be both declaration and implementation. \n The parameters will
supplied by the system: - desiredObj: the object represents be supplied by the system: - desiredObj: the object represents
the configuration to be applied to the member cluster. - the configuration to be applied to the member cluster. -
desiredReplica: the replica number should be applied with. desiredReplica: the replica number should be applied with.
\n The returned object should be a revised configuration \n The returned object should be a revised configuration
@ -157,17 +157,17 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to retain runtime values to the desired specification. \n to retain runtime values to the desired specification. \n
The script should implement a function as follows: luaScript: The script should implement a function as follows: \n ```
> function Retain(desiredObj, observedObj) desiredObj.spec.fieldFoo luaScript: > function Retain(desiredObj, observedObj) desiredObj.spec.fieldFoo
= observedObj.spec.fieldFoo return desiredObj end \n The = observedObj.spec.fieldFoo return desiredObj end ``` \n
content of the LuaScript needs to be a whole function including The content of the LuaScript needs to be a whole function
both declaration and implementation. \n The parameters will including both declaration and implementation. \n The parameters
be supplied by the system: - desiredObj: the object represents will be supplied by the system: - desiredObj: the object
the configuration to be applied to the member cluster. - represents the configuration to be applied to the member
observedObj: the object represents the configuration that cluster. - observedObj: the object represents the configuration
is observed from a specific member cluster. \n The returned that is observed from a specific member cluster. \n The
object should be a retained configuration which will be returned object should be a retained configuration which
applied to member cluster eventually." will be applied to member cluster eventually."
type: string type: string
required: required:
- luaScript - luaScript
@ -182,11 +182,11 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to aggregate decentralized statuses to the desired specification. to aggregate decentralized statuses to the desired specification.
The script should implement a function as follows: luaScript: The script should implement a function as follows: \n ```
> function AggregateStatus(desiredObj, statusItems) for luaScript: > function AggregateStatus(desiredObj, statusItems)
i = 1, #statusItems do desiredObj.status.readyReplicas = for i = 1, #statusItems do desiredObj.status.readyReplicas
desiredObj.status.readyReplicas + items[i].readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas
end return desiredObj end \n The content of the LuaScript end return desiredObj end ``` \n The content of the LuaScript
needs to be a whole function including both declaration needs to be a whole function including both declaration
and implementation. \n The parameters will be supplied by and implementation. \n The parameters will be supplied by
the system: - desiredObj: the object represents a resource the system: - desiredObj: the object represents a resource
@ -206,15 +206,16 @@ spec:
luaScript: luaScript:
description: "LuaScript holds the Lua script that is used description: "LuaScript holds the Lua script that is used
to get the status from the observed specification. The script to get the status from the observed specification. The script
should implement a function as follows: luaScript: > function should implement a function as follows: \n ``` luaScript:
ReflectStatus(observedObj) status = {} status.readyReplicas > function ReflectStatus(observedObj) status = {} status.readyReplicas
= observedObj.status.observedObj return status end \n The = observedObj.status.observedObj return status end ``` \n
content of the LuaScript needs to be a whole function including The content of the LuaScript needs to be a whole function
both declaration and implementation. \n The parameters will including both declaration and implementation. \n The parameters
be supplied by the system: - observedObj: the object represents will be supplied by the system: - observedObj: the object
the configuration that is observed from a specific member represents the configuration that is observed from a specific
cluster. \n The returned status could be the whole status member cluster. \n The returned status could be the whole
or part of it and will be set into both Work and ResourceBinding(ClusterResourceBinding)." status or part of it and will be set into both Work and
ResourceBinding(ClusterResourceBinding)."
type: string type: string
required: required:
- luaScript - luaScript

View File

@ -139,11 +139,14 @@ type LocalValueRetention struct {
// to the desired specification. // to the desired specification.
// //
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function Retain(desiredObj, observedObj) // ```
// desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo // luaScript: >
// return desiredObj // function Retain(desiredObj, observedObj)
// end // desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo
// return desiredObj
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -167,16 +170,19 @@ type ReplicaResourceRequirement struct {
// replica as well as resource requirements // replica as well as resource requirements
// //
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function GetReplicas(desiredObj) // ```
// replica = desiredObj.spec.replicas // luaScript: >
// requirement = {} // function GetReplicas(desiredObj)
// requirement.nodeClaim = {} // replica = desiredObj.spec.replicas
// requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector // requirement = {}
// requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations // requirement.nodeClaim = {}
// requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits // requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector
// return replica, requirement // requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations
// end // requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits
// return replica, requirement
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -198,11 +204,14 @@ type ReplicaResourceRequirement struct {
type ReplicaRevision struct { type ReplicaRevision struct {
// LuaScript holds the Lua script that is used to revise replicas in the desired specification. // LuaScript holds the Lua script that is used to revise replicas in the desired specification.
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function ReviseReplica(desiredObj, desiredReplica) // ```
// desiredObj.spec.replicas = desiredReplica // luaScript: >
// return desiredObj // function ReviseReplica(desiredObj, desiredReplica)
// end // desiredObj.spec.replicas = desiredReplica
// return desiredObj
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -222,12 +231,15 @@ type ReplicaRevision struct {
type StatusReflection struct { type StatusReflection struct {
// LuaScript holds the Lua script that is used to get the status from the observed specification. // LuaScript holds the Lua script that is used to get the status from the observed specification.
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function ReflectStatus(observedObj) // ```
// status = {} // luaScript: >
// status.readyReplicas = observedObj.status.observedObj // function ReflectStatus(observedObj)
// return status // status = {}
// end // status.readyReplicas = observedObj.status.observedObj
// return status
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -247,13 +259,16 @@ type StatusAggregation struct {
// LuaScript holds the Lua script that is used to aggregate decentralized statuses // LuaScript holds the Lua script that is used to aggregate decentralized statuses
// to the desired specification. // to the desired specification.
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function AggregateStatus(desiredObj, statusItems) // ```
// for i = 1, #statusItems do // luaScript: >
// desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas // function AggregateStatus(desiredObj, statusItems)
// end // for i = 1, #statusItems do
// return desiredObj // desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas
// end // end
// return desiredObj
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -273,12 +288,15 @@ type HealthInterpretation struct {
// LuaScript holds the Lua script that is used to assess the health state of // LuaScript holds the Lua script that is used to assess the health state of
// a specific resource. // a specific resource.
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function InterpretHealth(observedObj) // ```
// if observedObj.status.readyReplicas == observedObj.spec.replicas then // luaScript: >
// return true // function InterpretHealth(observedObj)
// end // if observedObj.status.readyReplicas == observedObj.spec.replicas then
// end // return true
// end
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.
@ -299,20 +317,23 @@ type DependencyInterpretation struct {
// LuaScript holds the Lua script that is used to interpret the dependencies of // LuaScript holds the Lua script that is used to interpret the dependencies of
// a specific resource. // a specific resource.
// The script should implement a function as follows: // The script should implement a function as follows:
// luaScript: > //
// function GetDependencies(desiredObj) // ```
// dependencies = {} // luaScript: >
// if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then // function GetDependencies(desiredObj)
// dependency = {} // dependencies = {}
// dependency.apiVersion = "v1" // if desiredObj.spec.serviceAccountName ~= nil and desiredObj.spec.serviceAccountName ~= "default" then
// dependency.kind = "ServiceAccount" // dependency = {}
// dependency.name = desiredObj.spec.serviceAccountName // dependency.apiVersion = "v1"
// dependency.namespace = desiredObj.namespace // dependency.kind = "ServiceAccount"
// dependencies[1] = {} // dependency.name = desiredObj.spec.serviceAccountName
// dependencies[1] = dependency // dependency.namespace = desiredObj.namespace
// end // dependencies[1] = {}
// return dependencies // dependencies[1] = dependency
// end // end
// return dependencies
// end
// ```
// //
// The content of the LuaScript needs to be a whole function including both // The content of the LuaScript needs to be a whole function including both
// declaration and implementation. // declaration and implementation.

View File

@ -1805,7 +1805,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 ~= 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.", 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.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -1879,7 +1879,7 @@ func schema_pkg_apis_config_v1alpha1_HealthInterpretation(ref common.ReferenceCa
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 assess the health state of a specific resource. The script should implement a function as follows:\n luaScript: >\n function InterpretHealth(observedObj)\n if observedObj.status.readyReplicas == observedObj.spec.replicas then\n return true\n end\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned boolean value indicates the health status.", Description: "LuaScript holds the Lua script that is used to assess the health state of a specific resource. The script should implement a function as follows:\n\n```\n luaScript: >\n function InterpretHealth(observedObj)\n if observedObj.status.readyReplicas == observedObj.spec.replicas then\n return true\n end\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned boolean value indicates the health status.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -1901,7 +1901,7 @@ func schema_pkg_apis_config_v1alpha1_LocalValueRetention(ref common.ReferenceCal
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 retain runtime values to the desired specification.\n\nThe script should implement a function as follows:\n luaScript: >\n function Retain(desiredObj, observedObj)\n desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo\n return desiredObj\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned object should be a retained configuration which will be applied to member cluster eventually.", Description: "LuaScript holds the Lua script that is used to retain runtime values to the desired specification.\n\nThe script should implement a function as follows:\n\n```\n luaScript: >\n function Retain(desiredObj, observedObj)\n desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo\n return desiredObj\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned object should be a retained configuration which will be applied to member cluster eventually.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -1923,7 +1923,7 @@ func schema_pkg_apis_config_v1alpha1_ReplicaResourceRequirement(ref common.Refer
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 discover the resource's replica as well as resource requirements\n\nThe script should implement a function as follows:\n luaScript: >\n function GetReplicas(desiredObj)\n replica = desiredObj.spec.replicas\n requirement = {}\n requirement.nodeClaim = {}\n requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector\n requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations\n requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits\n return replica, requirement\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 function expects two return values:\n - replica: the declared replica number\n - requirement: the resource required by each replica expressed with a\n ResourceBindingSpec.ReplicaRequirements.\nThe returned values will be set into a ResourceBinding or ClusterResourceBinding.", Description: "LuaScript holds the Lua script that is used to discover the resource's replica as well as resource requirements\n\nThe script should implement a function as follows:\n\n```\n luaScript: >\n function GetReplicas(desiredObj)\n replica = desiredObj.spec.replicas\n requirement = {}\n requirement.nodeClaim = {}\n requirement.nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector\n requirement.nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations\n requirement.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits\n return replica, requirement\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 function expects two return values:\n - replica: the declared replica number\n - requirement: the resource required by each replica expressed with a\n ResourceBindingSpec.ReplicaRequirements.\nThe returned values will be set into a ResourceBinding or ClusterResourceBinding.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -1945,7 +1945,7 @@ func schema_pkg_apis_config_v1alpha1_ReplicaRevision(ref common.ReferenceCallbac
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 revise replicas in the desired specification. The script should implement a function as follows:\n luaScript: >\n function ReviseReplica(desiredObj, desiredReplica)\n desiredObj.spec.replicas = desiredReplica\n return desiredObj\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 - desiredReplica: the replica number should be applied with.\n\nThe returned object should be a revised configuration which will be applied to member cluster eventually.", Description: "LuaScript holds the Lua script that is used to revise replicas in the desired specification. The script should implement a function as follows:\n\n```\n luaScript: >\n function ReviseReplica(desiredObj, desiredReplica)\n desiredObj.spec.replicas = desiredReplica\n return desiredObj\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 - desiredReplica: the replica number should be applied with.\n\nThe returned object should be a revised configuration which will be applied to member cluster eventually.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -2637,7 +2637,7 @@ func schema_pkg_apis_config_v1alpha1_StatusAggregation(ref common.ReferenceCallb
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 aggregate decentralized statuses to the desired specification. The script should implement a function as follows:\n luaScript: >\n function AggregateStatus(desiredObj, statusItems)\n for i = 1, #statusItems do\n desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas\n end\n return desiredObj\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 a resource template.\n - statusItems: the slice of status expressed with AggregatedStatusItem.\n\nThe returned object should be a whole object with status aggregated.", Description: "LuaScript holds the Lua script that is used to aggregate decentralized statuses to the desired specification. The script should implement a function as follows:\n\n```\n luaScript: >\n function AggregateStatus(desiredObj, statusItems)\n for i = 1, #statusItems do\n desiredObj.status.readyReplicas = desiredObj.status.readyReplicas + items[i].readyReplicas\n end\n return desiredObj\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 a resource template.\n - statusItems: the slice of status expressed with AggregatedStatusItem.\n\nThe returned object should be a whole object with status aggregated.",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",
@ -2659,7 +2659,7 @@ func schema_pkg_apis_config_v1alpha1_StatusReflection(ref common.ReferenceCallba
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 get the status from the observed specification. The script should implement a function as follows:\n luaScript: >\n function ReflectStatus(observedObj)\n status = {}\n status.readyReplicas = observedObj.status.observedObj\n return status\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned status could be the whole status or part of it and will be set into both Work and ResourceBinding(ClusterResourceBinding).", Description: "LuaScript holds the Lua script that is used to get the status from the observed specification. The script should implement a function as follows:\n\n```\n luaScript: >\n function ReflectStatus(observedObj)\n status = {}\n status.readyReplicas = observedObj.status.observedObj\n return status\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 - observedObj: the object represents the configuration that is observed\n from a specific member cluster.\n\nThe returned status could be the whole status or part of it and will be set into both Work and ResourceBinding(ClusterResourceBinding).",
Default: "", Default: "",
Type: []string{"string"}, Type: []string{"string"},
Format: "", Format: "",