@toa.io/operations 0.20.0-dev.3 → 0.20.0-dev.31

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/operations",
3
- "version": "0.20.0-dev.3",
3
+ "version": "0.20.0-dev.31",
4
4
  "description": "Toa Deployment",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -22,14 +22,15 @@
22
22
  "access": "public"
23
23
  },
24
24
  "main": "src/index.js",
25
+ "types": "types/index.d.ts",
25
26
  "scripts": {
26
27
  "test": "echo \"Error: run tests from root\" && exit 1"
27
28
  },
28
29
  "dependencies": {
29
- "@toa.io/filesystem": "0.20.0-dev.3",
30
- "@toa.io/generic": "0.20.0-dev.3",
31
- "@toa.io/yaml": "0.20.0-dev.3",
30
+ "@toa.io/filesystem": "0.20.0-dev.31",
31
+ "@toa.io/generic": "0.20.0-dev.31",
32
+ "@toa.io/yaml": "0.20.0-dev.31",
32
33
  "execa": "5.1.1"
33
34
  },
34
- "gitHead": "3eabf45761f4cf211e1e4c331933ec60b4a828a7"
35
+ "gitHead": "f9ad6bf2bab1298b96ca52557b7e36b6041cfc88"
35
36
  }
package/readme.md CHANGED
@@ -11,8 +11,8 @@
11
11
 
12
12
  registry:
13
13
  build:
14
- arguments: [NPM_TOKEN]
15
- run: echo //npm.pkg.github.com/:_authToken=${NPM_TOKEN} > .npmrc
14
+ arguments: [GITHUB_TOKEN]
15
+ run: npm config set //npm.pkg.github.com/:_authToken ${GITHUB_TOKEN}
16
16
  ```
17
17
 
18
18
  `arguments` is a list of environemt varialbes to be passed to `docker build`.
@@ -28,3 +28,15 @@ registry:
28
28
  echo test > .test
29
29
  rm .test
30
30
  ```
