@xfe-repo/web-app 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  {{- define "template.namespace" -}}
2
- {{ if eq $.Values.envType "dev" }} deployment-dev {{ else if eq $.Values.envType "test" }} deployment-test {{ else if eq $.Values.envType "stage" }} deployment-stage {{ else if eq $.Values.envType "beta" }} deployment-beta {{ else if eq $.Values.envType "prod" }} deployment-prod {{ else if eq $.Values.envType "apitest" }} ci-apitest {{ else }} deployment-test {{ end }}
2
+ {{ if not (empty .Values.namespace) }}{{ .Values.namespace }}{{ else }}deployment-{{ .Values.envType }}{{ end }}
3
3
  {{- end -}}
@@ -1,26 +1,27 @@
1
+ {{- if .Values.virtualService.enabled }}
1
2
  apiVersion: networking.istio.io/v1alpha3
2
3
  kind: VirtualService
3
4
  metadata:
4
- name: {{ $.Values.app }}-vs
5
+ name: {{ .Values.app }}-vs
5
6
  namespace: {{ include "template.namespace" . }}
6
7
  spec:
7
8
  hosts:
8
- {{- $host := (get $.Values.hosts $.Values.envType) }}
9
- {{- range $host }}
10
- - "{{ . }}"
11
- {{- end }}
9
+ {{- $host := (get .Values.virtualService.hosts .Values.envType) }}
10
+ {{- range $host }}
11
+ - "{{ . }}"
12
+ {{- end }}
12
13
  gateways:
13
- {{- $gateways := $.Values.gateways }}
14
- {{- range $gateways }}
15
- - "{{ . }}"
16
- {{- end }}
14
+ {{- $gateways := .Values.virtualService.gateways }}
15
+ {{- range $gateways }}
16
+ - "{{ . }}"
17
+ {{- end }}
17
18
  http:
18
19
  - match:
19
20
  - uri:
20
21
  prefix: /
21
22
  route:
22
23
  - destination:
23
- host: {{ $.Values.app }}
24
+ host: {{ .Values.app }}
24
25
  port:
25
26
  number: 80
26
27
  corsPolicy:
@@ -28,4 +29,4 @@ spec:
28
29
  - "*"
29
30
  allowMethods:
30
31
  - "*"
31
- ---
32
+ {{- end }}
@@ -5,14 +5,17 @@ tagContent: '<<TAG_CONTENT>>'
5
5
  commitSHA: '<<CI_COMMIT_SHA>>'
6
6
  envType: '<<ENV_TYPE>>'
7
7
  hostPrefix: '<<HOST_PREFIX>>'
8
- hosts:
9
- test:
10
- - 'test.template.com'
11
- stage:
12
- - 'stage.template.com'
13
- prod:
14
- - 'template.com'
15
- gateways:
16
- - 'common-gateway-eshetang'
8
+ namespace: ''
9
+ virtualService:
10
+ enabled: false
11
+ hosts:
12
+ test:
13
+ - 'test.template.com'
14
+ stage:
15
+ - 'stage.template.com'
16
+ prod:
17
+ - 'template.com'
18
+ gateways:
19
+ - 'common-gateway-eshetang'
17
20
  # 目标集群 默认发布到saas集群 可选值: saas, infra
18
21
  targetK8s: 'saas'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-app",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "bin": {
5
5
  "xfe-web": "./bin/index.js"
6
6
  },
@@ -73,7 +73,7 @@
73
73
  "webpack-manifest-plugin": "^4.0.2",
74
74
  "workbox-webpack-plugin": "^7.0.0",
75
75
  "yaml": "^2.3.4",
76
- "@xfe-repo/typescript-config": "0.0.3",
77
- "@xfe-repo/eslint-config": "0.0.2"
76
+ "@xfe-repo/eslint-config": "0.0.2",
77
+ "@xfe-repo/typescript-config": "0.0.3"
78
78
  }
79
79
  }
package/scripts/config.js CHANGED
@@ -21,11 +21,15 @@ const configDeploy = () => {
21
21
  const valuesYamlFile = fs.readFileSync(valuesYamlFilePath, 'utf8')
22
22
  const valuesYaml = yaml.parse(valuesYamlFile)
23
23
 
24
- if(!valuesYaml.hosts) valuesYaml.hosts = { test: [], stage: [], prod: [] }
24
+ if(!valuesYaml.virtualService) valuesYaml.virtualService = {}
25
25
 
26
- valuesYaml.hosts.prod = xfeConfig.deploy.hostsProd || []
27
- valuesYaml.hosts.stage = xfeConfig.deploy.hostsStage || []
28
- valuesYaml.hosts.test = xfeConfig.deploy.hostsTest || []
26
+ if(!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = { test: [], stage: [], prod: [] }
27
+
28
+ valuesYaml.virtualService.enabled = xfeConfig.deploy.virtualServiceEnabled || true
29
+
30
+ valuesYaml.virtualService.hosts.prod = xfeConfig.deploy.hostsProd || []
31
+ valuesYaml.virtualService.hosts.stage = xfeConfig.deploy.hostsStage || []
32
+ valuesYaml.virtualService.hosts.test = xfeConfig.deploy.hostsTest || []
29
33
 
30
34
  // gateways 默认为 common-gateway-eshetang
31
35
  valuesYaml.gateways = xfeConfig.deploy.gateways || ["common-gateway-eshetang"]
@@ -33,6 +37,9 @@ const configDeploy = () => {
33
37
  // 修改目标集群
34
38
  valuesYaml.targetK8s = xfeConfig.deploy.targetK8s || "saas"
35
39
 
40
+ // 修改目标命名空间
41
+ valuesYaml.namespace = xfeConfig.deploy.targetNamespace || ''
42
+
36
43
  // 写入values.yaml
37
44
  const valuesYamlStr = yaml.stringify(valuesYaml, { defaultStringType: 'QUOTE_SINGLE', defaultKeyType: 'PLAIN' })
38
45
  fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, 'utf8')