@jfvilas/kwirth-common 0.2.6 → 0.2.7

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": "@jfvilas/kwirth-common",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Common interfaces for integrating applications with Kwirth",
5
5
  "scripts": {
6
6
  "build": "del .\\dist\\* /s /q && tsc"
@@ -9,6 +9,12 @@
9
9
  "access": "public",
10
10
  "main": "dist/index.js"
11
11
  },
12
+ "main": "dist/index.js",
13
+ "module": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
12
18
  "repository": {
13
19
  "type": "git",
14
20
  "url": "git+https://github.com/jfvilas/kwirth-common.git"
@@ -1,38 +0,0 @@
1
- {
2
- "name": "@jfvilas/kwirth-common",
3
- "version": "0.2.4",
4
- "description": "Common interfaces for integrating applications with Kwirth",
5
- "main": "src/index.ts",
6
- "types": "src/index.ts",
7
- "scripts": {
8
- "build": "del .\\dist\\* /s /q && tsc"
9
- },
10
- "publishConfig": {
11
- "access": "public",
12
- "main": "dist/index.js",
13
- "types": "dist/index.d.ts"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/jfvilas/kwirth-common.git"
18
- },
19
- "keywords": [
20
- "kwrith",
21
- "kubernetes",
22
- "log",
23
- "observability",
24
- "kubelog"
25
- ],
26
- "author": "Julio Fernandez",
27
- "license": "ISC",
28
- "bugs": {
29
- "url": "https://github.com/jfvilas/kwirth-common/issues"
30
- },
31
- "homepage": "https://github.com/jfvilas/kwirth-common#readme",
32
- "dependencies": {
33
- "guid": "^0.0.12"
34
- },
35
- "devDependencies": {
36
- "@types/guid": "^1.0.3"
37
- }
38
- }
package/src/AccessKey.ts DELETED
@@ -1,122 +0,0 @@
1
- import Guid from 'guid';
2
-
3
- /*
4
- Access key format is:
5
-
6
- id|type|resource
7
-
8
- where:
9
- id: is a GUID
10
- type: is volatile' or 'permanent' (the second type is persisted when created)
11
- resource: is a stringified ResourceIdentifier
12
- */
13
- class AccessKey {
14
- public id:string='';
15
- public type:string='volatile';
16
- public resource:string='';
17
- }
18
-
19
- function accessKeyCreate(type:string, resource:string) : AccessKey {
20
- var accessKey=new AccessKey();
21
- accessKey.id=Guid.create().toString();
22
- accessKey.type=type;
23
- accessKey.resource=resource;
24
- return accessKey;
25
- }
26
-
27
- function accessKeyBuild(id:string, type:string, resource:string) : AccessKey {
28
- var accessKey=new AccessKey();
29
- accessKey.id=id;
30
- accessKey.type=type;
31
- accessKey.resource=resource;
32
- return accessKey;
33
- }
34
-
35
- function accessKeySerialize (accessKey:AccessKey) : string {
36
- return `${accessKey.id}|${accessKey.type}|${accessKey.resource}`;
37
- }
38
-
39
- function accessKeyDeserialize (key:string) : AccessKey {
40
- var parts=key.split('|');
41
- return accessKeyBuild(parts[0], parts[1], parts[2]);
42
- }
43
-
44
- function parseResource (key:string) : ResourceIdentifier {
45
- var parts=key.split(':');
46
- return {
47
- scope:parts[0],
48
- namespace:parts[1],
49
- set:parts[2],
50
- pod:parts[3],
51
- container:parts[4]
52
- }
53
- }
54
-
55
- function buildResource (scope:string, namespace:string, groupType:string, groupName:string, pod:string, container:string) : string {
56
- return `${scope}:${namespace}:${groupType}+${groupName}:${pod}:${container}`;
57
- }
58
-
59
- /*
60
- ResourceIdentifier is composed by:
61
-
62
- scope can a comma-separated list of: cluster, api, view|filter, restart
63
- cluster is the admin level, can do everything
64
- api can create api keys
65
- view or filter, can view logs
66
- restart, can restart pods or deployments
67
-
68
- for example, a user that can view and restart would have the scope 'view,restart'
69
-
70
- NOTE: group is the type and name of a group: 'replica', 'stateful' or 'daemon', a plus sign ('+'), and the name of the group, example: 'replica+rs1', 'stateful+mongo'
71
-
72
- the rest of fields are names (regex in fact) according to this rules:
73
- - it can be a direct name, like: 'mynamespace', 'your-replicaset', 'our-pod'...
74
- - it can be an '', indicating any resource of the scope is valid
75
- - it can be a comma-separated list of names, like: namespace 'dev,pre', or pod 'my-pod,our-pod,your-pod'
76
-
77
- full access is created by using cluster scope:
78
- scope: cluster
79
- namespace: ''
80
- set: ''
81
- pod: ''
82
- container: ''
83
-
84
- for example, an accessKey that gives access to view logs of namespaces production and staging would be something like
85
- scope: view
86
- namespace: ['production','staging']
87
- set: ''
88
- pod: ''
89
- container: ''
90
-
91
- access to restart any pod in 'development' namespace is like this:
92
- scope: restart
93
- namespace: 'development'
94
- set: ''
95
- pod: ''
96
- container: ''
97
-
98
- an accessKey that allows viewing logs of pod 'my-pod' in the whole cluster would be something like:
99
- scope: view
100
- namespace: ''
101
- set: ''
102
- pod: my-pod
103
- container: ''
104
-
105
- the names are infact regex, so you, for allowing a requestor to restart any pod of the accounting application in preproduction environment you would use this:
106
- scope: restart
107
- namespace: 'preproduction'
108
- set: ''
109
- pod: '^account-'
110
- container: ''
111
-
112
- */
113
-
114
- interface ResourceIdentifier {
115
- scope:string,
116
- namespace:string,
117
- set:string,
118
- pod:string,
119
- container:string
120
- }
121
-
122
- export { accessKeyBuild, accessKeyCreate, accessKeyDeserialize, accessKeySerialize, AccessKey, parseResource, ResourceIdentifier, buildResource };
package/src/ApiKey.ts DELETED
@@ -1,8 +0,0 @@
1
- import { AccessKey } from './AccessKey';
2
-
3
- export interface ApiKey {
4
- accessKey:AccessKey;
5
- description:string;
6
- expire:number;
7
- }
8
-
@@ -1,7 +0,0 @@
1
- export interface StreamMessage {
2
- namespace?:string,
3
- podName?:string,
4
- type:string,
5
- text:string,
6
- timestamp?:Date
7
- }
package/src/index.ts DELETED
@@ -1,18 +0,0 @@
1
- /*
2
- Copyright 2024 Julio Fernandez
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
- export * from './StreamMessage'
17
- export * from './ApiKey'
18
- export * from './AccessKey'
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "include": [
3
- "./src"
4
- ],
5
- "compilerOptions": {
6
- "outDir": "dist",
7
- "rootDir": "./src",
8
- "module": "commonjs",
9
- "target": "es6",
10
- "strict": true,
11
- "esModuleInterop": true,
12
- "declaration": true,
13
- }
14
- }