Skip to content

Commit

Permalink
chore: use YALM field reference to reduce redundancy (apecloud#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
wusai80 authored May 25, 2023
1 parent 49fdcb7 commit 4468b16
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 155 deletions.
9 changes: 2 additions & 7 deletions deploy/apecloud-mysql/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,14 @@ spec:
creation: CREATE USER $(USERNAME) IDENTIFIED BY '$(PASSWD)';GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO $(USERNAME); GRANT LOCK TABLES,RELOAD,PROCESS,REPLICATION CLIENT, SUPER,SELECT,EVENT,TRIGGER,SHOW VIEW ON *.* TO $(USERNAME);
update: ALTER USER $(USERNAME) IDENTIFIED BY '$(PASSWD)';
- name: kbprobe
provisionPolicy:
provisionPolicy: &kbReadonlyAcctRef
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) IDENTIFIED BY '$(PASSWD)'; GRANT REPLICATION CLIENT, PROCESS ON *.* TO $(USERNAME); GRANT SELECT ON performance_schema.* TO $(USERNAME);
update: ALTER USER (USERNAME) IDENTIFIED BY '$(PASSWD)';
- name: kbmonitoring
provisionPolicy:
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) IDENTIFIED BY '$(PASSWD)'; GRANT REPLICATION CLIENT, PROCESS ON *.* TO $(USERNAME); GRANT SELECT ON performance_schema.* TO $(USERNAME);
update: ALTER USER $(USERNAME) IDENTIFIED BY '$(PASSWD)';
provisionPolicy: *kbReadonlyAcctRef
- name: kbreplicator
provisionPolicy:
type: CreateByStmt
Expand Down
18 changes: 4 additions & 14 deletions deploy/postgresql/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,33 +276,23 @@ spec:
letterCase: MixedCases
accounts:
- name: kbadmin
provisionPolicy:
provisionPolicy: &kbAdminAcctRef
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) SUPERUSER PASSWORD '$(PASSWD)';
update: ALTER USER $(USERNAME) WITH PASSWORD '$(PASSWD)';
- name: kbdataprotection
provisionPolicy:
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) SUPERUSER PASSWORD '$(PASSWD)';
update: ALTER USER $(USERNAME) WITH PASSWORD '$(PASSWD)';
provisionPolicy: *kbAdminAcctRef
- name: kbprobe
provisionPolicy:
provisionPolicy: &kbReadonlyAcctRef
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) WITH PASSWORD '$(PASSWD)'; GRANT pg_monitor TO $(USERNAME);
update: ALTER USER $(USERNAME) WITH PASSWORD '$(PASSWD)';
- name: kbmonitoring
provisionPolicy:
type: CreateByStmt
scope: AnyPods
statements:
creation: CREATE USER $(USERNAME) WITH PASSWORD '$(PASSWD)'; GRANT pg_monitor TO $(USERNAME);
update: ALTER USER $(USERNAME) WITH PASSWORD '$(PASSWD)';
provisionPolicy: *kbReadonlyAcctRef
- name: kbreplicator
provisionPolicy:
type: CreateByStmt
Expand Down
18 changes: 4 additions & 14 deletions deploy/redis/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,23 @@ spec:
letterCase: MixedCases
accounts:
- name: kbadmin
provisionPolicy:
provisionPolicy: &kbadminAcctRef
type: CreateByStmt
scope: AllPods
statements:
creation: ACL SETUSER $(USERNAME) ON \>$(PASSWD) allcommands allkeys
update: ACL SETUSER $(USERNAME) ON \>$(PASSWD)
- name: kbdataprotection
provisionPolicy:
type: CreateByStmt
scope: AllPods
statements:
creation: ACL SETUSER $(USERNAME) ON \>$(PASSWD) allcommands allkeys
update: ACL SETUSER $(USERNAME) ON \>$(PASSWD)
provisionPolicy: *kbadminAcctRef
- name: kbmonitoring
provisionPolicy:
provisionPolicy: &kbReadOnlyAcctRef
type: CreateByStmt
scope: AllPods
statements:
creation: ACL SETUSER $(USERNAME) ON \>$(PASSWD) allkeys +get
update: ACL SETUSER $(USERNAME) ON \>$(PASSWD)
- name: kbprobe
provisionPolicy:
type: CreateByStmt
scope: AllPods
statements:
creation: ACL SETUSER $(USERNAME) ON \>$(PASSWD) allkeys +get
update: ACL SETUSER $(USERNAME) ON \>$(PASSWD)
provisionPolicy: *kbReadOnlyAcctRef
- name: kbreplicator
provisionPolicy:
type: CreateByStmt
Expand Down
55 changes: 27 additions & 28 deletions deploy/weaviate/config/weaviate-config-constraint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,44 @@
#WeaviateEnvs: {

// Which modules to enable in the setup?
ENABLE_MODULES ?: string
ENABLE_MODULES?: string

// The endpoint where to reach the transformers module if enabled
TRANSFORMERS_INFERENCE_API ?: string
// The endpoint where to reach the transformers module if enabled
TRANSFORMERS_INFERENCE_API?: string

// The endpoint where to reach the clip module if enabled
CLIP_INFERENCE_API ?: string
// The endpoint where to reach the clip module if enabled
CLIP_INFERENCE_API?: string

