@@ -100,7 +100,7 @@ type failingBaseComponent struct {
100
100
component.BaseComponent [struct {}]
101
101
}
102
102
103
- func (f * failingBaseComponent ) Setup (container component.Container , config component.Config ) error {
103
+ func (f * failingBaseComponent ) Setup (container component.Container , config * component.Config , rewrite bool ) error {
104
104
return errors .New ("setup failed" )
105
105
}
106
106
@@ -136,10 +136,6 @@ type complexRefs struct {
136
136
}
137
137
}
138
138
139
- type componentWithComplexRefs struct {
140
- component.BaseComponentWithRefs [struct {}, complexRefs ]
141
- }
142
-
143
139
type failingResolver struct {
144
140
component.Reference [* mockComponent ]
145
141
}
@@ -265,7 +261,7 @@ func TestBaseComponentSetup(t *testing.T) {
265
261
mc := & mockComponent {}
266
262
container := newMockContainer ()
267
263
268
- err := mc .Setup (container , tt .config )
264
+ err := mc .Setup (container , & tt .config , false )
269
265
270
266
if (err != nil ) != tt .wantErr {
271
267
t .Errorf ("Setup() error = %v, wantErr %v" , err , tt .wantErr )
@@ -384,7 +380,7 @@ func TestGroup(t *testing.T) {
384
380
mc := & mockComponent {}
385
381
uuid := fmt .Sprintf ("test-uuid-%d" , i )
386
382
container := newMockContainer () // Create a new container for each component
387
- err := mc .Setup (container , component.Config {Name : fmt .Sprintf ("TestComponent-%d" , i ), UUID : uuid })
383
+ err := mc .Setup (container , & component.Config {Name : fmt .Sprintf ("TestComponent-%d" , i ), UUID : uuid }, false )
388
384
if err != nil {
389
385
t .Fatalf ("Failed to setup mockComponent: %v" , err )
390
386
}
@@ -415,7 +411,7 @@ func TestGroup(t *testing.T) {
415
411
t .Run ("Init failure" , func (t * testing.T ) {
416
412
group := component .NewGroup ()
417
413
failingComponent := & mockComponent {initError : true }
418
- failingComponent .Setup (newMockContainer (), component.Config {Name : "FailingComponent" , UUID : "failing-uuid" })
414
+ failingComponent .Setup (newMockContainer (), & component.Config {Name : "FailingComponent" , UUID : "failing-uuid" }, false )
419
415
group .AddComponent ("failing-component" , failingComponent )
420
416
421
417
err := group .Init (context .Background ())
@@ -427,7 +423,7 @@ func TestGroup(t *testing.T) {
427
423
t .Run ("Start failure" , func (t * testing.T ) {
428
424
group := component .NewGroup ()
429
425
failingComponent := & mockComponent {startError : true }
430
- failingComponent .Setup (newMockContainer (), component.Config {Name : "FailingComponent" , UUID : "failing-uuid" })
426
+ failingComponent .Setup (newMockContainer (), & component.Config {Name : "FailingComponent" , UUID : "failing-uuid" }, false )
431
427
group .AddComponent ("failing-component" , failingComponent )
432
428
433
429
if err := group .Init (context .Background ()); err != nil {
@@ -441,7 +437,7 @@ func TestGroup(t *testing.T) {
441
437
t .Run ("Shutdown failure" , func (t * testing.T ) {
442
438
group := component .NewGroup ()
443
439
failingComponent := & mockComponent {shutdownError : true }
444
- failingComponent .Setup (newMockContainer (), component.Config {Name : "FailingComponent" , UUID : "failing-uuid" })
440
+ failingComponent .Setup (newMockContainer (), & component.Config {Name : "FailingComponent" , UUID : "failing-uuid" }, false )
445
441
group .AddComponent ("failing-component" , failingComponent )
446
442
447
443
if err := group .Init (context .Background ()); err != nil {
@@ -458,7 +454,7 @@ func TestGroup(t *testing.T) {
458
454
t .Run ("Uninit failure" , func (t * testing.T ) {
459
455
group := component .NewGroup ()
460
456
failingComponent := & mockComponent {uninitError : true }
461
- failingComponent .Setup (newMockContainer (), component.Config {Name : "FailingComponent" , UUID : "failing-uuid" })
457
+ failingComponent .Setup (newMockContainer (), & component.Config {Name : "FailingComponent" , UUID : "failing-uuid" }, false )
462
458
group .AddComponent ("failing-component" , failingComponent )
463
459
464
460
if err := group .Init (context .Background ()); err != nil {
@@ -619,7 +615,7 @@ func ExampleBaseComponent() {
619
615
Options : types .NewRawObject (`{"Value":"example"}` ),
620
616
}
621
617
622
- err := mc .Setup (container , config )
618
+ err := mc .Setup (container , & config , false )
623
619
if err != nil {
624
620
fmt .Printf ("Failed to setup component: %v\n " , err )
625
621
return
@@ -643,7 +639,7 @@ func ExampleGroup() {
643
639
mc := & mockComponent {}
644
640
uuid := fmt .Sprintf ("example-uuid-%d" , i )
645
641
container := newMockContainer ()
646
- _ = mc .Setup (container , component.Config {Name : fmt .Sprintf ("ExampleComponent-%d" , i ), UUID : uuid })
642
+ _ = mc .Setup (container , & component.Config {Name : fmt .Sprintf ("ExampleComponent-%d" , i ), UUID : uuid }, false )
647
643
group .AddComponent (uuid , mc )
648
644
}
649
645
@@ -690,7 +686,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
690
686
Refs : types .NewRawObject (`{"Ref1":"ref1","Ref2":"ref2"}` ),
691
687
}
692
688
693
- err := tc .Setup (container , config )
689
+ err := tc .Setup (container , & config , false )
694
690
if err != nil {
695
691
t .Fatalf ("Failed to setup component: %v" , err )
696
692
}
@@ -710,7 +706,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
710
706
UUID : "test-uuid" ,
711
707
Refs : types .NewRawObject (`{invalid json` ),
712
708
}
713
- err := tc .Setup (container , config )
709
+ err := tc .Setup (container , & config , false )
714
710
if err == nil || ! strings .Contains (err .Error (), "failed to unmarshal refs" ) {
715
711
t .Errorf ("Expected error for invalid refs JSON, got: %v" , err )
716
712
}
@@ -726,7 +722,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
726
722
UUID : "test-uuid" ,
727
723
Refs : types .NewRawObject (`{"Ref1":"non-existent-uuid"}` ),
728
724
}
729
- err := tc .Setup (mockContainer , config )
725
+ err := tc .Setup (mockContainer , & config , false )
730
726
if err == nil || ! strings .Contains (err .Error (), "failed to resolve reference" ) {
731
727
t .Errorf ("Expected error for failed reference resolution, got: %v" , err )
732
728
}
@@ -757,7 +753,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
757
753
Refs : types .NewRawObject (`{"Ref1":"ref1","NestedStruct":{"Ref2":"ref2"}}` ),
758
754
}
759
755
760
- err := nc .Setup (container , config )
756
+ err := nc .Setup (container , & config , false )
761
757
if err != nil {
762
758
t .Fatalf ("Failed to setup nested component: %v" , err )
763
759
}
@@ -794,7 +790,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
794
790
Refs : types .NewRawObject (`{"Ref1":"ref1","Ref2":null,"Ref3":{},"Ref4":"not-a-ref"}` ),
795
791
}
796
792
797
- err := mixedComp .Setup (container , config )
793
+ err := mixedComp .Setup (container , & config , false )
798
794
if err != nil {
799
795
t .Fatalf ("Failed to setup mixed component: %v" , err )
800
796
}
@@ -816,7 +812,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
816
812
Name : "FailingComponent" ,
817
813
UUID : "failing-uuid" ,
818
814
}
819
- err := fc .Setup (newMockContainer (), config )
815
+ err := fc .Setup (newMockContainer (), & config , false )
820
816
if err == nil || err .Error () != "setup failed" {
821
817
t .Errorf ("Expected setup failed error, got: %v" , err )
822
818
}
@@ -829,7 +825,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
829
825
UUID : "test-uuid" ,
830
826
Refs : types .NewRawObject (`{invalid json` ),
831
827
}
832
- err := tc .Setup (newMockContainer (), config )
828
+ err := tc .Setup (newMockContainer (), & config , false )
833
829
if err == nil || ! strings .Contains (err .Error (), "failed to unmarshal refs" ) {
834
830
t .Errorf ("Expected error for invalid refs JSON, got: %v" , err )
835
831
}
@@ -842,7 +838,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
842
838
UUID : "non-struct-uuid" ,
843
839
Refs : types .NewRawObject (`"string ref"` ),
844
840
}
845
- err := cnsr .Setup (newMockContainer (), config )
841
+ err := cnsr .Setup (newMockContainer (), & config , false )
846
842
if err != nil {
847
843
t .Errorf ("Expected no error for non-struct refs, got: %v" , err )
848
844
}
@@ -872,7 +868,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
872
868
}` ),
873
869
}
874
870
875
- err := cdr .Setup (container , config )
871
+ err := cdr .Setup (container , & config , false )
876
872
if err != nil {
877
873
t .Fatalf ("Failed to setup component with deep refs: %v" , err )
878
874
}
@@ -904,7 +900,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
904
900
Refs : types .NewRawObject (`{"FailingRef": "some-uuid"}` ),
905
901
}
906
902
907
- err := cfr .Setup (newMockContainer (), config )
903
+ err := cfr .Setup (newMockContainer (), & config , false )
908
904
if err == nil || ! strings .Contains (err .Error (), "failed to resolve reference" ) {
909
905
t .Errorf ("Expected error for failing resolver, got: %v" , err )
910
906
}
@@ -921,7 +917,7 @@ func TestComponentLifecycle(t *testing.T) {
921
917
UUID : "lifecycle-uuid" ,
922
918
}
923
919
924
- err := mc .Setup (container , config )
920
+ err := mc .Setup (container , & config , false )
925
921
if err != nil {
926
922
t .Fatalf ("Failed to setup component: %v" , err )
927
923
}
@@ -988,7 +984,7 @@ func TestComponentErrorHandling(t *testing.T) {
988
984
UUID : "error-uuid" ,
989
985
}
990
986
991
- err := errorComponent .Setup (container , config )
987
+ err := errorComponent .Setup (container , & config , false )
992
988
if err != nil {
993
989
t .Fatalf ("Failed to setup component: %v" , err )
994
990
}
@@ -1022,7 +1018,7 @@ func BenchmarkComponentLifecycle(b *testing.B) {
1022
1018
b .ResetTimer ()
1023
1019
for i := 0 ; i < b .N ; i ++ {
1024
1020
mc := & mockComponent {}
1025
- _ = mc .Setup (container , config )
1021
+ _ = mc .Setup (container , & config , false )
1026
1022
_ = mc .Init (ctx )
1027
1023
_ = mc .Start (ctx )
1028
1024
_ = mc .Shutdown (ctx )
0 commit comments