30
30
import static io .javaoperatorsdk .operator .sample .dependent .SecretDependentResource .MYSQL_SECRET_USERNAME ;
31
31
import static java .lang .String .format ;
32
32
33
- @ SchemaConfig (pollPeriod = 700 , host = "127.0.0.1" ,
33
+ @ SchemaConfig (pollPeriod = 400 , host = "127.0.0.1" ,
34
34
port = SchemaDependentResource .LOCAL_PORT ,
35
35
user = "root" , password = "password" ) // NOSONAR: password is only used locally, example only
36
36
@ Configured (by = SchemaConfig .class , with = ResourcePollerConfig .class ,
@@ -63,7 +63,9 @@ public void configureWith(ResourcePollerConfig config) {
63
63
64
64
@ Override
65
65
public Schema desired (MySQLSchema primary , Context <MySQLSchema > context ) {
66
- return new Schema (primary .getMetadata ().getName (), primary .getSpec ().getEncoding ());
66
+ var desired = new Schema (primary .getMetadata ().getName (), primary .getSpec ().getEncoding ());
67
+ log .debug ("Desired schema: {}" , desired );
68
+ return desired ;
67
69
}
68
70
69
71
@ Override
@@ -72,6 +74,7 @@ public Schema create(Schema target, MySQLSchema mySQLSchema, Context<MySQLSchema
72
74
Secret secret = context .getSecondaryResource (Secret .class ).orElseThrow ();
73
75
var username = decode (secret .getData ().get (MYSQL_SECRET_USERNAME ));
74
76
var password = decode (secret .getData ().get (MYSQL_SECRET_PASSWORD ));
77
+ log .debug ("Creating schema: {}" , target );
75
78
return SchemaService .createSchemaAndRelatedUser (
76
79
connection ,
77
80
target .getName (),
@@ -107,8 +110,10 @@ public static String decode(String value) {
107
110
@ Override
108
111
public Set <Schema > fetchResources (MySQLSchema primaryResource ) {
109
112
try (Connection connection = getConnection ()) {
110
- return SchemaService .getSchema (connection , primaryResource .getMetadata ().getName ())
113
+ var schema = SchemaService .getSchema (connection , primaryResource .getMetadata ().getName ())
111
114
.map (Set ::of ).orElseGet (Collections ::emptySet );
115
+ log .debug ("Fetched schema: {}" , schema );
116
+ return schema ;
112
117
} catch (SQLException e ) {
113
118
throw new RuntimeException ("Error while trying read Schema" , e );
114
119
}
0 commit comments