This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +45
-6
lines changed
Expand file tree Collapse file tree 6 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ export class Manager {
99 constructor ( options ?: ManagerOptions ) ;
1010 client : KubernetesObjectApi ;
1111 kubeconfig : KubeConfig ;
12- started : boolean ;
1312 /**
1413 * add() causes the Manager to manage the provided controller.
1514 * @param {Controller } controller The controller to manage.
@@ -26,6 +25,11 @@ export class Manager {
2625 * @returns {Promise<void> }
2726 */
2827 start ( context ?: Context ) : Promise < void > ;
28+ /**
29+ * A boolean indicating if the manager was started.
30+ * @type {boolean }
31+ */
32+ get started ( ) : boolean ;
2933 #private;
3034}
3135declare namespace _default {
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export class Manager {
4747 #controllers;
4848 /** @type LeaderElector */
4949 #leaderElector;
50+ /** @type boolean */
51+ #started;
5052 /** @type Server */
5153 #webhookServer;
5254
@@ -166,7 +168,7 @@ export class Manager {
166168 this . client = client ;
167169 this . #controllers = [ ] ;
168170 this . kubeconfig = kubeconfig ;
169- this . started = false ;
171+ this . # started = false ;
170172 this . #webhookServer = null ;
171173 }
172174
@@ -196,12 +198,10 @@ export class Manager {
196198 * @returns {Promise<void> }
197199 */
198200 async start ( context = Context . create ( ) ) {
199- if ( this . started ) {
201+ if ( this . # started) {
200202 throw new Error ( 'manager already started' ) ;
201203 }
202204
203- this . started = true ;
204-
205205 // Webhooks can start before leader election.
206206 if ( this . #webhookServer !== null ) {
207207 await this . #webhookServer. start ( context . child ( ) ) ;
@@ -212,6 +212,16 @@ export class Manager {
212212 } else {
213213 this . #startControllers( context ) ;
214214 }
215+
216+ this . #started = true ;
217+ }
218+
219+ /**
220+ * A boolean indicating if the manager was started.
221+ * @type {boolean }
222+ */
223+ get started ( ) {
224+ return this . #started;
215225 }
216226
217227 /**
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ export class Source {
2525 * @returns {Promise<void> }
2626 */
2727 start ( context : Context , queue : Queue < Request > ) : Promise < void > ;
28+ /**
29+ * A boolean indicating if the source was started.
30+ * @type {boolean }
31+ */
32+ get started ( ) : boolean ;
33+ #private;
2834}
2935declare namespace _default {
3036 export { Source } ;
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ import { Request } from './reconcile.js';
1515 * Source provides event streams to hook up to Controllers.
1616 */
1717export class Source {
18+ /** @type boolean */
19+ #started;
20+
1821 /**
1922 * Construct a Source.
2023 * @param {KubeConfig } kubeconfig - Kubeconfig to use.
@@ -44,6 +47,7 @@ export class Source {
4447 this . kind = kind ;
4548 this . apiVersion = apiVersion ;
4649 this . informer = null ;
50+ this . #started = false ;
4751 }
4852
4953 /**
@@ -61,6 +65,10 @@ export class Source {
6165 throw new TypeError ( 'queue must be a Queue instance' ) ;
6266 }
6367
68+ if ( this . #started) {
69+ throw new Error ( 'source already started' ) ;
70+ }
71+
6472 let apiVersion = this . apiVersion ;
6573
6674 if ( apiVersion !== 'v1' && apiVersion . split ( '/' ) . length === 1 ) {
@@ -119,7 +127,16 @@ export class Source {
119127 queue . enqueue ( k8sObjectToRequest ( resource ) ) ;
120128 } ) ;
121129
122- return this . informer . start ( ) ;
130+ await this . informer . start ( ) ;
131+ this . #started = true ;
132+ }
133+
134+ /**
135+ * A boolean indicating if the source was started.
136+ * @type {boolean }
137+ */
138+ get started ( ) {
139+ return this . #started;
123140 }
124141}
125142
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ suite('Manager', () => {
152152 const manager = new Manager ( options ) ;
153153 manager . start ( ctx ) ;
154154
155+ assert . strictEqual ( manager . started , true ) ;
155156 await assert . rejects ( ( ) => {
156157 return manager . start ( ctx ) ;
157158 } , / m a n a g e r a l r e a d y s t a r t e d / ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ suite('Source', () => {
1616 assert . strictEqual ( source . client , o . client ) ;
1717 assert . strictEqual ( source . kind , o . kind ) ;
1818 assert . strictEqual ( source . apiVersion , o . apiVersion ) ;
19+ assert . strictEqual ( source . started , false ) ;
1920 } ) ;
2021
2122 test ( 'kubeconfig argument must be a KubeConfig instance' , ( ) => {
You can’t perform that action at this time.
0 commit comments