Skip to content
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
303 changes: 0 additions & 303 deletions portal-ui/build/asset-manifest.json

This file was deleted.

1 change: 0 additions & 1 deletion portal-ui/build/index.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
} from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";
import Loader from "../../Common/Loader/Loader";
import EndpointDisplay from "./EndpointDisplay";

const styles = (theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -82,6 +83,7 @@ const EditConfiguration = ({
const [saving, setSaving] = useState<boolean>(false);
const [loadingConfig, setLoadingConfig] = useState<boolean>(true);
const [configValues, setConfigValues] = useState<IElementValue[]>([]);
const [configSubsysList, setConfigSubsysList] = useState<any>([]);
const [resetConfigurationOpen, setResetConfigurationOpen] =
useState<boolean>(false);

Expand All @@ -97,7 +99,8 @@ const EditConfiguration = ({
api
.invoke("GET", `/api/v1/configs/${configId}`)
.then((res) => {
const keyVals = get(res, "key_values", []);
setConfigSubsysList(res);
const keyVals = get(res[0], "key_values", []);
setConfigValues(keyVals);
setLoadingConfig(false);
})
Expand Down Expand Up @@ -196,6 +199,13 @@ const EditConfiguration = ({
onChange={onValueChange}
defaultVals={configValues}
/>
{(selectedConfiguration.configuration_id === "logger_webhook" ||
selectedConfiguration.configuration_id === "audit_webhook") && (
<EndpointDisplay
classes={classes}
configSubsysList={configSubsysList}
/>
)}
</Grid>
<Grid
item
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useEffect, useState } from "react";

import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";

import {
fieldBasic,
settingsCommon,
} from "../../Common/FormComponents/common/styleLibrary";

import TableWrapper from "../../Common/TableWrapper/TableWrapper";

const styles = (theme: Theme) =>
createStyles({
...fieldBasic,
...settingsCommon,
settingsFormContainer: {
display: "grid",
gridTemplateColumns: "1fr",
gridGap: "10px",
},
});

interface IEndpointDisplayProps {
// selectedConfiguration: IConfigurationElement;
classes: any;
configSubsysList: any[];
className?: string;
}

const EndpointDisplay = ({
// selectedConfiguration,
classes,
configSubsysList,
className = "",
}: IEndpointDisplayProps) => {
const [configRecords, setConfigRecords] = useState<any>([]);

useEffect(() => {
let records: any[] = [];
if (configSubsysList !== null) {
configSubsysList.forEach((config) => {
if (config.name !== null && config.key_values !== null) {
records.push({
name: config.name,
endpoint: config.key_values[0]["value"],
});
if (config.key_values[0]["value"] === "off") {
records = [];
}
}
});
setConfigRecords(records);
}
}, [configSubsysList]);

return (
<Fragment>
<h3>Currently Configured Endpoints</h3>

<TableWrapper
columns={[
{ label: "Name", elementKey: "name" },
{ label: "Endpoint", elementKey: "endpoint" },
]}
idField="config-id"
isLoading={false}
records={configRecords}
classes={classes}
entityName="endpoints"
/>
</Fragment>
);
};

export default withStyles(styles)(EndpointDisplay);
40 changes: 21 additions & 19 deletions restapi/admin_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package restapi

import (
"context"
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -113,34 +114,39 @@ func getListConfigResponse(session *models.Principal, params cfgApi.ListConfigPa
// `madmin.Default`. Some configuration sub-systems are multi-target and since
// this function does not accept a target argument, it ignores all non-default
// targets.
func getConfig(ctx context.Context, client MinioAdmin, name string) ([]*models.ConfigurationKV, error) {
func getConfig(ctx context.Context, client MinioAdmin, name string) ([]*models.Configuration, error) {
configBytes, err := client.getConfigKV(ctx, name)
if err != nil {
return nil, err
}

subSysConfigs, err := madmin.ParseServerConfigOutput(string(configBytes))
if err != nil {
return nil, err
}

var configSubSysList []*models.Configuration
for _, scfg := range subSysConfigs {
var confkv []*models.ConfigurationKV
for _, kv := range scfg.KV {
// FIXME: Ignoring env-overrides for now as support for this
// needs to be added for presentation.
confkv = append(confkv, &models.ConfigurationKV{Key: kv.Key, Value: kv.Value})
}
if len(confkv) == 0 {
return nil, errors.New("Invalid SubSystem - check config format")
}
var fullConfigName string
if scfg.Target == "" {
var confkv []*models.ConfigurationKV
for _, kv := range scfg.KV {
// FIXME: Ignoring env-overrides for now as support for this
// needs to be added for presentation.
confkv = append(confkv, &models.ConfigurationKV{Key: kv.Key, Value: kv.Value})
}
return confkv, nil
fullConfigName = scfg.SubSystem
} else {
fullConfigName = scfg.SubSystem + ":" + scfg.Target
}
configSubSysList = append(configSubSysList, &models.Configuration{KeyValues: confkv, Name: fullConfigName})
}

return nil, fmt.Errorf("unable to find configuration for: %s (default target)", name)
return configSubSysList, nil
}

// getConfigResponse performs getConfig() and serializes it to the handler's output
func getConfigResponse(session *models.Principal, params cfgApi.ConfigInfoParams) (*models.Configuration, *models.Error) {
func getConfigResponse(session *models.Principal, params cfgApi.ConfigInfoParams) ([]*models.Configuration, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(session)
Expand All @@ -151,7 +157,7 @@ func getConfigResponse(session *models.Principal, params cfgApi.ConfigInfoParams
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}

configkv, err := getConfig(ctx, adminClient, params.Name)
configurations, err := getConfig(ctx, adminClient, params.Name)
if err != nil {
errorVal := ErrorWithContext(ctx, err)
minioError := madmin.ToErrorResponse(err)
Expand All @@ -160,11 +166,7 @@ func getConfigResponse(session *models.Principal, params cfgApi.ConfigInfoParams
}
return nil, errorVal
}
configurationObj := &models.Configuration{
Name: params.Name,
KeyValues: configkv,
}
return configurationObj, nil
return configurations, nil
}

// setConfig sets a configuration with the defined key values
Expand Down
22 changes: 13 additions & 9 deletions restapi/admin_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func Test_getConfig(t *testing.T) {
name string
args args
mock func()
want []*models.ConfigurationKV
want []*models.Configuration
wantErr bool
}{
{
Expand Down Expand Up @@ -445,14 +445,18 @@ func Test_getConfig(t *testing.T) {
return mockConfigList, nil
}
},
want: []*models.ConfigurationKV{
want: []*models.Configuration{
{
Key: PostgresConnectionString,
Value: "host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable",
},
{
Key: PostgresTable,
Value: "bucketevents",
KeyValues: []*models.ConfigurationKV{
{
Key: PostgresConnectionString,
Value: "host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable",
},
{
Key: PostgresTable,
Value: "bucketevents",
},
}, Name: "notify_postgres",
},
},
wantErr: false,
Expand Down Expand Up @@ -516,7 +520,7 @@ func Test_getConfig(t *testing.T) {
}
},
want: nil,
wantErr: false,
wantErr: true,
},
{
name: "random bytes coming out of getConfigKv",
Expand Down
10 changes: 8 additions & 2 deletions restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions restapi/operations/configuration/config_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions restapi/operations/configuration/config_info_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion swagger-console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,9 @@ paths:
200:
description: A successful response.
schema:
$ref: "#/definitions/configuration"
type: array
items:
$ref: "#/definitions/configuration"
default:
description: Generic error response.
schema:
Expand Down