-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add leader election configuration (#60)
- Loading branch information
1 parent
9cb471d
commit a2e81fb
Showing
8 changed files
with
137 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
docs/modules/onecx-permission-operator/pages/onecx-permission-operator.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
:summaryTableId: onecx-permission-operator | ||
[.configuration-legend] | ||
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime | ||
[.configuration-reference.searchable, cols="80,.^10,.^10"] | ||
|=== | ||
|
||
h|[.header-title]##Configuration property## | ||
h|Type | ||
h|Default | ||
|
||
a| [[onecx-permission-operator_onecx-permission-operator-leader-election-lease-name]] [.property-path]##link:#onecx-permission-operator_onecx-permission-operator-leader-election-lease-name[`onecx.permission.operator.leader-election.lease-name`]## | ||
|
||
[.description] | ||
-- | ||
Lease name | ||
|
||
|
||
ifdef::add-copy-button-to-env-var[] | ||
Environment variable: env_var_with_copy_button:+++ONECX_PERMISSION_OPERATOR_LEADER_ELECTION_LEASE_NAME+++[] | ||
endif::add-copy-button-to-env-var[] | ||
ifndef::add-copy-button-to-env-var[] | ||
Environment variable: `+++ONECX_PERMISSION_OPERATOR_LEADER_ELECTION_LEASE_NAME+++` | ||
endif::add-copy-button-to-env-var[] | ||
-- | ||
|string | ||
|`onecx-permission-operator-lease` | ||
|
||
|=== | ||
|
||
|
||
:!summaryTableId: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/org/tkit/onecx/permission/operator/LeaderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.tkit.onecx.permission.operator; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration; | ||
|
||
@Singleton | ||
public class LeaderConfiguration extends LeaderElectionConfiguration { | ||
|
||
public LeaderConfiguration(PermissionConfig config) { | ||
super(config.leaderElectionConfig().leaseName()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/tkit/onecx/permission/operator/PermissionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.tkit.onecx.permission.operator; | ||
|
||
import io.quarkus.runtime.annotations.ConfigDocFilename; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.quarkus.runtime.annotations.StaticInitSafe; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
import io.smallrye.config.WithName; | ||
|
||
@StaticInitSafe | ||
@ConfigDocFilename("onecx-permission-operator.adoc") | ||
@ConfigMapping(prefix = "onecx.permission.operator") | ||
@ConfigRoot(phase = ConfigPhase.RUN_TIME) | ||
public interface PermissionConfig { | ||
|
||
/** | ||
* Leader election configuration | ||
*/ | ||
@WithName("leader-election") | ||
LeaderElectionConfig leaderElectionConfig(); | ||
|
||
/** | ||
* Leader election config | ||
*/ | ||
interface LeaderElectionConfig { | ||
|
||
/** | ||
* Lease name | ||
*/ | ||
@WithName("lease-name") | ||
@WithDefault("onecx-permission-operator-lease") | ||
String leaseName(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/org/tkit/onecx/permission/operator/LeaderConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.tkit.onecx.permission.operator; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.tkit.onecx.permission.test.AbstractTest; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class LeaderConfigurationTest extends AbstractTest { | ||
|
||
@Inject | ||
PermissionConfig dataConfig; | ||
|
||
@Inject | ||
LeaderConfiguration leaderConfiguration; | ||
|
||
@Test | ||
void testLeaderConfiguration() { | ||
assertThat(dataConfig).isNotNull(); | ||
assertThat(dataConfig.leaderElectionConfig()).isNotNull(); | ||
assertThat(leaderConfiguration).isNotNull(); | ||
assertThat(leaderConfiguration.getLeaseName()).isNotNull().isEqualTo(dataConfig.leaderElectionConfig().leaseName()); | ||
} | ||
} |