berget 0.1.0 → 1.0.0
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/dist/index.js +62 -30
- package/dist/src/constants/command-structure.js +150 -0
- package/dist/src/services/api-key-service.js +34 -5
- package/dist/src/services/auth-service.js +41 -3
- package/dist/src/services/cluster-service.js +37 -2
- package/dist/src/services/collaborator-service.js +21 -4
- package/dist/src/services/flux-service.js +21 -4
- package/dist/src/services/helm-service.js +20 -3
- package/dist/src/services/kubectl-service.js +26 -5
- package/index.ts +67 -30
- package/package.json +1 -1
- package/src/constants/command-structure.ts +168 -0
- package/src/services/api-key-service.ts +36 -5
- package/src/services/auth-service.ts +20 -3
- package/src/services/cluster-service.ts +37 -2
- package/src/services/collaborator-service.ts +23 -4
- package/src/services/flux-service.ts +23 -4
- package/src/services/helm-service.ts +22 -3
- package/src/services/kubectl-service.ts +28 -5
|
@@ -4,13 +4,24 @@ import {
|
|
|
4
4
|
clearAuthToken,
|
|
5
5
|
apiClient,
|
|
6
6
|
} from '../client'
|
|
7
|
-
import
|
|
7
|
+
// We'll use dynamic import for 'open' to support ESM modules in CommonJS
|
|
8
8
|
import chalk from 'chalk'
|
|
9
9
|
import { handleError } from '../utils/error-handler'
|
|
10
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Service for authentication operations
|
|
14
|
+
* Command group: auth
|
|
15
|
+
*/
|
|
11
16
|
export class AuthService {
|
|
12
17
|
private static instance: AuthService
|
|
13
18
|
private client = createAuthenticatedClient()
|
|
19
|
+
|
|
20
|
+
// Command group name for this service
|
|
21
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.AUTH
|
|
22
|
+
|
|
23
|
+
// Subcommands for this service
|
|
24
|
+
public static readonly COMMANDS = SUBCOMMANDS.AUTH
|
|
14
25
|
|
|
15
26
|
private constructor() {}
|
|
16
27
|
|
|
@@ -60,7 +71,9 @@ export class AuthService {
|
|
|
60
71
|
// Try to open browser automatically
|
|
61
72
|
try {
|
|
62
73
|
if (deviceData.verification_url) {
|
|
63
|
-
|
|
74
|
+
// Use dynamic import for the 'open' package
|
|
75
|
+
const open = await import('open').then(m => m.default);
|
|
76
|
+
await open(deviceData.verification_url);
|
|
64
77
|
console.log(
|
|
65
78
|
chalk.dim(
|
|
66
79
|
"Browser opened automatically. If it didn't open, please use the URL above."
|
|
@@ -193,7 +206,11 @@ export class AuthService {
|
|
|
193
206
|
}
|
|
194
207
|
}
|
|
195
208
|
|
|
196
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Get current user profile
|
|
211
|
+
* Command: berget auth whoami
|
|
212
|
+
*/
|
|
213
|
+
public async whoami() {
|
|
197
214
|
try {
|
|
198
215
|
const { data, error } = await this.client.GET('/v1/users/me')
|
|
199
216
|
if (error) throw new Error(JSON.stringify(error))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAuthenticatedClient } from '../client'
|
|
2
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
2
3
|
|
|
3
4
|
export interface Cluster {
|
|
4
5
|
id: string
|
|
@@ -8,9 +9,19 @@ export interface Cluster {
|
|
|
8
9
|
created: string
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Service for managing Kubernetes clusters
|
|
14
|
+
* Command group: clusters
|
|
15
|
+
*/
|
|
11
16
|
export class ClusterService {
|
|
12
17
|
private static instance: ClusterService
|
|
13
18
|
private client = createAuthenticatedClient()
|
|
19
|
+
|
|
20
|
+
// Command group name for this service
|
|
21
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.CLUSTERS
|
|
22
|
+
|
|
23
|
+
// Subcommands for this service
|
|
24
|
+
public static readonly COMMANDS = SUBCOMMANDS.CLUSTERS
|
|
14
25
|
|
|
15
26
|
private constructor() {}
|
|
16
27
|
|
|
@@ -21,7 +32,11 @@ export class ClusterService {
|
|
|
21
32
|
return ClusterService.instance
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Get resource usage for a cluster
|
|
37
|
+
* Command: berget clusters get-usage
|
|
38
|
+
*/
|
|
39
|
+
public async getUsage(clusterId: string): Promise<any> {
|
|
25
40
|
try {
|
|
26
41
|
const { data, error } = await this.client.GET(
|
|
27
42
|
'/v1/clusters/{clusterId}/usage',
|
|
@@ -37,7 +52,11 @@ export class ClusterService {
|
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
/**
|
|
56
|
+
* List all clusters
|
|
57
|
+
* Command: berget clusters list
|
|
58
|
+
*/
|
|
59
|
+
public async list(): Promise<Cluster[]> {
|
|
41
60
|
try {
|
|
42
61
|
const { data, error } = await this.client.GET('/v1/clusters')
|
|
43
62
|
if (error) throw new Error(JSON.stringify(error))
|
|
@@ -47,4 +66,20 @@ export class ClusterService {
|
|
|
47
66
|
throw error
|
|
48
67
|
}
|
|
49
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get detailed information about a cluster
|
|
72
|
+
* Command: berget clusters describe
|
|
73
|
+
*/
|
|
74
|
+
public async describe(clusterId: string): Promise<Cluster | null> {
|
|
75
|
+
try {
|
|
76
|
+
// This is a placeholder since the API doesn't have a specific endpoint
|
|
77
|
+
// In a real implementation, this would call a specific endpoint
|
|
78
|
+
const clusters = await this.list()
|
|
79
|
+
return clusters.find(cluster => cluster.id === clusterId) || null
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('Failed to describe cluster:', error)
|
|
82
|
+
throw error
|
|
83
|
+
}
|
|
84
|
+
}
|
|
50
85
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAuthenticatedClient } from '../client'
|
|
2
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
2
3
|
|
|
3
4
|
export interface Collaborator {
|
|
4
5
|
username: string
|
|
@@ -6,9 +7,19 @@ export interface Collaborator {
|
|
|
6
7
|
status: string
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Service for managing collaborators
|
|
12
|
+
* Command group: users
|
|
13
|
+
*/
|
|
9
14
|
export class CollaboratorService {
|
|
10
15
|
private static instance: CollaboratorService
|
|
11
16
|
private client = createAuthenticatedClient()
|
|
17
|
+
|
|
18
|
+
// Command group name for this service
|
|
19
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.USERS
|
|
20
|
+
|
|
21
|
+
// Subcommands for this service
|
|
22
|
+
public static readonly COMMANDS = SUBCOMMANDS.USERS
|
|
12
23
|
|
|
13
24
|
private constructor() {}
|
|
14
25
|
|
|
@@ -19,16 +30,24 @@ export class CollaboratorService {
|
|
|
19
30
|
return CollaboratorService.instance
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Invite a new collaborator
|
|
35
|
+
* Command: berget users invite
|
|
36
|
+
* This endpoint is not available in the API
|
|
37
|
+
*/
|
|
38
|
+
public async invite(
|
|
24
39
|
clusterId: string,
|
|
25
40
|
githubUsername: string
|
|
26
41
|
): Promise<Collaborator[]> {
|
|
27
42
|
throw new Error('This functionality is not available in the API')
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
/**
|
|
46
|
+
* List all collaborators
|
|
47
|
+
* Command: berget users list
|
|
48
|
+
* This endpoint is not available in the API
|
|
49
|
+
*/
|
|
50
|
+
public async list(clusterId: string): Promise<Collaborator[]> {
|
|
32
51
|
throw new Error('This functionality is not available in the API')
|
|
33
52
|
}
|
|
34
53
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAuthenticatedClient } from '../client'
|
|
2
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
2
3
|
|
|
3
4
|
export interface FluxInstallOptions {
|
|
4
5
|
cluster: string
|
|
@@ -12,9 +13,19 @@ export interface FluxBootstrapOptions {
|
|
|
12
13
|
personal?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Service for managing Flux CD
|
|
18
|
+
* Command group: flux
|
|
19
|
+
*/
|
|
15
20
|
export class FluxService {
|
|
16
21
|
private static instance: FluxService
|
|
17
22
|
private client = createAuthenticatedClient()
|
|
23
|
+
|
|
24
|
+
// Command group name for this service
|
|
25
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.FLUX
|
|
26
|
+
|
|
27
|
+
// Subcommands for this service
|
|
28
|
+
public static readonly COMMANDS = SUBCOMMANDS.FLUX
|
|
18
29
|
|
|
19
30
|
private constructor() {}
|
|
20
31
|
|
|
@@ -25,13 +36,21 @@ export class FluxService {
|
|
|
25
36
|
return FluxService.instance
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Install Flux CD
|
|
41
|
+
* Command: berget flux install
|
|
42
|
+
* This endpoint is not available in the API
|
|
43
|
+
*/
|
|
44
|
+
public async install(options: FluxInstallOptions): Promise<boolean> {
|
|
30
45
|
throw new Error('This functionality is not available in the API')
|
|
31
46
|
}
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Bootstrap Flux CD
|
|
50
|
+
* Command: berget flux bootstrap
|
|
51
|
+
* This endpoint is not available in the API
|
|
52
|
+
*/
|
|
53
|
+
public async bootstrap(options: FluxBootstrapOptions): Promise<boolean> {
|
|
35
54
|
throw new Error('This functionality is not available in the API')
|
|
36
55
|
}
|
|
37
56
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAuthenticatedClient } from '../client'
|
|
2
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
2
3
|
|
|
3
4
|
export interface HelmRepoAddOptions {
|
|
4
5
|
name: string
|
|
@@ -12,9 +13,19 @@ export interface HelmInstallOptions {
|
|
|
12
13
|
values?: Record<string, string>
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Service for managing Helm charts
|
|
18
|
+
* Command group: helm
|
|
19
|
+
*/
|
|
15
20
|
export class HelmService {
|
|
16
21
|
private static instance: HelmService
|
|
17
22
|
private client = createAuthenticatedClient()
|
|
23
|
+
|
|
24
|
+
// Command group name for this service
|
|
25
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.HELM
|
|
26
|
+
|
|
27
|
+
// Subcommands for this service
|
|
28
|
+
public static readonly COMMANDS = SUBCOMMANDS.HELM
|
|
18
29
|
|
|
19
30
|
private constructor() {}
|
|
20
31
|
|
|
@@ -25,13 +36,21 @@ export class HelmService {
|
|
|
25
36
|
return HelmService.instance
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Add a Helm repository
|
|
41
|
+
* Command: berget helm add-repo
|
|
42
|
+
* This endpoint is not available in the API
|
|
43
|
+
*/
|
|
29
44
|
public async addRepo(options: HelmRepoAddOptions): Promise<boolean> {
|
|
30
45
|
throw new Error('This functionality is not available in the API')
|
|
31
46
|
}
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Install a Helm chart
|
|
50
|
+
* Command: berget helm install
|
|
51
|
+
* This endpoint is not available in the API
|
|
52
|
+
*/
|
|
53
|
+
public async install(options: HelmInstallOptions): Promise<any> {
|
|
35
54
|
throw new Error('This functionality is not available in the API')
|
|
36
55
|
}
|
|
37
56
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { createAuthenticatedClient } from '../client'
|
|
2
|
+
import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Service for managing Kubernetes resources
|
|
6
|
+
* Command group: kubectl
|
|
7
|
+
*/
|
|
3
8
|
export class KubectlService {
|
|
4
9
|
private static instance: KubectlService
|
|
5
10
|
private client = createAuthenticatedClient()
|
|
11
|
+
|
|
12
|
+
// Command group name for this service
|
|
13
|
+
public static readonly COMMAND_GROUP = COMMAND_GROUPS.KUBECTL
|
|
14
|
+
|
|
15
|
+
// Subcommands for this service
|
|
16
|
+
public static readonly COMMANDS = SUBCOMMANDS.KUBECTL
|
|
6
17
|
|
|
7
18
|
private constructor() {}
|
|
8
19
|
|
|
@@ -13,18 +24,30 @@ export class KubectlService {
|
|
|
13
24
|
return KubectlService.instance
|
|
14
25
|
}
|
|
15
26
|
|
|
16
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Create a Kubernetes namespace
|
|
29
|
+
* Command: berget kubectl create-namespace
|
|
30
|
+
* This endpoint is not available in the API
|
|
31
|
+
*/
|
|
17
32
|
public async createNamespace(name: string): Promise<boolean> {
|
|
18
33
|
throw new Error('This functionality is not available in the API')
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Apply a Kubernetes configuration
|
|
38
|
+
* Command: berget kubectl apply
|
|
39
|
+
* This endpoint is not available in the API
|
|
40
|
+
*/
|
|
41
|
+
public async apply(filename: string): Promise<boolean> {
|
|
23
42
|
throw new Error('This functionality is not available in the API')
|
|
24
43
|
}
|
|
25
44
|
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Get Kubernetes resources
|
|
47
|
+
* Command: berget kubectl get
|
|
48
|
+
* This endpoint is not available in the API
|
|
49
|
+
*/
|
|
50
|
+
public async get(
|
|
28
51
|
resource: string,
|
|
29
52
|
namespace?: string
|
|
30
53
|
): Promise<any[]> {
|