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

FISH-9198 Add Microprofile Config TOML Support #6988

Merged
merged 2 commits into from
Oct 14, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved.
# Copyright (c) [2018-2024] Payara Foundation and/or its affiliates. All rights reserved.
#
# The contents of this file are subject to the terms of either the GNU
# General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -48,6 +48,7 @@ microprofile.configuration.openTracingTab=OpenTracing
microprofile.configuration.configOrdinalTab=Ordinal
microprofile.configuration.configPropertyTab=Property
microprofile.configuration.configSecretsDirectoryTab=Directory
microprofile.configuration.tomlTab=TOML
microprofile.configuration.awsSecretsConfigSourceTab=AWS Secrets
microprofile.configuration.gcpSecretsConfigSourceTab=GCP Secrets
microprofile.configuration.azureSecretsConfigSourceTab=Azure Secrets
Expand Down Expand Up @@ -115,6 +116,8 @@ microprofile.specs.configuration.config.property.pageTitle=Property
microprofile.specs.configuration.config.property.pageTitleHelpText=Configuration options to set the given property name and value in one of the built-in config sources.
microprofile.specs.configuration.config.secretsDirectory.pageTitle=Secrets Directory
microprofile.specs.configuration.config.secretsDirectory.pageTitleHelpText=Sets the directory to be used for the directory config source.
microprofile.specs.configuration.config.toml.pageTitle=TOML
microprofile.specs.configuration.config.toml.pageTitleHelpText=Sets the TOML Config Source configuration.
microprofile.specs.configuration.config.awsSecretsConfigSource.pageTitle=AWS Secrets Config Source
microprofile.specs.configuration.config.awsSecretsConfigSource.pageTitleHelpText=Configuration options for the config source which fetches data from AWS Secrets Manager. Make sure that the password aliases AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY exist.
microprofile.specs.configuration.config.gcpSecretsConfigSource.pageTitle=GCP Secrets Config Source
Expand All @@ -138,6 +141,7 @@ config.ordinal.configuration.jndi=JNDI
config.ordinal.configuration.module=Module
config.ordinal.configuration.password=Password
config.ordinal.configuration.secretDirectory=Secret Directory
config.ordinal.configuration.toml=TOML
config.ordinal.configuration.server=Server
config.ordinal.configuration.cloud=Cloud
config.ordinal.configuration.jdbc=JDBC
Expand All @@ -152,7 +156,14 @@ config.property.configuration.moduleNameHelp=The name of the module when the Con

config.secretsDirectory.configuration.directory=Directory
config.secretsDirectory.configuration.directoryHelp=Full path to the directory containing configuration files.

config.toml.configuration.enabledLabel=Enabled
config.toml.configuration.enabledHelpText=Enable the config source, which fetches data from the specified TOML file
config.toml.configuration.dynamicLabel=Dynamic
config.toml.configuration.dynamicHelpText=Configure the config source dynamically, which will not require a restart
config.toml.configuration.path=Path
config.toml.configuration.pathHelp=Full path to the TOML configuration file.
config.toml.configuration.depth=Depth
config.toml.configuration.depthHelp=The maximum recursion depth.
config.aws.configuration.enabledLabel=Enabled
config.aws.configuration.enabledHelpText=Enable the config source, which fetches data from AWS Secrets Manager
config.aws.configuration.dynamicLabel=Dynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) [2018-2020] Payara Foundation and/or its affiliates. All rights reserved.
Copyright (c) [2018-2024] Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -64,6 +64,14 @@
gf.redirect(page="#{request.contextPath}/microprofile/microprofile/specs/configAPI/secretsDirectoryConfiguration.jsf?configName=#{configName}");
/>
</sun:tab>
<sun:tab id="microProfileConfigTOMLTab" immediate="$boolean{true}"
text="$resource{i18n_microprofile.microprofile.configuration.tomlTab}"
toolTip="$resource{i18n_microprofile.microprofile.configuration.tomlTab} Tab" >
<!command
setSessionAttribute(key="microprofileConfigTabs" value="microProfileConfigTOMLTab");
gf.redirect(page="#{request.contextPath}/microprofile/microprofile/specs/configAPI/tomlConfiguration.jsf?configName=#{configName}");
/>
</sun:tab>
<sun:tab id="microProfileConfigAWSSecretsConfigSourceTab" immediate="$boolean{true}"
text="$resource{i18n_microprofile.microprofile.configuration.awsSecretsConfigSourceTab}"
toolTip="$resource{i18n_microprofile.microprofile.configuration.awsSecretsConfigSourceTab} Tab" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
text="#{pageSession.microprofileConfigMap['secretDirOrdinality']}"/>
</sun:property>

<sun:property id="tomlOrdinalProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.ordinal.configuration.toml}">
<sun:textField id="endPoint" columns="$int{40}" maxLength="250"
text="#{pageSession.microprofileConfigMap['tomlOrdinality']}"/>
</sun:property>