31
+
32
+ #### Registry Credentials
33
+
34
+ When using private container registry,
35
+ a secret containing required credentials can be specified using `registry.credentials` option.
36
+
37
+ ```yaml
38
+ # context.toa.yaml
39
+
40
+ registry:
41
+ credentials: docker-credentials-secret-name
42
+ ```
@@ -14,6 +14,7 @@ const describe = (context, compositions, dependency) => {
14
14
  const components = get.components(compositions)
15
15
  const dependencies = get.dependencies(references)
16
16
  const variables = get.variables(context, dependency.variables)
17
+ const credentials = context.registry?.credentials
17
18
 
18
19
  return {
19
20
  compositions,
@@ -21,6 +22,7 @@ const describe = (context, compositions, dependency) => {
21
22
  services,
22
23
  proxies,
23
24
  variables,
25
+ credentials,
24
26
  ...dependencies
25
27
  }
26
28
  }
@@ -34,5 +34,9 @@ spec:
34
34
  {{- include "env.var" . | indent 12 }}
35
35
  {{- end }}
36
36
  {{- end }}
37
+ {{- if $.Values.credentials }}
38
+ imagePullSecrets:
39
+ - name: {{ $.Values.credentials }}
40
+ {{- end }}
37
41
  ---
38
42
  {{- end }}
@@ -45,3 +45,4 @@ proxies:
45
45
  - name: storage-proxy
46
46
  target: host.docker.internal
47
47
  environment: development
48
+ credentials: docker-credentials
@@ -3,16 +3,17 @@ FROM node:18.16.0-alpine3.17
3
3
  {{build.arguments}}
4
4
 
5
5
  ENV NODE_ENV=production
6
- RUN if [ {{runtime.registry}} != undefined ]; then npm set registry {{runtime.registry}}; fi
7
- RUN if [ {{runtime.proxy}} != undefined ]; then npm set proxy {{runtime.proxy}}; fi
8
- RUN npm i -g @toa.io/runtime@{{runtime.version}}
6
+ RUN if [ "{{runtime.registry}}" != "" ]; then npm set registry {{runtime.registry}}; fi
7
+ RUN if [ "{{runtime.proxy}}" != "" ]; then npm set proxy {{runtime.proxy}}; fi
8
+ RUN npm i -g @toa.io/runtime@{{runtime.version}} --omit=dev
9
9
 
10
10
  WORKDIR /composition
11
- ADD . .
12
-
13
- # run 'npm i' in each component
14
- RUN find . -maxdepth 1 -type d \( ! -name . \) -exec /bin/sh -c "cd '{}' && if [ -f package.json ]; then npm i; fi" \;
11
+ COPY --chown=node:node . /composition
15
12
 
16
13
  {{build.run}}
17
14
 
15
+ # run 'npm i' in each component
16
+ RUN for entry in *; do if [ -f "$entry/package.json" ]; then (cd $entry && npm i --omit=dev); fi; done
17
+
18
+ USER node
18
19
  CMD toa compose *
@@ -1,12 +1,14 @@
1
1
  FROM node:18.16.0-alpine3.17
2
2
 
3
3
  ENV NODE_ENV=production
4
- RUN if [ {{runtime.registry}} != undefined ]; then npm set registry {{runtime.registry}}; fi
5
- RUN if [ {{runtime.proxy}} != undefined ]; then npm set proxy {{runtime.proxy}}; fi
6
- RUN npm i -g @toa.io/runtime@{{runtime.version}}
4
+ RUN if [ "{{runtime.registry}}" != "" ]; then npm set registry {{runtime.registry}}; fi
5
+ RUN if [ "{{runtime.proxy}}" != "" ]; then npm set proxy {{runtime.proxy}}; fi
6
+ RUN npm i -g @toa.io/runtime@{{runtime.version}} --omit=dev
7
7
 
8
8
  WORKDIR /service
9
- ADD . .
10
- RUN npm i
9
+ COPY --chown=node:node . /service
11
10
 
11
+ RUN npm i --omit=dev
12
+
13
+ USER node
12
14
  CMD toa serve .
@@ -0,0 +1,72 @@
1
+ import * as _service from './service'
2
+ import { dependencies } from '@toa.io/norm/types/context'
3
+
4
+ declare namespace toa.deployment {
5
+
6
+ namespace dependency {
7
+
8
+ type Constructor = (instances: dependencies.Instance[], annotation: any) => Declaration
9
+
10
+ type Reference = {
11
+ name: string
12
+ version: string
13
+ repository?: string
14
+ alias?: string
15
+ values?: Object
16
+ }
17
+
18
+ type Service = {
19
+ group: string
20
+ name: string
21
+ version: string
22
+ port: number
23
+ ingress?: {
24
+ host: string
25
+ class: string
26
+ annotations?: object
27
+ }
28
+ }
29
+
30
+ type Proxy = {
31
+ name: string
32
+ target: string
33
+ }
34
+
35
+ type Variable = {
36
+ name: string
37
+ value?: string | number
38
+ secret?: {
39
+ name: string,
40
+ key: string
41
+ }
42
+ }
43
+
44
+ type Variables = {
45
+ [key: string]: Variable[]
46
+ }
47
+
48
+ type Declaration = {
49
+ references?: Reference[]
50
+ services?: Service[] // dependency.Service
51
+ proxies?: Proxy[]
52
+ variables?: Variables
53
+ }
54
+
55
+ }
56
+
57
+ type Dependency = {
58
+ references?: dependency.Reference[]
59
+ services?: _service.Service[] // deployment.Service
60
+ proxies?: dependency.Proxy[]
61
+ variables?: dependency.Variables
62
+ }
63
+
64
+ }
65
+
66
+ export type Declaration = toa.deployment.dependency.Declaration
67
+ export type Reference = toa.deployment.dependency.Reference
68
+ export type Service = toa.deployment.dependency.Service
69
+ export type Proxy = toa.deployment.dependency.Proxy
70
+ export type Variables = toa.deployment.dependency.Variables
71
+ export type Variable = toa.deployment.dependency.Variable
72
+ export type Dependency = toa.deployment.Dependency
@@ -1,72 +1,36 @@
1
- import * as _service from './service'
2
- import { dependencies } from '@toa.io/norm/types/context'
3
-
4
- declare namespace toa.deployment {
5
-
6
- namespace dependency {
7
-
8
- type Constructor = (instances: dependencies.Instance[], annotation: any) => Declaration
9
-
10
- type Reference = {
11
- name: string
12
- version: string
13
- repository?: string
14
- alias?: string
15
- values?: Object
16
- }
17
-
18
- type Service = {
19
- group: string
20
- name: string
21
- version: string
22
- port: number
23
- ingress?: {
24
- host: string
25
- class: string
26
- annotations?: object
27
- }
28
- }
29
-
30
- type Proxy = {
31
- name: string
32
- target: string
33
- }
34
-
35
- type Variable = {
36
- name: string
37
- value?: string | number
38
- secret?: {
39
- name: string,
40
- key: string
41
- }
42
- }
43
-
44
- type Variables = {
45
- [key: string]: Variable[]
46
- }
47
-
48
- type Declaration = {
49
- references?: Reference[]
50
- services?: Service[] // dependency.Service
51
- proxies?: Proxy[]
52
- variables?: Variables
53
- }
1
+ type Reference = {
2
+ name: string
3
+ version: string
4
+ repository?: string
5
+ alias?: string
6
+ values?: Object
7
+ }
54
8
 
9
+ type Service = {
10
+ group: string
11
+ name: string
12
+ version: string
13
+ port: number
14
+ ingress?: {
15
+ host: string
16
+ class: string
17
+ annotations?: object
55
18
  }
19
+ }
56
20
 
57
- type Dependency = {
58
- references?: dependency.Reference[]
59
- services?: _service.Service[] // deployment.Service
60
- proxies?: dependency.Proxy[]
61
- variables?: dependency.Variables
21
+ type Variable = {
22
+ name: string
23
+ value?: string
24
+ secret?: {
25
+ name: string,
26
+ key: string
62
27
  }
63
-
64
28
  }
65
29
 
66
- export type Declaration = toa.deployment.dependency.Declaration
67
- export type Reference = toa.deployment.dependency.Reference
68
- export type Service = toa.deployment.dependency.Service
69
- export type Proxy = toa.deployment.dependency.Proxy
70
- export type Variables = toa.deployment.dependency.Variables
71
- export type Variable = toa.deployment.dependency.Variable
72
- export type Dependency = toa.deployment.Dependency
30
+ type Variables = Record<string, Variable[]>
31
+
32
+ export type Dependency = {
33
+ references?: Reference[]
34
+ services?: Service[]
35
+ variables?: Variables
36
+ }
@@ -0,0 +1 @@
1
+ export * from './dependency'
@@ -0,0 +1 @@
1
+ export * as deployment from './deployment'
File without changes
File without changes
File without changes
File without changes