11
11
import org .apache .commons .lang3 .StringUtils ;
12
12
import org .slf4j .Logger ;
13
13
import org .slf4j .LoggerFactory ;
14
- import org .springframework .beans .factory .annotation .Autowired ;
15
14
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
16
15
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
17
16
import org .springframework .context .annotation .Bean ;
21
20
22
21
@ Configuration
23
22
@ EnableConfigurationProperties ({OperatorProperties .class , RetryProperties .class })
24
- @ ConditionalOnMissingBean (Operator .class )
25
23
public class OperatorAutoConfiguration {
26
24
private static final Logger log = LoggerFactory .getLogger (OperatorAutoConfiguration .class );
27
25
28
- @ Autowired
29
- private RetryProperties retryProperties ;
30
-
31
- @ Autowired
32
- private OperatorProperties operatorProperties ;
33
-
34
- @ Autowired
35
- private List <ResourceController > resourceControllers ;
36
-
37
26
@ Bean
38
27
@ ConditionalOnMissingBean
39
- public KubernetesClient kubernetesClient () {
28
+ public KubernetesClient kubernetesClient (OperatorProperties operatorProperties ) {
40
29
ConfigBuilder config = new ConfigBuilder ();
41
30
config .withTrustCerts (operatorProperties .isTrustSelfSignedCertificates ());
42
31
if (StringUtils .isNotBlank (operatorProperties .getUsername ())) {
@@ -53,15 +42,16 @@ public KubernetesClient kubernetesClient() {
53
42
}
54
43
55
44
@ Bean
56
- public Operator operator (KubernetesClient kubernetesClient , Retry retry ) {
45
+ @ ConditionalOnMissingBean (Operator .class )
46
+ public Operator operator (KubernetesClient kubernetesClient , Retry retry , List <ResourceController > resourceControllers ) {
57
47
Operator operator = new Operator (kubernetesClient );
58
48
resourceControllers .forEach (r -> operator .registerControllerForAllNamespaces (r , retry ));
59
49
return operator ;
60
50
}
61
51
62
52
@ Bean
63
53
@ ConditionalOnMissingBean
64
- public Retry retry () {
54
+ public Retry retry (RetryProperties retryProperties ) {
65
55
GenericRetry retry = new GenericRetry ();
66
56
if (retryProperties .getInitialInterval () != null ) {
67
57
retry .setInitialInterval (retryProperties .getInitialInterval ());
0 commit comments