@leverege/build-tools 2.114.0-DEVOP-578.2 → 2.114.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.
@@ -29,13 +29,9 @@ export const exeCommand = new Command( 'exe' )
29
29
  .action( async ( target ) => {
30
30
  await overwhelmGate()
31
31
  const cfg = target ?
32
- TARGETS[target] :
32
+ ( TARGETS[target] ?? { ns: 'default', query: target, cmd: [ 'bash' ] } ) :
33
33
  { ns: 'default', query: null, cmd: [ 'bash' ] }
34
34
 
35
- if ( target && !cfg ) {
36
- errorExit( `Unknown target: ${target}\nValid: ${Object.keys( TARGETS ).join( ', ' )}` )
37
- }
38
-
39
35
  let pods = await listPods( cfg.ns )
40
36
  if ( cfg.query ) {
41
37
  pods = pods.filter( p => p.name.includes( cfg.query ) )
package/src/k8s/k8s.mjs CHANGED
@@ -8,7 +8,7 @@ import { scaleCommand } from './commands/scale.mjs'
8
8
  import { rollCommand } from './commands/roll.mjs'
9
9
  import { logCommand } from './commands/log.mjs'
10
10
  import { completionCommand } from './commands/completion.mjs'
11
- import { hibernateCommand, wakeCommand } from './commands/cryo.mjs'
11
+ import { cryoCommand } from './commands/cryo.mjs'
12
12
 
13
13
  $.verbose = false
14
14
 
@@ -21,6 +21,5 @@ program
21
21
  .addCommand( rollCommand )
22
22
  .addCommand( logCommand )
23
23
  .addCommand( completionCommand )
24
- .addCommand( hibernateCommand )
25
- .addCommand( wakeCommand )
24
+ .addCommand( cryoCommand )
26
25
  .parse()
@@ -1,26 +1,57 @@
1
1
  import { $ } from 'zx'
2
2
 
3
- export async function listPods(namespace) {
3
+ export async function listPods( namespace ) {
4
4
  const result = namespace
5
5
  ? await $`kubectl get pods -n ${namespace} --no-headers`
6
6
  : await $`kubectl get pods --all-namespaces --no-headers`
7
7
 
8
- return result.stdout.trim().split('\n').filter(Boolean).map(line => {
9
- const cols = line.trim().split(/\s+/)
10
- if (namespace) {
11
- const [name, , status] = cols
8
+ return result.stdout.trim().split( '\n' ).filter( Boolean ).map( line => {
9
+ const cols = line.trim().split( /\s+/ )
10
+ if ( namespace ) {
11
+ const [ name, , status ] = cols
12
12
  return { namespace, name, status }
13
13
  }
14
- const [ns, name, , status] = cols
14
+ const [ ns, name, , status ] = cols
15
15
  return { namespace: ns, name, status }
16
- })
16
+ } )
17
17
  }
18
18
 
19
- export async function listDeployments(namespace) {
19
+ export async function listDeployments( namespace ) {
20
20
  const result = namespace
21
21
  ? await $`kubectl get deploy -n ${namespace} --no-headers -o name`
22
22
  : await $`kubectl get deploy --all-namespaces --no-headers -o name`
23
23
 
24
- return result.stdout.trim().split('\n').filter(Boolean)
25
- .map(n => n.replace(/^deployment\.apps\//, ''))
24
+ return result.stdout.trim().split( '\n' ).filter( Boolean )
25
+ .map( n => n.replace( /^deployment\.apps\//, '' ) )
26
+ }
27
+
28
+ export async function namespaceExists( namespace ) {
29
+ try {
30
+ await $`kubectl get namespace ${namespace} --no-headers -o name`
31
+ return true
32
+ } catch {
33
+ return false
34
+ }
35
+ }
36
+
37
+ export async function listStatefulSets( namespace ) {
38
+ try {
39
+ const result = namespace
40
+ ? await $`kubectl get statefulset -n ${namespace} --no-headers -o name`
41
+ : await $`kubectl get statefulset --all-namespaces --no-headers -o name`
42
+ return result.stdout.trim().split( '\n' ).filter( Boolean )
43
+ .map( n => n.replace( /^statefulset\.apps\//, '' ) )
44
+ } catch {
45
+ return []
46
+ }
47
+ }
48
+
49
+ export async function getReplicaCount( kind, name, namespace ) {
50
+ try {
51
+ const result = await $`kubectl get ${kind} ${name} -n ${namespace} -o jsonpath={.spec.replicas}`
52
+ const n = parseInt( result.stdout.trim(), 10 )
53
+ return isNaN( n ) ? 1 : n
54
+ } catch {
55
+ return 1
56
+ }
26
57
  }
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "roles" : [
3
3
  "leveregePubSub",
4
- "leveregeSecretsViewer"
4
+ "leveregeSecretsViewer",
5
+ "leveregeVertexEndpointUser"
5
6
  ]
6
7
  }