Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonProperty to ControlPlanePluginConfig constructor parameter #996

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches:
- main
- "**"
tags-ignore:
# The release versions will be verified by 'publish-release.yml'
- centraldogma-*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@

import javax.annotation.Nullable;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.linecorp.centraldogma.server.plugin.AbstractPluginConfig;

/**
* A plugin configuration for the control plane.
*/
public final class ControlPlanePluginConfig extends AbstractPluginConfig {

/**
* Creates a new instance.
*/
public ControlPlanePluginConfig(@Nullable Boolean enabled) {
@JsonCreator
public ControlPlanePluginConfig(@JsonProperty("enabled") @Nullable Boolean enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need @JsonCreator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed when there's only one constructor. Let me add it though for clarity.

super(enabled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2024 LINE Corporation
*
* LINE Corporation licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.linecorp.centraldogma.xds.internal;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

import com.linecorp.centraldogma.server.CentralDogmaConfig;
import com.linecorp.centraldogma.server.plugin.PluginConfig;

class ControlPlanePluginConfigTest {

@Test
void duplicatePluginConfigs() throws Exception {
final CentralDogmaConfig config =
CentralDogmaConfig.load("{\n" +
" \"dataDir\": \"./data\",\n" +
" \"ports\": [\n" +
" {\n" +
" \"localAddress\": {\n" +
" \"host\": \"*\",\n" +
" \"port\": 36462\n" +
" },\n" +
" \"protocols\": [\n" +
" \"https\",\n" +
" \"http\",\n" +
" \"proxy\"\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"pluginConfigs\": [" +
" {\n" +
" \"type\": \"com.linecorp.centraldogma.xds.internal" +
".ControlPlanePluginConfig\",\n" +
" \"enabled\": false" +
" }" +
" ]\n" +
'}');
final PluginConfig pluginConfig = config.pluginConfigMap().get(ControlPlanePluginConfig.class);
assertThat(pluginConfig).isNotNull();
assertThat(pluginConfig.enabled()).isFalse();
}
}
Loading