<sun:property id="serverOrdinalProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.ordinal.configuration.server}">
<sun:textField id="endPoint" columns="$int{40}" maxLength="250"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!--

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) 2024 Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://github.com/payara/Payara/blob/main/LICENSE.txt
See the License for the specific
language governing permissions and limitations under the License.

When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/legal/LICENSE.txt.

GPL Classpath Exception:
The Payara Foundation designates this particular file as subject to the "Classpath"
exception as provided by the Payara Foundation in the GPL Version 2 section of the License
file that accompanied this code.

Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"

Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->

<!initPage
setResourceBundle(key="i18n_microprofile" bundle="fish.payara.admingui.microprofile.Strings");
/>
<!composition template="/templates/default.layout"
guiTitle="$resource{i18n_microprofile.microprofile.specs.configuration.config.toml.pageTitle}">

<!define name="content">

<event>
<!beforeCreate
setSessionAttribute(key="microprofileConfigTabs" value="microProfileConfigTOMLTab");
getRequestValue(key="configName" value="#{pageSession.configName}");
setPageSessionAttribute(key="MICROPROFILE_CONFIG_URL",
value="#{sessionScope.REST_URL}/configs/config/#{pageSession.configName}/microprofile-config");
gf.restRequest(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/get-toml-config-source-configuration?target=#{pageSession.configName}"
method="GET" result="#{requestScope.resp}");

setPageSessionAttribute(key="valueMap",
value="#{requestScope.resp.data.extraProperties.configSourceConfiguration}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");

setPageSessionAttribute(key="convertToFalseList", value={"enabled"});

if (#{pageSession.valueMap['enabled']}=true) {
setPageSessionAttribute(key="enabledSelected", value="true");
}
setPageSessionAttribute(key="dynamic", value="true");
/>
</event>


<sun:form id="propertyForm">
#include "/common/shared/alertMsg_1.inc"
#include "/microprofile/microprofile/microprofileConfigTabs.inc"
#include "/microprofile/microprofile/microprofileConfigAPITabs.inc"
<sun:title id="propertyContentPage" title="$resource{i18n_microprofile.microprofile.specs.configuration.config.toml.pageTitle}"
helpText="$resource{i18n_microprofile.microprofile.specs.configuration.config.toml.pageTitleHelpText}" >
<!facet pageButtonsTop>
<sun:panelGroup id="topButtons">
<sun:button id="saveButton" text="$resource{i18n.button.Save}"
onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}'))
submitAndDisable(this, '$resource{i18n.button.Processing}'); return false;" >
<!command
mapPut(map="#{pageSession.valueMap}" key="enabled" value="#{pageSession.enabledSelected}");
mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
prepareSuccessfulMsg();
gf.updateEntity(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/set-toml-config-source-configuration"
attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
/>
</sun:button>
</sun:panelGroup>
</facet>
</sun:title>
<sun:propertySheet id="propertySheet">
#include "/common/shared/configNameSection.inc"
<sun:propertySheetSection id="tomlProps">
<sun:property id="enabledProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.toml.configuration.enabledLabel}"
helpText="$resource{i18n_microprofile.config.toml.configuration.enabledHelpText}">
<sun:checkbox id="enabledProp" selected="#{pageSession.enabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="dynamic" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.toml.configuration.dynamicLabel}"
helpText="$resource{i18n_microprofile.config.toml.configuration.dynamicHelpText}">
<sun:checkbox id="dynamic" selected="#{pageSession.dynamic}" selectedValue="true" />
</sun:property>
<sun:property id="tomlPath" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.toml.configuration.path}"
helpText="$resource{i18n_microprofile.config.toml.configuration.pathHelp}">
<sun:textField id="tomlPathField" columns="$int{40}" maxLength="250"
text="#{pageSession.valueMap['path']}" styleClass="required"
required="#{true}"/>
</sun:property>
<sun:property id="tomlDepth" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.toml.configuration.depth}"
helpText="$resource{i18n_microprofile.config.toml.configuration.depthHelp}">
<sun:textField id="tomlDepthField" columns="$int{40}" maxLength="250"
text="#{pageSession.valueMap['depth']}" styleClass="required"
required="#{true}"/>
</sun:property>
</sun:propertySheetSection>
</sun:propertySheet>
</sun:form>
</define>
</composition>
6 changes: 5 additions & 1 deletion appserver/packager/appserver-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) 2019-2022 Payara Foundation and/or its affiliates. All rights reserved.
Copyright (c) 2019-2024 Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -274,5 +274,9 @@
<groupId>jakarta.jws</groupId>
<artifactId>jakarta.jws-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) [2020-2022] Payara Foundation and/or its affiliates. All rights reserved.
Copyright (c) [2020-2024] Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -46,8 +46,7 @@
<artifactId>microprofile</artifactId>
<version>6.2024.11-SNAPSHOT</version>
</parent>

<groupId>fish.payara.server.internal.payara-appserver-modules</groupId>

<artifactId>microprofile-config-extensions</artifactId>
<packaging>glassfish-jar</packaging>
<name>Microprofile-Config-Extensions</name>
Expand Down Expand Up @@ -85,6 +84,10 @@
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Loading