QNA_INFERENCE_API ?: string
QNA_INFERENCE_API?: string

// The endpoint where to reach the img2vec-neural module if enabled
IMAGE_INFERENCE_API ?: string
// The endpoint where to reach the img2vec-neural module if enabled
IMAGE_INFERENCE_API?: string

// The id of the AWS access key for the desired account.
AWS_ACCESS_KEY_ID ?: string
// The id of the AWS access key for the desired account.
AWS_ACCESS_KEY_ID?: string

// The secret AWS access key for the desired account.
AWS_SECRET_ACCESS_KEY ?: string
// The secret AWS access key for the desired account.
AWS_SECRET_ACCESS_KEY?: string

// The path to the secret GCP service account or workload identity file.
GOOGLE_APPLICATION_CREDENTIALS ?: string
// The path to the secret GCP service account or workload identity file.
GOOGLE_APPLICATION_CREDENTIALS?: string

// The name of your Azure Storage account.
AZURE_STORAGE_ACCOUNT ?: string
// The name of your Azure Storage account.
AZURE_STORAGE_ACCOUNT?: string

// An access key for your Azure Storage account.
AZURE_STORAGE_KEY ?: string
// An access key for your Azure Storage account.
AZURE_STORAGE_KEY?: string

// A string that includes the authorization information required.
AZURE_STORAGE_CONNECTION_STRING ?: string

SPELLCHECK_INFERENCE_API ?: string
NER_INFERENCE_API ?: string
SUM_INFERENCE_API ?: string
OPENAI_APIKEY ?: string
HUGGINGFACE_APIKEY ?: string
COHERE_APIKEY ?: string
PALM_APIKEY ?: string
// A string that includes the authorization information required.
AZURE_STORAGE_CONNECTION_STRING?: string

SPELLCHECK_INFERENCE_API?: string
NER_INFERENCE_API?: string
SUM_INFERENCE_API?: string
OPENAI_APIKEY?: string
HUGGINGFACE_APIKEY?: string
COHERE_APIKEY?: string
PALM_APIKEY?: string
}

// SectionName is section name
Expand Down
70 changes: 35 additions & 35 deletions internal/cli/create/template/http_chaos_template.cue
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,51 @@

// required, command line input options for parameters and flags
options: {
namespace: string
selector: {}
mode: string
value: string
duration: string
namespace: string
selector: {}
mode: string
value: string
duration: string

target: string
port: int32
path: string
method: string
code?: int32
target: string
port: int32
path: string
method: string
code?: int32

abort?: bool
delay?: string
replace?: {}
patch?: {}
abort?: bool
delay?: string
replace?: {}
patch?: {}
}

// required, k8s api resource content
content: {
kind: "HTTPChaos"
apiVersion: "chaos-mesh.org/v1alpha1"
metadata:{
generateName: "http-chaos-"
namespace: options.namespace
}
spec:{
selector: options.selector
mode: options.mode
value: options.value
duration: options.duration
kind: "HTTPChaos"
apiVersion: "chaos-mesh.org/v1alpha1"
metadata: {
generateName: "http-chaos-"
namespace: options.namespace
}
spec: {
selector: options.selector
mode: options.mode
value: options.value
duration: options.duration

target: options.target
port: options.port
path: options.path
method: options.method
if options.code != _|_ {
code: options.code
}
port: options.port
path: options.path
method: options.method
if options.code != _|_ {
code: options.code
}

if options.abort != _|_ {
abort: options.abort
}
if options.abort != _|_ {
abort: options.abort
}

if options.delay != _|_ {
if options.delay != _|_ {
delay: options.delay
}

Expand Down
62 changes: 31 additions & 31 deletions internal/cli/create/template/network_chaos_template.cue
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,46 @@

// required, command line input options for parameters and flags
options: {
namespace: string
action: string
selector: {}
mode: string
value: string
duration: string
namespace: string
action: string
selector: {}
mode: string
value: string
duration: string

direction: string
externalTargets?: [...]
target?: {}
direction: string
externalTargets?: [...]
target?: {}

loss?: {}
delay?: {}
duplicate?: {}
corrupt?: {}
bandwidth?: {}
loss?: {}
delay?: {}
duplicate?: {}
corrupt?: {}
bandwidth?: {}
}

// required, k8s api resource content
content: {
kind: "NetworkChaos"
apiVersion: "chaos-mesh.org/v1alpha1"
metadata:{
generateName: "network-chaos-"
namespace: options.namespace
}
spec:{
selector: options.selector
mode: options.mode
value: options.value
action: options.action
duration: options.duration
kind: "NetworkChaos"
apiVersion: "chaos-mesh.org/v1alpha1"
metadata: {
generateName: "network-chaos-"
namespace: options.namespace
}
spec: {
selector: options.selector
mode: options.mode
value: options.value
action: options.action
duration: options.duration

direction: options.direction
direction: options.direction

if options.externalTargets != _|_ {
externalTargets: options.externalTargets
}
if options.externalTargets != _|_ {
externalTargets: options.externalTargets
}

if options.target["mode"] != _|_ || len(options.target["selector"]) !=0 {
if options.target["mode"] != _|_ || len(options.target["selector"]) != 0 {
target: options.target
}

Expand Down
Loading

0 comments on commit 4468b16

Please sign in to comment.