Compare commits
7 Commits
v0.19.5
...
bucket_nam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ed8f11b22 | ||
|
|
860d8c6b78 | ||
|
|
99965805a6 | ||
|
|
7036d1328e | ||
|
|
697910c7b2 | ||
|
|
64dc605843 | ||
|
|
75fa88e6e2 |
@@ -4,7 +4,7 @@ linters-settings:
|
||||
|
||||
misspell:
|
||||
locale: US
|
||||
|
||||
|
||||
goheader:
|
||||
values:
|
||||
regexp:
|
||||
@@ -40,15 +40,15 @@ service:
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
- should have a package comment
|
||||
# TODO(y4m4): Remove once all exported ident. have comments!
|
||||
- comment on exported function
|
||||
- comment on exported type
|
||||
- should have comment
|
||||
- use leading k in Go names
|
||||
- comment on exported const
|
||||
- should have a package comment
|
||||
# TODO(y4m4): Remove once all exported ident. have comments!
|
||||
- comment on exported function
|
||||
- comment on exported type
|
||||
- should have comment
|
||||
- use leading k in Go names
|
||||
- comment on exported const
|
||||
run:
|
||||
skip-dirs:
|
||||
- pkg/clientgen
|
||||
- pkg/apis/networking.gke.io
|
||||
- restapi/operations
|
||||
- restapi/operations
|
||||
@@ -17,6 +17,7 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
directpvclient "github.com/minio/directpv/pkg/client"
|
||||
operator "github.com/minio/operator/pkg/client/clientset/versioned"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
@@ -63,3 +64,13 @@ func OperatorClient(token string) (*operator.Clientset, error) {
|
||||
func K8sClient(token string) (*kubernetes.Clientset, error) {
|
||||
return kubernetes.NewForConfig(GetK8sConfig(token))
|
||||
}
|
||||
|
||||
// DirectPV interfaces required to fetch information
|
||||
|
||||
func DirectPVDriveInterface(token string) (*directpvclient.DirectCSIDriveInterface, error) {
|
||||
return directpvclient.DirectCSIDriveInterfaceForConfig(GetK8sConfig(token))
|
||||
}
|
||||
|
||||
func DirectPVVolumeInterface(token string) (*directpvclient.DirectCSIVolumeInterface, error) {
|
||||
return directpvclient.DirectCSIVolumeInterfaceForConfig(GetK8sConfig(token))
|
||||
}
|
||||
|
||||
41
go.mod
41
go.mod
@@ -20,6 +20,7 @@ require (
|
||||
github.com/jessevdk/go-flags v1.5.0
|
||||
github.com/klauspost/compress v1.15.1
|
||||
github.com/minio/cli v1.22.0
|
||||
github.com/minio/directpv v1.4.4-0.20220805090942-948ca4731651
|
||||
github.com/minio/highwayhash v1.0.2
|
||||
github.com/minio/kes v0.19.2
|
||||
github.com/minio/madmin-go v1.4.3
|
||||
@@ -38,13 +39,20 @@ require (
|
||||
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861
|
||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.23.5
|
||||
k8s.io/apimachinery v0.23.5
|
||||
k8s.io/client-go v0.23.5
|
||||
k8s.io/api v0.24.3
|
||||
k8s.io/apimachinery v0.24.3
|
||||
k8s.io/client-go v0.24.3
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.81.0 // indirect
|
||||
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
|
||||
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
|
||||
github.com/Azure/go-autorest/logger v0.2.1 // indirect
|
||||
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
|
||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
@@ -59,8 +67,11 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
|
||||
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
||||
github.com/gdamore/encoding v1.0.0 // indirect
|
||||
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1 // indirect
|
||||
github.com/go-logr/logr v1.2.2 // indirect
|
||||
@@ -72,13 +83,16 @@ require (
|
||||
github.com/goccy/go-json v0.9.4 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
||||
github.com/google/go-cmp v0.5.7 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/googleapis/gnostic v0.5.5 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
@@ -91,12 +105,14 @@ require (
|
||||
github.com/lestrrat-go/option v1.0.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/magiconair/properties v1.8.5 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mattn/go-ieproxy v0.0.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect
|
||||
github.com/minio/colorjson v1.0.2 // indirect
|
||||
github.com/minio/filepath v1.0.0 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
@@ -108,16 +124,18 @@ require (
|
||||
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/navidys/tvxwidgets v0.1.0 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||
github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/xattr v0.4.5 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/posener/complete v1.2.3 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
|
||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.33.0 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
@@ -127,6 +145,12 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.2 // indirect
|
||||
github.com/shirou/gopsutil/v3 v3.22.2 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/spf13/afero v1.6.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.8.1 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tinylib/msgp v1.1.7-0.20211026165309-e818a1881b0e // indirect
|
||||
@@ -136,7 +160,7 @@ require (
|
||||
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.2 // indirect
|
||||
go.mongodb.org/mongo-driver v1.8.4 // indirect
|
||||
go.mongodb.org/mongo-driver v1.9.1 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
@@ -153,8 +177,9 @@ require (
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/klog/v2 v2.40.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect
|
||||
k8s.io/apiextensions-apiserver v0.24.3 // indirect
|
||||
k8s.io/klog/v2 v2.60.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.11.1 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
|
||||
85
models/direct_p_v_drive_info.go
Normal file
85
models/direct_p_v_drive_info.go
Normal file
@@ -0,0 +1,85 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// DirectPVDriveInfo direct p v drive info
|
||||
//
|
||||
// swagger:model directPVDriveInfo
|
||||
type DirectPVDriveInfo struct {
|
||||
|
||||
// allocated
|
||||
Allocated int64 `json:"allocated,omitempty"`
|
||||
|
||||
// capacity
|
||||
Capacity int64 `json:"capacity,omitempty"`
|
||||
|
||||
// drive
|
||||
Drive string `json:"drive,omitempty"`
|
||||
|
||||
// message
|
||||
Message string `json:"message,omitempty"`
|
||||
|
||||
// node
|
||||
Node string `json:"node,omitempty"`
|
||||
|
||||
// status
|
||||
Status string `json:"status,omitempty"`
|
||||
|
||||
// volumes
|
||||
Volumes int64 `json:"volumes,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this direct p v drive info
|
||||
func (m *DirectPVDriveInfo) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this direct p v drive info based on context it is used
|
||||
func (m *DirectPVDriveInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *DirectPVDriveInfo) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *DirectPVDriveInfo) UnmarshalBinary(b []byte) error {
|
||||
var res DirectPVDriveInfo
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
76
models/direct_p_v_volume_info.go
Normal file
76
models/direct_p_v_volume_info.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// DirectPVVolumeInfo direct p v volume info
|
||||
//
|
||||
// swagger:model directPVVolumeInfo
|
||||
type DirectPVVolumeInfo struct {
|
||||
|
||||
// capacity
|
||||
Capacity int64 `json:"capacity,omitempty"`
|
||||
|
||||
// drive
|
||||
Drive string `json:"drive,omitempty"`
|
||||
|
||||
// node
|
||||
Node string `json:"node,omitempty"`
|
||||
|
||||
// volume
|
||||
Volume string `json:"volume,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this direct p v volume info
|
||||
func (m *DirectPVVolumeInfo) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this direct p v volume info based on context it is used
|
||||
func (m *DirectPVVolumeInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *DirectPVVolumeInfo) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *DirectPVVolumeInfo) UnmarshalBinary(b []byte) error {
|
||||
var res DirectPVVolumeInfo
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
133
models/format_direct_p_v_drives_response.go
Normal file
133
models/format_direct_p_v_drives_response.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// FormatDirectPVDrivesResponse format direct p v drives response
|
||||
//
|
||||
// swagger:model formatDirectPVDrivesResponse
|
||||
type FormatDirectPVDrivesResponse struct {
|
||||
|
||||
// format issues list
|
||||
FormatIssuesList []*PvFormatErrorResponse `json:"formatIssuesList"`
|
||||
}
|
||||
|
||||
// Validate validates this format direct p v drives response
|
||||
func (m *FormatDirectPVDrivesResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateFormatIssuesList(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *FormatDirectPVDrivesResponse) validateFormatIssuesList(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.FormatIssuesList) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.FormatIssuesList); i++ {
|
||||
if swag.IsZero(m.FormatIssuesList[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.FormatIssuesList[i] != nil {
|
||||
if err := m.FormatIssuesList[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this format direct p v drives response based on the context it is used
|
||||
func (m *FormatDirectPVDrivesResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateFormatIssuesList(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *FormatDirectPVDrivesResponse) contextValidateFormatIssuesList(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.FormatIssuesList); i++ {
|
||||
|
||||
if m.FormatIssuesList[i] != nil {
|
||||
if err := m.FormatIssuesList[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *FormatDirectPVDrivesResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *FormatDirectPVDrivesResponse) UnmarshalBinary(b []byte) error {
|
||||
var res FormatDirectPVDrivesResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
133
models/get_direct_p_v_drive_list_response.go
Normal file
133
models/get_direct_p_v_drive_list_response.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// GetDirectPVDriveListResponse get direct p v drive list response
|
||||
//
|
||||
// swagger:model getDirectPVDriveListResponse
|
||||
type GetDirectPVDriveListResponse struct {
|
||||
|
||||
// drives
|
||||
Drives []*DirectPVDriveInfo `json:"drives"`
|
||||
}
|
||||
|
||||
// Validate validates this get direct p v drive list response
|
||||
func (m *GetDirectPVDriveListResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDrives(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetDirectPVDriveListResponse) validateDrives(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Drives) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Drives); i++ {
|
||||
if swag.IsZero(m.Drives[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Drives[i] != nil {
|
||||
if err := m.Drives[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("drives" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("drives" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this get direct p v drive list response based on the context it is used
|
||||
func (m *GetDirectPVDriveListResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateDrives(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetDirectPVDriveListResponse) contextValidateDrives(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Drives); i++ {
|
||||
|
||||
if m.Drives[i] != nil {
|
||||
if err := m.Drives[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("drives" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("drives" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *GetDirectPVDriveListResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *GetDirectPVDriveListResponse) UnmarshalBinary(b []byte) error {
|
||||
var res GetDirectPVDriveListResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
133
models/get_direct_p_v_volume_list_response.go
Normal file
133
models/get_direct_p_v_volume_list_response.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// GetDirectPVVolumeListResponse get direct p v volume list response
|
||||
//
|
||||
// swagger:model getDirectPVVolumeListResponse
|
||||
type GetDirectPVVolumeListResponse struct {
|
||||
|
||||
// volumes
|
||||
Volumes []*DirectPVVolumeInfo `json:"volumes"`
|
||||
}
|
||||
|
||||
// Validate validates this get direct p v volume list response
|
||||
func (m *GetDirectPVVolumeListResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateVolumes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetDirectPVVolumeListResponse) validateVolumes(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Volumes) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Volumes); i++ {
|
||||
if swag.IsZero(m.Volumes[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Volumes[i] != nil {
|
||||
if err := m.Volumes[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("volumes" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("volumes" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this get direct p v volume list response based on the context it is used
|
||||
func (m *GetDirectPVVolumeListResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateVolumes(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetDirectPVVolumeListResponse) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Volumes); i++ {
|
||||
|
||||
if m.Volumes[i] != nil {
|
||||
if err := m.Volumes[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("volumes" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("volumes" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *GetDirectPVVolumeListResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *GetDirectPVVolumeListResponse) UnmarshalBinary(b []byte) error {
|
||||
var res GetDirectPVVolumeListResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -46,6 +46,9 @@ type Principal struct {
|
||||
// account access key
|
||||
AccountAccessKey string `json:"accountAccessKey,omitempty"`
|
||||
|
||||
// custom style ob
|
||||
CustomStyleOb string `json:"customStyleOb,omitempty"`
|
||||
|
||||
// hm
|
||||
Hm bool `json:"hm,omitempty"`
|
||||
|
||||
|
||||
73
models/pv_format_error_response.go
Normal file
73
models/pv_format_error_response.go
Normal file
@@ -0,0 +1,73 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// PvFormatErrorResponse pv format error response
|
||||
//
|
||||
// swagger:model pvFormatErrorResponse
|
||||
type PvFormatErrorResponse struct {
|
||||
|
||||
// drive
|
||||
Drive string `json:"drive,omitempty"`
|
||||
|
||||
// error
|
||||
Error string `json:"error,omitempty"`
|
||||
|
||||
// node
|
||||
Node string `json:"node,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this pv format error response
|
||||
func (m *PvFormatErrorResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this pv format error response based on context it is used
|
||||
func (m *PvFormatErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PvFormatErrorResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PvFormatErrorResponse) UnmarshalBinary(b []byte) error {
|
||||
var res PvFormatErrorResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -41,6 +41,9 @@ type SessionResponse struct {
|
||||
// allow resources
|
||||
AllowResources []*PermissionResource `json:"allowResources"`
|
||||
|
||||
// custom styles
|
||||
CustomStyles string `json:"customStyles,omitempty"`
|
||||
|
||||
// distributed mode
|
||||
DistributedMode bool `json:"distributedMode,omitempty"`
|
||||
|
||||
|
||||
@@ -89,8 +89,12 @@ func configureAPI(api *operations.OperatorAPI) http.Handler {
|
||||
registerVolumesHandlers(api)
|
||||
// Namespaces handlers
|
||||
registerNamespaceHandlers(api)
|
||||
// Marketplace handlers
|
||||
registerMarketplaceHandlers(api)
|
||||
// Subnet handlers
|
||||
registerOperatorSubnetHandlers(api)
|
||||
// Direct PV handlers
|
||||
registerDirectPVHandlers(api)
|
||||
|
||||
api.PreServerShutdown = func() {}
|
||||
|
||||
|
||||
328
operatorapi/directpv.go
Normal file
328
operatorapi/directpv.go
Normal file
@@ -0,0 +1,328 @@
|
||||
// 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/>.
|
||||
|
||||
package operatorapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/directpv/pkg/utils"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/cluster"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/console/operatorapi/operations"
|
||||
"github.com/minio/console/operatorapi/operations/operator_api"
|
||||
xerrors "github.com/minio/console/restapi"
|
||||
directcsi "github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
|
||||
"github.com/minio/directpv/pkg/sys"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const XFS = "xfs"
|
||||
|
||||
func registerDirectPVHandlers(api *operations.OperatorAPI) {
|
||||
api.OperatorAPIGetDirectPVDriveListHandler = operator_api.GetDirectPVDriveListHandlerFunc(func(params operator_api.GetDirectPVDriveListParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := getDirectPVDrivesListResponse(session)
|
||||
if err != nil {
|
||||
return operator_api.NewGetDirectPVDriveListDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewGetDirectPVDriveListOK().WithPayload(resp)
|
||||
})
|
||||
api.OperatorAPIGetDirectPVVolumeListHandler = operator_api.GetDirectPVVolumeListHandlerFunc(func(params operator_api.GetDirectPVVolumeListParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := getDirectPVVolumesListResponse(session)
|
||||
if err != nil {
|
||||
return operator_api.NewGetDirectPVVolumeListDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewGetDirectPVVolumeListOK().WithPayload(resp)
|
||||
})
|
||||
api.OperatorAPIDirectPVFormatDriveHandler = operator_api.DirectPVFormatDriveHandlerFunc(func(params operator_api.DirectPVFormatDriveParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := formatVolumesResponse(session, params)
|
||||
if err != nil {
|
||||
return operator_api.NewDirectPVFormatDriveDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewDirectPVFormatDriveOK().WithPayload(resp)
|
||||
})
|
||||
}
|
||||
|
||||
// getDirectPVVolumesList returns directPV drives
|
||||
func getDirectPVDriveList(ctx context.Context, driveInterface DirectPVDrivesClientI) (*models.GetDirectPVDriveListResponse, error) {
|
||||
drivesList, err := driveInterface.List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &models.GetDirectPVDriveListResponse{}
|
||||
|
||||
// implementation same as directPV `drives ls` command
|
||||
driveName := func(val string) string {
|
||||
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
|
||||
dr = strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
|
||||
return strings.ReplaceAll(dr, sys.DirectCSIPartitionInfix, "")
|
||||
}
|
||||
drivesSorted := drivesList.Items
|
||||
// sort by nodename, path and status
|
||||
sort.Slice(drivesSorted, func(i, j int) bool {
|
||||
d1 := drivesSorted[i]
|
||||
d2 := drivesSorted[j]
|
||||
|
||||
if v := strings.Compare(d1.Status.NodeName, d2.Status.NodeName); v != 0 {
|
||||
return v < 0
|
||||
}
|
||||
|
||||
if v := strings.Compare(d1.Status.Path, d2.Status.Path); v != 0 {
|
||||
return v < 0
|
||||
}
|
||||
|
||||
return strings.Compare(string(d1.Status.DriveStatus), string(d2.Status.DriveStatus)) < 0
|
||||
})
|
||||
|
||||
for _, d := range drivesSorted {
|
||||
volumes := 0
|
||||
|
||||
if len(d.Finalizers) > 1 {
|
||||
volumes = len(d.Finalizers) - 1
|
||||
}
|
||||
|
||||
dr := driveName(d.Status.Path)
|
||||
dr = strings.ReplaceAll("/dev/"+dr, sys.DirectCSIPartitionInfix, "")
|
||||
|
||||
status := d.Status.DriveStatus
|
||||
msg := ""
|
||||
for _, c := range d.Status.Conditions {
|
||||
switch c.Type {
|
||||
case string(directcsi.DirectCSIDriveConditionInitialized), string(directcsi.DirectCSIDriveConditionOwned), string(directcsi.DirectCSIDriveConditionReady):
|
||||
if c.Status != metav1.ConditionTrue {
|
||||
msg = c.Message
|
||||
if msg != "" {
|
||||
status = d.Status.DriveStatus + "*"
|
||||
msg = strings.ReplaceAll(msg, d.Name, "")
|
||||
msg = strings.ReplaceAll(msg, sys.DirectCSIDevRoot, "/dev")
|
||||
msg = strings.ReplaceAll(msg, sys.DirectCSIPartitionInfix, "")
|
||||
msg = strings.Split(msg, "\n")[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var allocatedCapacity int64
|
||||
if status == directcsi.DriveStatusInUse {
|
||||
allocatedCapacity = d.Status.AllocatedCapacity
|
||||
}
|
||||
|
||||
drStatus := d.Status.DriveStatus
|
||||
|
||||
driveInfo := &models.DirectPVDriveInfo{
|
||||
Drive: dr,
|
||||
Capacity: d.Status.TotalCapacity,
|
||||
Allocated: allocatedCapacity,
|
||||
Node: d.Status.NodeName,
|
||||
Status: string(drStatus),
|
||||
Message: msg,
|
||||
Volumes: int64(volumes),
|
||||
}
|
||||
res.Drives = append(res.Drives, driveInfo)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func getDirectPVDrivesListResponse(session *models.Principal) (*models.GetDirectPVDriveListResponse, *models.Error) {
|
||||
ctx := context.Background()
|
||||
|
||||
driveInterface, err := cluster.DirectPVDriveInterface(session.STSSessionToken)
|
||||
if err != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
directPVDrvClient := &directPVDrivesClient{
|
||||
client: driveInterface,
|
||||
}
|
||||
|
||||
drives, err := getDirectPVDriveList(ctx, directPVDrvClient)
|
||||
if err != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return drives, nil
|
||||
}
|
||||
|
||||
// getDirectPVVolumesList returns directPV volumes
|
||||
func getDirectPVVolumesList(ctx context.Context, volumeInterface DirectPVVolumesClientI) (*models.GetDirectPVVolumeListResponse, error) {
|
||||
volList, err := volumeInterface.List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
driveName := func(val string) string {
|
||||
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
|
||||
return strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
|
||||
}
|
||||
|
||||
getLabelValue := func(obj metav1.Object, key string) string {
|
||||
if labels := obj.GetLabels(); labels != nil {
|
||||
return labels[key]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var volumes []*models.DirectPVVolumeInfo
|
||||
for _, v := range volList.Items {
|
||||
vol := &models.DirectPVVolumeInfo{
|
||||
Volume: v.Name,
|
||||
Capacity: v.Status.TotalCapacity,
|
||||
Drive: driveName(getLabelValue(&v, string(utils.DrivePathLabelKey))),
|
||||
Node: v.Status.NodeName,
|
||||
}
|
||||
|
||||
volumes = append(volumes, vol)
|
||||
}
|
||||
|
||||
res := &models.GetDirectPVVolumeListResponse{
|
||||
Volumes: volumes,
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func getDirectPVVolumesListResponse(session *models.Principal) (*models.GetDirectPVVolumeListResponse, *models.Error) {
|
||||
ctx := context.Background()
|
||||
|
||||
volumeInterface, err := cluster.DirectPVVolumeInterface(session.STSSessionToken)
|
||||
if err != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
directPVVolClient := &directPVVolumesClient{
|
||||
client: volumeInterface,
|
||||
}
|
||||
|
||||
volumes, err := getDirectPVVolumesList(ctx, directPVVolClient)
|
||||
if err != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
func formatDrives(ctx context.Context, driveInterface DirectPVDrivesClientI, drives []string, force bool) (*models.FormatDirectPVDrivesResponse, error) {
|
||||
if len(drives) == 0 {
|
||||
return nil, errors.New("at least one drive needs to be set")
|
||||
}
|
||||
|
||||
driveList, err := driveInterface.List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
driveName := func(val string) string {
|
||||
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
|
||||
dr = strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
|
||||
return strings.ReplaceAll(dr, sys.DirectCSIPartitionInfix, "")
|
||||
}
|
||||
|
||||
drivesArray := map[string]string{}
|
||||
|
||||
for _, driveFromAPI := range drives {
|
||||
drivesArray[driveFromAPI] = driveFromAPI
|
||||
}
|
||||
|
||||
if len(driveList.Items) == 0 {
|
||||
return nil, errors.New("no resources found globally")
|
||||
}
|
||||
|
||||
var errorResponses []*models.PvFormatErrorResponse
|
||||
|
||||
for _, driveItem := range driveList.Items {
|
||||
drName := "/dev/" + driveName(driveItem.Status.Path)
|
||||
driveName := driveItem.Status.NodeName + ":" + drName
|
||||
|
||||
base := &models.PvFormatErrorResponse{
|
||||
Node: driveItem.Status.NodeName,
|
||||
Drive: drName,
|
||||
Error: "",
|
||||
}
|
||||
|
||||
// Element is requested to be formatted
|
||||
if _, ok := drivesArray[driveName]; ok {
|
||||
if driveItem.Status.DriveStatus == directcsi.DriveStatusUnavailable {
|
||||
base.Error = "Status is unavailable"
|
||||
errorResponses = append(errorResponses, base)
|
||||
continue
|
||||
}
|
||||
|
||||
if driveItem.Status.DriveStatus == directcsi.DriveStatusInUse {
|
||||
base.Error = "Drive in use. Cannot be formatted"
|
||||
errorResponses = append(errorResponses, base)
|
||||
continue
|
||||
}
|
||||
|
||||
if driveItem.Status.DriveStatus == directcsi.DriveStatusReady {
|
||||
base.Error = "Drive already owned and managed."
|
||||
errorResponses = append(errorResponses, base)
|
||||
continue
|
||||
}
|
||||
if driveItem.Status.Filesystem != "" && !force {
|
||||
base.Error = "Drive already has a fs. Use force to overwrite"
|
||||
errorResponses = append(errorResponses, base)
|
||||
continue
|
||||
}
|
||||
|
||||
if driveItem.Status.DriveStatus == directcsi.DriveStatusReleased {
|
||||
base.Error = "Drive is in 'released state'. Please wait until it becomes available"
|
||||
errorResponses = append(errorResponses, base)
|
||||
continue
|
||||
}
|
||||
|
||||
// Validation passes, we request format
|
||||
driveItem.Spec.DirectCSIOwned = true
|
||||
driveItem.Spec.RequestedFormat = &directcsi.RequestedFormat{
|
||||
Filesystem: XFS,
|
||||
Force: force,
|
||||
}
|
||||
|
||||
_, err := driveInterface.Update(ctx, &driveItem, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
base.Error = err.Error()
|
||||
errorResponses = append(errorResponses, base)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returnErrors := &models.FormatDirectPVDrivesResponse{
|
||||
FormatIssuesList: errorResponses,
|
||||
}
|
||||
|
||||
return returnErrors, nil
|
||||
}
|
||||
|
||||
func formatVolumesResponse(session *models.Principal, params operator_api.DirectPVFormatDriveParams) (*models.FormatDirectPVDrivesResponse, *models.Error) {
|
||||
ctx := context.Background()
|
||||
|
||||
driveInterface, err := cluster.DirectPVDriveInterface(session.STSSessionToken)
|
||||
if err != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
directPVDrvClient := &directPVDrivesClient{
|
||||
client: driveInterface,
|
||||
}
|
||||
|
||||
formatResult, errFormat := formatDrives(ctx, directPVDrvClient, params.Body.Drives, *params.Body.Force)
|
||||
if errFormat != nil {
|
||||
return nil, xerrors.ErrorWithContext(ctx, errFormat)
|
||||
}
|
||||
return formatResult, nil
|
||||
}
|
||||
73
operatorapi/directpv_client.go
Normal file
73
operatorapi/directpv_client.go
Normal file
@@ -0,0 +1,73 @@
|
||||
// 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/>.
|
||||
|
||||
package operatorapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
|
||||
directPVClient "github.com/minio/directpv/pkg/client"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// DirectPVDrivesClientI interface with all functions to be implemented
|
||||
// by mock when testing, it should include all DirectPVDrivesClientI respective api calls
|
||||
// that are used within this project.
|
||||
type DirectPVDrivesClientI interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts metav1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
}
|
||||
|
||||
// Interface implementation
|
||||
//
|
||||
// Define the structure of directpv drive client and define the functions that are actually used
|
||||
// from the minio operator / directpv interface.
|
||||
|
||||
type directPVDrivesClient struct {
|
||||
client *directPVClient.DirectCSIDriveInterface
|
||||
}
|
||||
|
||||
// List implements the listing for DirectPV Drives List functionality
|
||||
func (dpd *directPVDrivesClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
return dpd.List(ctx, opts)
|
||||
}
|
||||
|
||||
// Update implements the listing for DirectPV Drives Update functionality
|
||||
func (dpd *directPVDrivesClient) Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts metav1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
return dpd.Update(ctx, driveItem, opts)
|
||||
}
|
||||
|
||||
// DirectPVVolumesClientI interface with all functions to be implemented
|
||||
// by mock when testing, it should include all DirectPVVolumesClientI respective api calls
|
||||
// that are used within this project.
|
||||
type DirectPVVolumesClientI interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
|
||||
}
|
||||
|
||||
// Interface implementation
|
||||
//
|
||||
// Define the structure of directpv volumes client and define the functions that are actually used
|
||||
// from the minio operator / directpv interface.
|
||||
|
||||
type directPVVolumesClient struct {
|
||||
client *directPVClient.DirectCSIVolumeInterface
|
||||
}
|
||||
|
||||
// List implements the listing for DirectPV Volumes List functionality
|
||||
func (dpv *directPVVolumesClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
|
||||
return dpv.List(ctx, opts)
|
||||
}
|
||||
410
operatorapi/directpv_test.go
Normal file
410
operatorapi/directpv_test.go
Normal file
@@ -0,0 +1,410 @@
|
||||
// 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/>.
|
||||
|
||||
package operatorapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
dpdClientListMock func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
dpdClientUpdateMock func(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts v1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
)
|
||||
|
||||
// mock function for drives List()
|
||||
func (dpdm directPVDriveMock) List(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
return dpdClientListMock(ctx, opts)
|
||||
}
|
||||
|
||||
func (dpdm directPVDriveMock) Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts v1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
return dpdClientUpdateMock(ctx, driveItem, opts)
|
||||
}
|
||||
|
||||
var dpvClientListMock func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
|
||||
|
||||
// mock function for volumes List()
|
||||
func (dpvm directPVVolumeMock) List(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
|
||||
return dpvClientListMock(ctx, opts)
|
||||
}
|
||||
|
||||
// DirectPVDrivesList
|
||||
func Test_GetDirectPVDrives(t *testing.T) {
|
||||
directPVDrvMock := directPVDriveMock{}
|
||||
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
opts v1.ListOptions
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
client DirectPVDrivesClientI
|
||||
mockListDrives func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Can List Drives correctly",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
opts: v1.ListOptions{},
|
||||
},
|
||||
client: directPVDrvMock,
|
||||
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
items := []v1beta4.DirectCSIDrive{}
|
||||
|
||||
returnList := v1beta4.DirectCSIDriveList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Drives request from DirectPV failed",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
},
|
||||
client: directPVDrvMock,
|
||||
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
return nil, errors.New("some error occurred")
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Drives request from DirectPV has information and doesn't return errors",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
},
|
||||
client: directPVDrvMock,
|
||||
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
items := []v1beta4.DirectCSIDrive{
|
||||
{
|
||||
Status: v1beta4.DirectCSIDriveStatus{
|
||||
Path: "/var/lib/direct-csi/devices/test-part-dev0-directcsi",
|
||||
AllocatedCapacity: 0,
|
||||
FreeCapacity: 4772382377372,
|
||||
RootPartition: "/",
|
||||
PartitionNum: 0,
|
||||
Filesystem: "nfs",
|
||||
Mountpoint: "",
|
||||
NodeName: "test-dev0-directcsi",
|
||||
DriveStatus: v1beta4.DriveStatusReady,
|
||||
ModelNumber: "testModel",
|
||||
SerialNumber: "testSN",
|
||||
TotalCapacity: 4772382377372,
|
||||
PhysicalBlockSize: 1024,
|
||||
LogicalBlockSize: 1024,
|
||||
AccessTier: "",
|
||||
FilesystemUUID: "",
|
||||
PartitionUUID: "",
|
||||
MajorNumber: 0,
|
||||
MinorNumber: 0,
|
||||
UeventSerial: "",
|
||||
UeventFSUUID: "",
|
||||
WWID: "",
|
||||
Vendor: "",
|
||||
DMName: "",
|
||||
DMUUID: "",
|
||||
MDUUID: "",
|
||||
PartTableUUID: "",
|
||||
PartTableType: "",
|
||||
Virtual: false,
|
||||
ReadOnly: false,
|
||||
Partitioned: false,
|
||||
SwapOn: false,
|
||||
Master: "",
|
||||
OtherMountsInfo: nil,
|
||||
PCIPath: "",
|
||||
SerialNumberLong: "",
|
||||
Conditions: []v1.Condition{{
|
||||
Type: "",
|
||||
Status: "",
|
||||
ObservedGeneration: 0,
|
||||
LastTransitionTime: v1.Time{},
|
||||
Reason: "",
|
||||
Message: "",
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Status: v1beta4.DirectCSIDriveStatus{
|
||||
Path: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
|
||||
AllocatedCapacity: 0,
|
||||
FreeCapacity: 4772382377372,
|
||||
RootPartition: "/",
|
||||
PartitionNum: 0,
|
||||
Filesystem: "nfs",
|
||||
Mountpoint: "",
|
||||
NodeName: "test-dev1-directcsi",
|
||||
DriveStatus: v1beta4.DriveStatus(v1beta4.DirectCSIDriveConditionOwned),
|
||||
ModelNumber: "testModel",
|
||||
SerialNumber: "testSN2",
|
||||
TotalCapacity: 4772382377372,
|
||||
PhysicalBlockSize: 1024,
|
||||
LogicalBlockSize: 1024,
|
||||
AccessTier: "",
|
||||
FilesystemUUID: "",
|
||||
PartitionUUID: "",
|
||||
MajorNumber: 0,
|
||||
MinorNumber: 0,
|
||||
UeventSerial: "",
|
||||
UeventFSUUID: "",
|
||||
WWID: "",
|
||||
Vendor: "",
|
||||
DMName: "",
|
||||
DMUUID: "",
|
||||
MDUUID: "",
|
||||
PartTableUUID: "",
|
||||
PartTableType: "",
|
||||
Virtual: false,
|
||||
ReadOnly: false,
|
||||
Partitioned: false,
|
||||
SwapOn: false,
|
||||
Master: "",
|
||||
OtherMountsInfo: nil,
|
||||
PCIPath: "",
|
||||
SerialNumberLong: "",
|
||||
Conditions: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
returnList := v1beta4.DirectCSIDriveList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dpdClientListMock = tt.mockListDrives
|
||||
|
||||
_, err := getDirectPVDriveList(tt.args.ctx, tt.client)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// DirectPVVolumesList
|
||||
func Test_GetDirectPVVolumes(t *testing.T) {
|
||||
directPVVolMock := directPVVolumeMock{}
|
||||
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
opts v1.ListOptions
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
volumesClient DirectPVVolumesClientI
|
||||
mockListVolumes func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Can List Volumes correctly",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
opts: v1.ListOptions{},
|
||||
},
|
||||
volumesClient: directPVVolMock,
|
||||
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
|
||||
items := []v1beta4.DirectCSIVolume{}
|
||||
|
||||
returnList := v1beta4.DirectCSIVolumeList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Drives request from DirectPV is ok but volumes request failed",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
},
|
||||
volumesClient: directPVVolMock,
|
||||
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
|
||||
return nil, errors.New("some error occurred")
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Can List Volumes & Drives correctly without any issue",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
opts: v1.ListOptions{},
|
||||
},
|
||||
volumesClient: directPVVolMock,
|
||||
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
|
||||
items := []v1beta4.DirectCSIVolume{{
|
||||
Status: v1beta4.DirectCSIVolumeStatus{
|
||||
Drive: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
|
||||
NodeName: "testNodeName",
|
||||
HostPath: "",
|
||||
StagingPath: "",
|
||||
ContainerPath: "",
|
||||
TotalCapacity: 4772382377372,
|
||||
AvailableCapacity: 4772382377372,
|
||||
UsedCapacity: 0,
|
||||
Conditions: nil,
|
||||
},
|
||||
}}
|
||||
|
||||
returnList := v1beta4.DirectCSIVolumeList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dpvClientListMock = tt.mockListVolumes
|
||||
|
||||
_, err := getDirectPVVolumesList(tt.args.ctx, tt.volumesClient)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// FormatDrives
|
||||
func Test_GetDirectPVFormatDrives(t *testing.T) {
|
||||
directPVDrvMock := directPVDriveMock{}
|
||||
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
opts v1.ListOptions
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
drivesClient DirectPVDrivesClientI
|
||||
mockListDrives func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
|
||||
drives []string
|
||||
force bool
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Format doesn't crash on empty list & returns error",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
opts: v1.ListOptions{},
|
||||
},
|
||||
drivesClient: directPVDrvMock,
|
||||
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
items := []v1beta4.DirectCSIDrive{}
|
||||
|
||||
returnList := v1beta4.DirectCSIDriveList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
drives: []string{},
|
||||
force: false,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Can Format Selected drives",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
opts: v1.ListOptions{},
|
||||
},
|
||||
drivesClient: directPVDrvMock,
|
||||
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
|
||||
items := []v1beta4.DirectCSIDrive{
|
||||
{
|
||||
Status: v1beta4.DirectCSIDriveStatus{
|
||||
Path: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
|
||||
AllocatedCapacity: 0,
|
||||
FreeCapacity: 4772382377372,
|
||||
RootPartition: "/",
|
||||
PartitionNum: 0,
|
||||
Filesystem: "nfs",
|
||||
Mountpoint: "",
|
||||
NodeName: "test-dev1-directcsi",
|
||||
DriveStatus: v1beta4.DriveStatusAvailable,
|
||||
ModelNumber: "testModel",
|
||||
SerialNumber: "testSN2",
|
||||
TotalCapacity: 4772382377372,
|
||||
PhysicalBlockSize: 1024,
|
||||
LogicalBlockSize: 1024,
|
||||
AccessTier: "",
|
||||
FilesystemUUID: "",
|
||||
PartitionUUID: "",
|
||||
MajorNumber: 0,
|
||||
MinorNumber: 0,
|
||||
UeventSerial: "",
|
||||
UeventFSUUID: "",
|
||||
WWID: "",
|
||||
Vendor: "",
|
||||
DMName: "",
|
||||
DMUUID: "",
|
||||
MDUUID: "",
|
||||
PartTableUUID: "",
|
||||
PartTableType: "",
|
||||
Virtual: false,
|
||||
ReadOnly: false,
|
||||
Partitioned: false,
|
||||
SwapOn: false,
|
||||
Master: "",
|
||||
OtherMountsInfo: nil,
|
||||
PCIPath: "",
|
||||
SerialNumberLong: "",
|
||||
Conditions: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
returnList := v1beta4.DirectCSIDriveList{
|
||||
Items: items,
|
||||
}
|
||||
|
||||
return &returnList, nil
|
||||
},
|
||||
drives: []string{"test-dev1-directcsi:/dev/testdev1-directcsi"},
|
||||
force: false,
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dpdClientListMock = tt.mockListDrives
|
||||
|
||||
_, err := formatDrives(tt.args.ctx, tt.drivesClient, tt.drives, tt.force)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,109 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/drives": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Get directpv drives list",
|
||||
"operationId": "GetDirectPVDriveList",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "nodes",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "drives",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/getDirectPVDriveListResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/drives/format": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Format directpv drives from a list",
|
||||
"operationId": "DirectPVFormatDrive",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/formatConfiguration"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/formatDirectPVDrivesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/volumes": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Get directpv volumes list",
|
||||
"operationId": "GetDirectPVVolumeList",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "nodes",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "drives",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/getDirectPVVolumeListResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/get-parity/{nodes}/{disksPerNode}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2590,20 +2693,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"csiFormatErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drive": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"node": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"csrElement": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2796,7 +2885,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"directCSIDriveInfo": {
|
||||
"directPVDriveInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allocated": {
|
||||
@@ -2825,7 +2914,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"directCSIVolumeInfo": {
|
||||
"directPVVolumeInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"capacity": {
|
||||
@@ -3042,13 +3131,13 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"formatDirectCSIDrivesResponse": {
|
||||
"formatDirectPVDrivesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"formatIssuesList": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/csiFormatErrorResponse"
|
||||
"$ref": "#/definitions/pvFormatErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3193,24 +3282,24 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"getDirectCSIDriveListResponse": {
|
||||
"getDirectPVDriveListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drives": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/directCSIDriveInfo"
|
||||
"$ref": "#/definitions/directPVDriveInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"getDirectCSIVolumeListResponse": {
|
||||
"getDirectPVVolumeListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"volumes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/directCSIVolumeInfo"
|
||||
"$ref": "#/definitions/directPVVolumeInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4151,6 +4240,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"pvFormatErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drive": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"node": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pvc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5112,6 +5215,109 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/drives": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Get directpv drives list",
|
||||
"operationId": "GetDirectPVDriveList",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "nodes",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "drives",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/getDirectPVDriveListResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/drives/format": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Format directpv drives from a list",
|
||||
"operationId": "DirectPVFormatDrive",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/formatConfiguration"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/formatDirectPVDrivesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/directpv/volumes": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Get directpv volumes list",
|
||||
"operationId": "GetDirectPVVolumeList",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "nodes",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "drives",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/getDirectPVVolumeListResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/get-parity/{nodes}/{disksPerNode}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -8403,20 +8609,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"csiFormatErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drive": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"node": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"csrElement": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -8609,7 +8801,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"directCSIDriveInfo": {
|
||||
"directPVDriveInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allocated": {
|
||||
@@ -8638,7 +8830,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"directCSIVolumeInfo": {
|
||||
"directPVVolumeInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"capacity": {
|
||||
@@ -8855,13 +9047,13 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"formatDirectCSIDrivesResponse": {
|
||||
"formatDirectPVDrivesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"formatIssuesList": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/csiFormatErrorResponse"
|
||||
"$ref": "#/definitions/pvFormatErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9006,24 +9198,24 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"getDirectCSIDriveListResponse": {
|
||||
"getDirectPVDriveListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drives": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/directCSIDriveInfo"
|
||||
"$ref": "#/definitions/directPVDriveInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"getDirectCSIVolumeListResponse": {
|
||||
"getDirectPVVolumeListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"volumes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/directCSIVolumeInfo"
|
||||
"$ref": "#/definitions/directPVVolumeInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9817,6 +10009,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"pvFormatErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"drive": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"node": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pvc": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -22,8 +22,10 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
opClientMock struct{}
|
||||
httpClientMock struct{}
|
||||
opClientMock struct{}
|
||||
httpClientMock struct{}
|
||||
directPVDriveMock struct{}
|
||||
directPVVolumeMock struct{}
|
||||
)
|
||||
|
||||
func createMockPVC(pvcMockName, pvcMockNamespace string) *v1.PersistentVolumeClaim {
|
||||
|
||||
@@ -85,6 +85,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
|
||||
OperatorAPIDescribePodHandler: operator_api.DescribePodHandlerFunc(func(params operator_api.DescribePodParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.DescribePod has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIDirectPVFormatDriveHandler: operator_api.DirectPVFormatDriveHandlerFunc(func(params operator_api.DirectPVFormatDriveParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.DirectPVFormatDrive has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIDisableTenantLoggingHandler: operator_api.DisableTenantLoggingHandlerFunc(func(params operator_api.DisableTenantLoggingParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.DisableTenantLogging has not yet been implemented")
|
||||
}),
|
||||
@@ -94,6 +97,12 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
|
||||
OperatorAPIGetAllocatableResourcesHandler: operator_api.GetAllocatableResourcesHandlerFunc(func(params operator_api.GetAllocatableResourcesParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.GetAllocatableResources has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIGetDirectPVDriveListHandler: operator_api.GetDirectPVDriveListHandlerFunc(func(params operator_api.GetDirectPVDriveListParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.GetDirectPVDriveList has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIGetDirectPVVolumeListHandler: operator_api.GetDirectPVVolumeListHandlerFunc(func(params operator_api.GetDirectPVVolumeListParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.GetDirectPVVolumeList has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIGetMPIntegrationHandler: operator_api.GetMPIntegrationHandlerFunc(func(params operator_api.GetMPIntegrationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.GetMPIntegration has not yet been implemented")
|
||||
}),
|
||||
@@ -313,12 +322,18 @@ type OperatorAPI struct {
|
||||
OperatorAPIDeleteTenantHandler operator_api.DeleteTenantHandler
|
||||
// OperatorAPIDescribePodHandler sets the operation handler for the describe pod operation
|
||||
OperatorAPIDescribePodHandler operator_api.DescribePodHandler
|
||||
// OperatorAPIDirectPVFormatDriveHandler sets the operation handler for the direct p v format drive operation
|
||||
OperatorAPIDirectPVFormatDriveHandler operator_api.DirectPVFormatDriveHandler
|
||||
// OperatorAPIDisableTenantLoggingHandler sets the operation handler for the disable tenant logging operation
|
||||
OperatorAPIDisableTenantLoggingHandler operator_api.DisableTenantLoggingHandler
|
||||
// OperatorAPIEnableTenantLoggingHandler sets the operation handler for the enable tenant logging operation
|
||||
OperatorAPIEnableTenantLoggingHandler operator_api.EnableTenantLoggingHandler
|
||||
// OperatorAPIGetAllocatableResourcesHandler sets the operation handler for the get allocatable resources operation
|
||||
OperatorAPIGetAllocatableResourcesHandler operator_api.GetAllocatableResourcesHandler
|
||||
// OperatorAPIGetDirectPVDriveListHandler sets the operation handler for the get direct p v drive list operation
|
||||
OperatorAPIGetDirectPVDriveListHandler operator_api.GetDirectPVDriveListHandler
|
||||
// OperatorAPIGetDirectPVVolumeListHandler sets the operation handler for the get direct p v volume list operation
|
||||
OperatorAPIGetDirectPVVolumeListHandler operator_api.GetDirectPVVolumeListHandler
|
||||
// OperatorAPIGetMPIntegrationHandler sets the operation handler for the get m p integration operation
|
||||
OperatorAPIGetMPIntegrationHandler operator_api.GetMPIntegrationHandler
|
||||
// OperatorAPIGetMaxAllocatableMemHandler sets the operation handler for the get max allocatable mem operation
|
||||
@@ -525,6 +540,9 @@ func (o *OperatorAPI) Validate() error {
|
||||
if o.OperatorAPIDescribePodHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.DescribePodHandler")
|
||||
}
|
||||
if o.OperatorAPIDirectPVFormatDriveHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.DirectPVFormatDriveHandler")
|
||||
}
|
||||
if o.OperatorAPIDisableTenantLoggingHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.DisableTenantLoggingHandler")
|
||||
}
|
||||
@@ -534,6 +552,12 @@ func (o *OperatorAPI) Validate() error {
|
||||
if o.OperatorAPIGetAllocatableResourcesHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.GetAllocatableResourcesHandler")
|
||||
}
|
||||
if o.OperatorAPIGetDirectPVDriveListHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.GetDirectPVDriveListHandler")
|
||||
}
|
||||
if o.OperatorAPIGetDirectPVVolumeListHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.GetDirectPVVolumeListHandler")
|
||||
}
|
||||
if o.OperatorAPIGetMPIntegrationHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.GetMPIntegrationHandler")
|
||||
}
|
||||
@@ -819,6 +843,10 @@ func (o *OperatorAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/directpv/drives/format"] = operator_api.NewDirectPVFormatDrive(o.context, o.OperatorAPIDirectPVFormatDriveHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/namespaces/{namespace}/tenants/{tenant}/disable-logging"] = operator_api.NewDisableTenantLogging(o.context, o.OperatorAPIDisableTenantLoggingHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
@@ -831,6 +859,14 @@ func (o *OperatorAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/directpv/drives"] = operator_api.NewGetDirectPVDriveList(o.context, o.OperatorAPIGetDirectPVDriveListHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/directpv/volumes"] = operator_api.NewGetDirectPVVolumeList(o.context, o.OperatorAPIGetDirectPVVolumeListHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/mp-integration"] = operator_api.NewGetMPIntegration(o.context, o.OperatorAPIGetMPIntegrationHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// DirectPVFormatDriveHandlerFunc turns a function with the right signature into a direct p v format drive handler
|
||||
type DirectPVFormatDriveHandlerFunc func(DirectPVFormatDriveParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DirectPVFormatDriveHandlerFunc) Handle(params DirectPVFormatDriveParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// DirectPVFormatDriveHandler interface for that can handle valid direct p v format drive params
|
||||
type DirectPVFormatDriveHandler interface {
|
||||
Handle(DirectPVFormatDriveParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDirectPVFormatDrive creates a new http.Handler for the direct p v format drive operation
|
||||
func NewDirectPVFormatDrive(ctx *middleware.Context, handler DirectPVFormatDriveHandler) *DirectPVFormatDrive {
|
||||
return &DirectPVFormatDrive{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* DirectPVFormatDrive swagger:route POST /directpv/drives/format OperatorAPI directPVFormatDrive
|
||||
|
||||
Format directpv drives from a list
|
||||
|
||||
*/
|
||||
type DirectPVFormatDrive struct {
|
||||
Context *middleware.Context
|
||||
Handler DirectPVFormatDriveHandler
|
||||
}
|
||||
|
||||
func (o *DirectPVFormatDrive) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewDirectPVFormatDriveParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewDirectPVFormatDriveParams creates a new DirectPVFormatDriveParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewDirectPVFormatDriveParams() DirectPVFormatDriveParams {
|
||||
|
||||
return DirectPVFormatDriveParams{}
|
||||
}
|
||||
|
||||
// DirectPVFormatDriveParams contains all the bound params for the direct p v format drive operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DirectPVFormatDrive
|
||||
type DirectPVFormatDriveParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.FormatConfiguration
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewDirectPVFormatDriveParams() beforehand.
|
||||
func (o *DirectPVFormatDriveParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.FormatConfiguration
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(context.Background())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// DirectPVFormatDriveOKCode is the HTTP code returned for type DirectPVFormatDriveOK
|
||||
const DirectPVFormatDriveOKCode int = 200
|
||||
|
||||
/*DirectPVFormatDriveOK A successful response.
|
||||
|
||||
swagger:response directPVFormatDriveOK
|
||||
*/
|
||||
type DirectPVFormatDriveOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.FormatDirectPVDrivesResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDirectPVFormatDriveOK creates DirectPVFormatDriveOK with default headers values
|
||||
func NewDirectPVFormatDriveOK() *DirectPVFormatDriveOK {
|
||||
|
||||
return &DirectPVFormatDriveOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the direct p v format drive o k response
|
||||
func (o *DirectPVFormatDriveOK) WithPayload(payload *models.FormatDirectPVDrivesResponse) *DirectPVFormatDriveOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the direct p v format drive o k response
|
||||
func (o *DirectPVFormatDriveOK) SetPayload(payload *models.FormatDirectPVDrivesResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DirectPVFormatDriveOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*DirectPVFormatDriveDefault Generic error response.
|
||||
|
||||
swagger:response directPVFormatDriveDefault
|
||||
*/
|
||||
type DirectPVFormatDriveDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDirectPVFormatDriveDefault creates DirectPVFormatDriveDefault with default headers values
|
||||
func NewDirectPVFormatDriveDefault(code int) *DirectPVFormatDriveDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DirectPVFormatDriveDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the direct p v format drive default response
|
||||
func (o *DirectPVFormatDriveDefault) WithStatusCode(code int) *DirectPVFormatDriveDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the direct p v format drive default response
|
||||
func (o *DirectPVFormatDriveDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the direct p v format drive default response
|
||||
func (o *DirectPVFormatDriveDefault) WithPayload(payload *models.Error) *DirectPVFormatDriveDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the direct p v format drive default response
|
||||
func (o *DirectPVFormatDriveDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DirectPVFormatDriveDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// DirectPVFormatDriveURL generates an URL for the direct p v format drive operation
|
||||
type DirectPVFormatDriveURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *DirectPVFormatDriveURL) WithBasePath(bp string) *DirectPVFormatDriveURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *DirectPVFormatDriveURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *DirectPVFormatDriveURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/directpv/drives/format"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *DirectPVFormatDriveURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *DirectPVFormatDriveURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *DirectPVFormatDriveURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on DirectPVFormatDriveURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on DirectPVFormatDriveURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *DirectPVFormatDriveURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetDirectPVDriveListHandlerFunc turns a function with the right signature into a get direct p v drive list handler
|
||||
type GetDirectPVDriveListHandlerFunc func(GetDirectPVDriveListParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetDirectPVDriveListHandlerFunc) Handle(params GetDirectPVDriveListParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetDirectPVDriveListHandler interface for that can handle valid get direct p v drive list params
|
||||
type GetDirectPVDriveListHandler interface {
|
||||
Handle(GetDirectPVDriveListParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetDirectPVDriveList creates a new http.Handler for the get direct p v drive list operation
|
||||
func NewGetDirectPVDriveList(ctx *middleware.Context, handler GetDirectPVDriveListHandler) *GetDirectPVDriveList {
|
||||
return &GetDirectPVDriveList{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* GetDirectPVDriveList swagger:route GET /directpv/drives OperatorAPI getDirectPVDriveList
|
||||
|
||||
Get directpv drives list
|
||||
|
||||
*/
|
||||
type GetDirectPVDriveList struct {
|
||||
Context *middleware.Context
|
||||
Handler GetDirectPVDriveListHandler
|
||||
}
|
||||
|
||||
func (o *GetDirectPVDriveList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetDirectPVDriveListParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetDirectPVDriveListParams creates a new GetDirectPVDriveListParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetDirectPVDriveListParams() GetDirectPVDriveListParams {
|
||||
|
||||
return GetDirectPVDriveListParams{}
|
||||
}
|
||||
|
||||
// GetDirectPVDriveListParams contains all the bound params for the get direct p v drive list operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetDirectPVDriveList
|
||||
type GetDirectPVDriveListParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Drives *string
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Nodes *string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetDirectPVDriveListParams() beforehand.
|
||||
func (o *GetDirectPVDriveListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qDrives, qhkDrives, _ := qs.GetOK("drives")
|
||||
if err := o.bindDrives(qDrives, qhkDrives, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qNodes, qhkNodes, _ := qs.GetOK("nodes")
|
||||
if err := o.bindNodes(qNodes, qhkNodes, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindDrives binds and validates parameter Drives from query.
|
||||
func (o *GetDirectPVDriveListParams) bindDrives(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
o.Drives = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindNodes binds and validates parameter Nodes from query.
|
||||
func (o *GetDirectPVDriveListParams) bindNodes(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
o.Nodes = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetDirectPVDriveListOKCode is the HTTP code returned for type GetDirectPVDriveListOK
|
||||
const GetDirectPVDriveListOKCode int = 200
|
||||
|
||||
/*GetDirectPVDriveListOK A successful response.
|
||||
|
||||
swagger:response getDirectPVDriveListOK
|
||||
*/
|
||||
type GetDirectPVDriveListOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.GetDirectPVDriveListResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetDirectPVDriveListOK creates GetDirectPVDriveListOK with default headers values
|
||||
func NewGetDirectPVDriveListOK() *GetDirectPVDriveListOK {
|
||||
|
||||
return &GetDirectPVDriveListOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get direct p v drive list o k response
|
||||
func (o *GetDirectPVDriveListOK) WithPayload(payload *models.GetDirectPVDriveListResponse) *GetDirectPVDriveListOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get direct p v drive list o k response
|
||||
func (o *GetDirectPVDriveListOK) SetPayload(payload *models.GetDirectPVDriveListResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetDirectPVDriveListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetDirectPVDriveListDefault Generic error response.
|
||||
|
||||
swagger:response getDirectPVDriveListDefault
|
||||
*/
|
||||
type GetDirectPVDriveListDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetDirectPVDriveListDefault creates GetDirectPVDriveListDefault with default headers values
|
||||
func NewGetDirectPVDriveListDefault(code int) *GetDirectPVDriveListDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetDirectPVDriveListDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get direct p v drive list default response
|
||||
func (o *GetDirectPVDriveListDefault) WithStatusCode(code int) *GetDirectPVDriveListDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get direct p v drive list default response
|
||||
func (o *GetDirectPVDriveListDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get direct p v drive list default response
|
||||
func (o *GetDirectPVDriveListDefault) WithPayload(payload *models.Error) *GetDirectPVDriveListDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get direct p v drive list default response
|
||||
func (o *GetDirectPVDriveListDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetDirectPVDriveListDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// GetDirectPVDriveListURL generates an URL for the get direct p v drive list operation
|
||||
type GetDirectPVDriveListURL struct {
|
||||
Drives *string
|
||||
Nodes *string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetDirectPVDriveListURL) WithBasePath(bp string) *GetDirectPVDriveListURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetDirectPVDriveListURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetDirectPVDriveListURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/directpv/drives"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
var drivesQ string
|
||||
if o.Drives != nil {
|
||||
drivesQ = *o.Drives
|
||||
}
|
||||
if drivesQ != "" {
|
||||
qs.Set("drives", drivesQ)
|
||||
}
|
||||
|
||||
var nodesQ string
|
||||
if o.Nodes != nil {
|
||||
nodesQ = *o.Nodes
|
||||
}
|
||||
if nodesQ != "" {
|
||||
qs.Set("nodes", nodesQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetDirectPVDriveListURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetDirectPVDriveListURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetDirectPVDriveListURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetDirectPVDriveListURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetDirectPVDriveListURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetDirectPVDriveListURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetDirectPVVolumeListHandlerFunc turns a function with the right signature into a get direct p v volume list handler
|
||||
type GetDirectPVVolumeListHandlerFunc func(GetDirectPVVolumeListParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetDirectPVVolumeListHandlerFunc) Handle(params GetDirectPVVolumeListParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetDirectPVVolumeListHandler interface for that can handle valid get direct p v volume list params
|
||||
type GetDirectPVVolumeListHandler interface {
|
||||
Handle(GetDirectPVVolumeListParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetDirectPVVolumeList creates a new http.Handler for the get direct p v volume list operation
|
||||
func NewGetDirectPVVolumeList(ctx *middleware.Context, handler GetDirectPVVolumeListHandler) *GetDirectPVVolumeList {
|
||||
return &GetDirectPVVolumeList{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* GetDirectPVVolumeList swagger:route GET /directpv/volumes OperatorAPI getDirectPVVolumeList
|
||||
|
||||
Get directpv volumes list
|
||||
|
||||
*/
|
||||
type GetDirectPVVolumeList struct {
|
||||
Context *middleware.Context
|
||||
Handler GetDirectPVVolumeListHandler
|
||||
}
|
||||
|
||||
func (o *GetDirectPVVolumeList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetDirectPVVolumeListParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetDirectPVVolumeListParams creates a new GetDirectPVVolumeListParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetDirectPVVolumeListParams() GetDirectPVVolumeListParams {
|
||||
|
||||
return GetDirectPVVolumeListParams{}
|
||||
}
|
||||
|
||||
// GetDirectPVVolumeListParams contains all the bound params for the get direct p v volume list operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetDirectPVVolumeList
|
||||
type GetDirectPVVolumeListParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Drives *string
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Nodes *string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetDirectPVVolumeListParams() beforehand.
|
||||
func (o *GetDirectPVVolumeListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qDrives, qhkDrives, _ := qs.GetOK("drives")
|
||||
if err := o.bindDrives(qDrives, qhkDrives, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qNodes, qhkNodes, _ := qs.GetOK("nodes")
|
||||
if err := o.bindNodes(qNodes, qhkNodes, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindDrives binds and validates parameter Drives from query.
|
||||
func (o *GetDirectPVVolumeListParams) bindDrives(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
o.Drives = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindNodes binds and validates parameter Nodes from query.
|
||||
func (o *GetDirectPVVolumeListParams) bindNodes(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
o.Nodes = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetDirectPVVolumeListOKCode is the HTTP code returned for type GetDirectPVVolumeListOK
|
||||
const GetDirectPVVolumeListOKCode int = 200
|
||||
|
||||
/*GetDirectPVVolumeListOK A successful response.
|
||||
|
||||
swagger:response getDirectPVVolumeListOK
|
||||
*/
|
||||
type GetDirectPVVolumeListOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.GetDirectPVVolumeListResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetDirectPVVolumeListOK creates GetDirectPVVolumeListOK with default headers values
|
||||
func NewGetDirectPVVolumeListOK() *GetDirectPVVolumeListOK {
|
||||
|
||||
return &GetDirectPVVolumeListOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get direct p v volume list o k response
|
||||
func (o *GetDirectPVVolumeListOK) WithPayload(payload *models.GetDirectPVVolumeListResponse) *GetDirectPVVolumeListOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get direct p v volume list o k response
|
||||
func (o *GetDirectPVVolumeListOK) SetPayload(payload *models.GetDirectPVVolumeListResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetDirectPVVolumeListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetDirectPVVolumeListDefault Generic error response.
|
||||
|
||||
swagger:response getDirectPVVolumeListDefault
|
||||
*/
|
||||
type GetDirectPVVolumeListDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetDirectPVVolumeListDefault creates GetDirectPVVolumeListDefault with default headers values
|
||||
func NewGetDirectPVVolumeListDefault(code int) *GetDirectPVVolumeListDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetDirectPVVolumeListDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get direct p v volume list default response
|
||||
func (o *GetDirectPVVolumeListDefault) WithStatusCode(code int) *GetDirectPVVolumeListDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get direct p v volume list default response
|
||||
func (o *GetDirectPVVolumeListDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get direct p v volume list default response
|
||||
func (o *GetDirectPVVolumeListDefault) WithPayload(payload *models.Error) *GetDirectPVVolumeListDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get direct p v volume list default response
|
||||
func (o *GetDirectPVVolumeListDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetDirectPVVolumeListDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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/>.
|
||||
//
|
||||
|
||||
package operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// GetDirectPVVolumeListURL generates an URL for the get direct p v volume list operation
|
||||
type GetDirectPVVolumeListURL struct {
|
||||
Drives *string
|
||||
Nodes *string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetDirectPVVolumeListURL) WithBasePath(bp string) *GetDirectPVVolumeListURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetDirectPVVolumeListURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetDirectPVVolumeListURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/directpv/volumes"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
var drivesQ string
|
||||
if o.Drives != nil {
|
||||
drivesQ = *o.Drives
|
||||
}
|
||||
if drivesQ != "" {
|
||||
qs.Set("drives", drivesQ)
|
||||
}
|
||||
|
||||
var nodesQ string
|
||||
if o.Nodes != nil {
|
||||
nodesQ = *o.Nodes
|
||||
}
|
||||
if nodesQ != "" {
|
||||
qs.Set("nodes", nodesQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetDirectPVVolumeListURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetDirectPVVolumeListURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetDirectPVVolumeListURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetDirectPVVolumeListURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetDirectPVVolumeListURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetDirectPVVolumeListURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -68,6 +68,7 @@ type TokenClaims struct {
|
||||
AccountAccessKey string `json:"accountAccessKey,omitempty"`
|
||||
HideMenu bool `json:"hm,omitempty"`
|
||||
ObjectBrowser bool `json:"ob,omitempty"`
|
||||
CustomStyleOB string `json:"customStyleOb,omitempty"`
|
||||
}
|
||||
|
||||
// STSClaims claims struct for STS Token
|
||||
@@ -79,6 +80,7 @@ type STSClaims struct {
|
||||
type SessionFeatures struct {
|
||||
HideMenu bool
|
||||
ObjectBrowser bool
|
||||
CustomStyleOB string
|
||||
}
|
||||
|
||||
// SessionTokenAuthenticate takes a session token, decode it, extract claims and validate the signature
|
||||
@@ -123,7 +125,9 @@ func NewEncryptedTokenForClient(credentials *credentials.Value, accountAccessKey
|
||||
if features != nil {
|
||||
tokenClaims.HideMenu = features.HideMenu
|
||||
tokenClaims.ObjectBrowser = features.ObjectBrowser
|
||||
tokenClaims.CustomStyleOB = features.CustomStyleOB
|
||||
}
|
||||
|
||||
encryptedClaims, err := encryptClaims(tokenClaims)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"react-window-infinite-loader": "^1.0.7",
|
||||
"recharts": "^2.1.1",
|
||||
"superagent": "^6.1.0",
|
||||
"tinycolor2": "^1.4.2",
|
||||
"websocket": "^1.0.31"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -27,12 +27,14 @@ import {
|
||||
globalSetDistributedSetup,
|
||||
operatorMode,
|
||||
selOpMode,
|
||||
setOverrideStyles,
|
||||
setSiteReplicationInfo,
|
||||
userLogged,
|
||||
} from "./systemSlice";
|
||||
import { SRInfoStateType } from "./types";
|
||||
import { AppState, useAppDispatch } from "./store";
|
||||
import { saveSessionResponse } from "./screens/Console/consoleSlice";
|
||||
import { getOverrideColorVariants } from "./utils/stylesUtils";
|
||||
|
||||
interface ProtectedRouteProps {
|
||||
Component: any;
|
||||
@@ -67,6 +69,16 @@ const ProtectedRoute = ({ Component }: ProtectedRouteProps) => {
|
||||
dispatch(directPVMode(!!res.directPV));
|
||||
document.title = "MinIO Operator";
|
||||
}
|
||||
|
||||
if (res.customStyles && res.customStyles !== "") {
|
||||
const overrideColorVariants = getOverrideColorVariants(
|
||||
res.customStyles
|
||||
);
|
||||
|
||||
if (overrideColorVariants !== false) {
|
||||
dispatch(setOverrideStyles(overrideColorVariants));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => setSessionLoading(false));
|
||||
}, [dispatch]);
|
||||
|
||||
168
portal-ui/src/StyleHandler.tsx
Normal file
168
portal-ui/src/StyleHandler.tsx
Normal file
@@ -0,0 +1,168 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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 } from "react";
|
||||
import {
|
||||
StyledEngineProvider,
|
||||
Theme,
|
||||
ThemeProvider,
|
||||
} from "@mui/material/styles";
|
||||
import withStyles from "@mui/styles/withStyles";
|
||||
import theme from "./theme/main";
|
||||
import "react-virtualized/styles.css";
|
||||
import "react-grid-layout/css/styles.css";
|
||||
import "react-resizable/css/styles.css";
|
||||
|
||||
import { generateOverrideTheme } from "./utils/stylesUtils";
|
||||
import "./index.css";
|
||||
import { useSelector } from "react-redux";
|
||||
import { AppState } from "./store";
|
||||
|
||||
declare module "@mui/styles/defaultTheme" {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface DefaultTheme extends Theme {}
|
||||
}
|
||||
|
||||
interface IStyleHandler {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const StyleHandler = ({ children }: IStyleHandler) => {
|
||||
const colorVariants = useSelector(
|
||||
(state: AppState) => state.system.overrideStyles
|
||||
);
|
||||
|
||||
let thm = theme;
|
||||
let globalBody: any = {};
|
||||
let rowColor: any = { color: "#393939" };
|
||||
let detailsListPanel: any = { backgroundColor: "#fff" };
|
||||
|
||||
if (colorVariants) {
|
||||
thm = generateOverrideTheme(colorVariants);
|
||||
|
||||
globalBody = { backgroundColor: colorVariants.backgroundColor };
|
||||
rowColor = { color: colorVariants.fontColor };
|
||||
detailsListPanel = {
|
||||
backgroundColor: colorVariants.backgroundColor,
|
||||
color: colorVariants.fontColor,
|
||||
};
|
||||
}
|
||||
|
||||
const GlobalCss = withStyles({
|
||||
// @global is handled by jss-plugin-global.
|
||||
"@global": {
|
||||
body: {
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
fontFamily: "Lato, sans-serif",
|
||||
...globalBody,
|
||||
},
|
||||
"#root": {
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexFlow: "column",
|
||||
alignItems: "stretch",
|
||||
},
|
||||
".min-icon": {
|
||||
width: 26,
|
||||
},
|
||||
".MuiButton-endIcon": {
|
||||
"& .min-icon": {
|
||||
width: 16,
|
||||
},
|
||||
},
|
||||
// You should target [class*="MuiButton-root"] instead if you nest themes.
|
||||
".MuiButton-root:not(.noDefaultHeight)": {
|
||||
height: 38,
|
||||
},
|
||||
".MuiButton-contained": {
|
||||
fontSize: "14px",
|
||||
textTransform: "capitalize",
|
||||
padding: "15px 25px 15px 25px",
|
||||
borderRadius: 3,
|
||||
},
|
||||
".MuiButton-sizeSmall": {
|
||||
padding: "4px 10px",
|
||||
fontSize: "0.8125rem",
|
||||
},
|
||||
".MuiTableCell-head": {
|
||||
borderRadius: "3px 3px 0px 0px",
|
||||
fontSize: 13,
|
||||
},
|
||||
".MuiPaper-root": {
|
||||
borderRadius: 3,
|
||||
},
|
||||
".MuiDrawer-paperAnchorDockedLeft": {
|
||||
borderRight: 0,
|
||||
},
|
||||
".MuiDrawer-root": {
|
||||
"& .MuiPaper-root": {
|
||||
borderRadius: 0,
|
||||
},
|
||||
},
|
||||
".rowLine": {
|
||||
...rowColor,
|
||||
},
|
||||
".detailsListPanel": {
|
||||
...detailsListPanel,
|
||||
},
|
||||
hr: {
|
||||
borderTop: 0,
|
||||
borderLeft: 0,
|
||||
borderRight: 0,
|
||||
borderColor: "#999999",
|
||||
backgroundColor: "transparent" as const,
|
||||
},
|
||||
ul: {
|
||||
paddingLeft: 20,
|
||||
listStyle: "none" /* Remove default bullets */,
|
||||
"& li::before:not(.Mui*)": {
|
||||
content: '"■"',
|
||||
color: "#2781B0",
|
||||
fontSize: 20,
|
||||
display:
|
||||
"inline-block" /* Needed to add space between the bullet and the text */,
|
||||
width: "1em" /* Also needed for space (tweak if needed) */,
|
||||
marginLeft: "-1em" /* Also needed for space (tweak if needed) */,
|
||||
},
|
||||
"& ul": {
|
||||
listStyle: "none" /* Remove default bullets */,
|
||||
"& li::before:not(.Mui*)": {
|
||||
content: '"○"',
|
||||
color: "#2781B0",
|
||||
fontSize: 20,
|
||||
display:
|
||||
"inline-block" /* Needed to add space between the bullet and the text */,
|
||||
width: "1em" /* Also needed for space (tweak if needed) */,
|
||||
marginLeft: "-1em" /* Also needed for space (tweak if needed) */,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})(() => null);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<GlobalCss />
|
||||
<StyledEngineProvider injectFirst>
|
||||
<ThemeProvider theme={thm}>{children}</ThemeProvider>
|
||||
</StyledEngineProvider>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default StyleHandler;
|
||||
@@ -462,3 +462,18 @@ export interface IBytesCalc {
|
||||
total: number;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export interface IEmbeddedCustomButton {
|
||||
backgroundColor?: string;
|
||||
textColor?: string;
|
||||
hoverColor?: string;
|
||||
hoverText?: string;
|
||||
activeColor?: string;
|
||||
activeText?: string;
|
||||
}
|
||||
|
||||
export interface IEmbeddedCustomStyles {
|
||||
backgroundColor: string;
|
||||
fontColor: string;
|
||||
buttonStyles: IEmbeddedCustomButton;
|
||||
}
|
||||
|
||||
@@ -15,117 +15,12 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React from "react";
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { Provider } from "react-redux";
|
||||
import { store } from "./store";
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import {
|
||||
StyledEngineProvider,
|
||||
Theme,
|
||||
ThemeProvider,
|
||||
} from "@mui/material/styles";
|
||||
import withStyles from "@mui/styles/withStyles";
|
||||
import "react-virtualized/styles.css";
|
||||
import "react-grid-layout/css/styles.css";
|
||||
import "react-resizable/css/styles.css";
|
||||
|
||||
import "./index.css";
|
||||
import theme from "./theme/main";
|
||||
import MainRouter from "./MainRouter";
|
||||
|
||||
declare module "@mui/styles/defaultTheme" {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface DefaultTheme extends Theme {}
|
||||
}
|
||||
|
||||
const GlobalCss = withStyles({
|
||||
// @global is handled by jss-plugin-global.
|
||||
"@global": {
|
||||
body: {
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
fontFamily: "Lato, sans-serif",
|
||||
},
|
||||
"#root": {
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexFlow: "column",
|
||||
alignItems: "stretch",
|
||||
},
|
||||
".min-icon": {
|
||||
// height: 26,
|
||||
width: 26,
|
||||
},
|
||||
".MuiButton-endIcon": {
|
||||
"& .min-icon": {
|
||||
// height: 26,
|
||||
width: 16,
|
||||
},
|
||||
},
|
||||
// You should target [class*="MuiButton-root"] instead if you nest themes.
|
||||
".MuiButton-root:not(.noDefaultHeight)": {
|
||||
height: 38,
|
||||
},
|
||||
".MuiButton-contained": {
|
||||
fontSize: "14px",
|
||||
textTransform: "capitalize",
|
||||
padding: "15px 25px 15px 25px",
|
||||
borderRadius: 3,
|
||||
},
|
||||
".MuiButton-sizeSmall": {
|
||||
padding: "4px 10px",
|
||||
fontSize: "0.8125rem",
|
||||
},
|
||||
".MuiTableCell-head": {
|
||||
borderRadius: "3px 3px 0px 0px",
|
||||
fontSize: 13,
|
||||
},
|
||||
".MuiPaper-root": {
|
||||
borderRadius: 3,
|
||||
},
|
||||
".MuiDrawer-paperAnchorDockedLeft": {
|
||||
borderRight: 0,
|
||||
},
|
||||
".MuiDrawer-root": {
|
||||
"& .MuiPaper-root": {
|
||||
borderRadius: 0,
|
||||
},
|
||||
},
|
||||
hr: {
|
||||
borderTop: 0,
|
||||
borderLeft: 0,
|
||||
borderRight: 0,
|
||||
borderColor: "#999999",
|
||||
backgroundColor: "transparent" as const,
|
||||
},
|
||||
ul: {
|
||||
paddingLeft: 20,
|
||||
listStyle: "none" /* Remove default bullets */,
|
||||
"& li::before:not(.Mui*)": {
|
||||
content: '"■"',
|
||||
color: "#2781B0",
|
||||
fontSize: 20,
|
||||
display:
|
||||
"inline-block" /* Needed to add space between the bullet and the text */,
|
||||
width: "1em" /* Also needed for space (tweak if needed) */,
|
||||
marginLeft: "-1em" /* Also needed for space (tweak if needed) */,
|
||||
},
|
||||
"& ul": {
|
||||
listStyle: "none" /* Remove default bullets */,
|
||||
"& li::before:not(.Mui*)": {
|
||||
content: '"○"',
|
||||
color: "#2781B0",
|
||||
fontSize: 20,
|
||||
display:
|
||||
"inline-block" /* Needed to add space between the bullet and the text */,
|
||||
width: "1em" /* Also needed for space (tweak if needed) */,
|
||||
marginLeft: "-1em" /* Also needed for space (tweak if needed) */,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})(() => null);
|
||||
import StyleHandler from "./StyleHandler";
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById("root") as HTMLElement
|
||||
@@ -134,12 +29,9 @@ const root = ReactDOM.createRoot(
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<Provider store={store}>
|
||||
<GlobalCss />
|
||||
<StyledEngineProvider injectFirst>
|
||||
<ThemeProvider theme={theme}>
|
||||
<MainRouter />
|
||||
</ThemeProvider>
|
||||
</StyledEngineProvider>
|
||||
<StyleHandler>
|
||||
<MainRouter />
|
||||
</StyleHandler>
|
||||
</Provider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
} from "../../ObjectBrowser/objectBrowserSlice";
|
||||
import SearchBox from "../../Common/SearchBox";
|
||||
import { selFeatures } from "../../consoleSlice";
|
||||
import { LoginMinIOLogo } from "../../../../icons";
|
||||
import AutoColorIcon from "../../Common/Components/AutoColorIcon";
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
@@ -150,14 +150,7 @@ const BrowserHandler = () => {
|
||||
}}
|
||||
>
|
||||
<Grid>
|
||||
<LoginMinIOLogo
|
||||
style={{
|
||||
width: 105,
|
||||
marginRight: 30,
|
||||
marginTop: 10,
|
||||
fill: "#081C42",
|
||||
}}
|
||||
/>
|
||||
<AutoColorIcon marginRight={30} marginTop={10} />
|
||||
</Grid>
|
||||
<Grid item xs>
|
||||
{searchBar}
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
AddIcon,
|
||||
BucketsIcon,
|
||||
LifecycleConfigIcon,
|
||||
LoginMinIOLogo,
|
||||
SelectAllIcon,
|
||||
} from "../../../../icons";
|
||||
import {
|
||||
@@ -60,6 +59,7 @@ import { setErrorSnackMessage } from "../../../../systemSlice";
|
||||
import { useAppDispatch } from "../../../../store";
|
||||
import { useSelector } from "react-redux";
|
||||
import { selFeatures } from "../../consoleSlice";
|
||||
import AutoColorIcon from "../../Common/Components/AutoColorIcon";
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
@@ -223,14 +223,7 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
|
||||
<Grid item xs={12} className={classes.actionsTray} display="flex">
|
||||
{obOnly && (
|
||||
<Grid item xs>
|
||||
<LoginMinIOLogo
|
||||
style={{
|
||||
width: 105,
|
||||
marginRight: 15,
|
||||
marginTop: 10,
|
||||
fill: "#081C42",
|
||||
}}
|
||||
/>
|
||||
<AutoColorIcon marginRight={15} marginTop={10} />
|
||||
</Grid>
|
||||
)}
|
||||
<SearchBox
|
||||
|
||||
@@ -17,23 +17,21 @@
|
||||
import React from "react";
|
||||
import { Theme } from "@mui/material/styles";
|
||||
import createStyles from "@mui/styles/createStyles";
|
||||
import withStyles from "@mui/styles/withStyles";
|
||||
import { Grid, IconButton } from "@mui/material";
|
||||
import { ClosePanelIcon } from "../../../../../../icons";
|
||||
import makeStyles from "@mui/styles/makeStyles";
|
||||
|
||||
interface IDetailsListPanel {
|
||||
classes: any;
|
||||
open: boolean;
|
||||
className?: string;
|
||||
closePanel: () => void;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
detailsList: {
|
||||
borderColor: "#EAEDEE",
|
||||
backgroundColor: "#fff",
|
||||
borderWidth: 0,
|
||||
borderStyle: "solid",
|
||||
borderRadius: 3,
|
||||
@@ -68,19 +66,23 @@ const styles = (theme: Theme) =>
|
||||
width: 14,
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const DetailsListPanel = ({
|
||||
classes,
|
||||
open,
|
||||
closePanel,
|
||||
className = "",
|
||||
children,
|
||||
}: IDetailsListPanel) => {
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<Grid
|
||||
item
|
||||
className={`${classes.detailsList} ${open ? "open" : ""} ${className}`}
|
||||
className={`${classes.detailsList} ${
|
||||
open ? "open" : ""
|
||||
} ${className} detailsListPanel`}
|
||||
>
|
||||
<IconButton onClick={closePanel} className={classes.closePanel}>
|
||||
<ClosePanelIcon />
|
||||
@@ -90,4 +92,4 @@ const DetailsListPanel = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default withStyles(styles)(DetailsListPanel);
|
||||
export default DetailsListPanel;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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 from "react";
|
||||
import { LoginMinIOLogo } from "../../../../icons";
|
||||
import { useSelector } from "react-redux";
|
||||
import { AppState } from "../../../../store";
|
||||
|
||||
interface IAutoColorIcon {
|
||||
marginRight: number;
|
||||
marginTop: number;
|
||||
}
|
||||
|
||||
const AutoColorIcon = ({ marginRight, marginTop }: IAutoColorIcon) => {
|
||||
let tinycolor = require("tinycolor2");
|
||||
|
||||
const colorVariants = useSelector(
|
||||
(state: AppState) => state.system.overrideStyles
|
||||
);
|
||||
|
||||
const isDark =
|
||||
tinycolor(colorVariants?.backgroundColor || "#fff").getBrightness() <= 128;
|
||||
|
||||
return (
|
||||
<LoginMinIOLogo
|
||||
style={{
|
||||
width: 105,
|
||||
marginRight,
|
||||
marginTop,
|
||||
fill: isDark ? "#fff" : "#081C42",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default AutoColorIcon;
|
||||
@@ -172,7 +172,6 @@ const styles = () =>
|
||||
".rowLine": {
|
||||
borderBottom: `1px solid ${borderColor}`,
|
||||
height: 40,
|
||||
color: "#393939",
|
||||
fontSize: 14,
|
||||
transitionDuration: 0.3,
|
||||
"&:focus": {
|
||||
|
||||
@@ -221,6 +221,7 @@ const BasicDashboard = ({ usage }: IDashboardProps) => {
|
||||
<Link
|
||||
to={IAM_PAGES.BUCKETS}
|
||||
style={{
|
||||
zIndex: 999,
|
||||
textDecoration: "none",
|
||||
top: "40px",
|
||||
position: "relative",
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
//
|
||||
// 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 { Fragment, useEffect, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
ICloseEvent,
|
||||
IMessageEvent,
|
||||
@@ -72,19 +73,19 @@ const styles = (theme: Theme) =>
|
||||
textAlign: "center",
|
||||
marginBottom: 10,
|
||||
},
|
||||
startDiagnostic: {
|
||||
textAlign: "center",
|
||||
marginBottom: 25,
|
||||
},
|
||||
progressResult: {
|
||||
textAlign: "center",
|
||||
marginBottom: 25,
|
||||
},
|
||||
diagNew: {
|
||||
startDiagnostic: {
|
||||
textAlign: "right",
|
||||
margin: 25,
|
||||
marginBottom: 0,
|
||||
},
|
||||
startDiagnosticCenter: {
|
||||
textAlign: "center",
|
||||
marginTop: 0,
|
||||
},
|
||||
...actionsTray,
|
||||
...containerForHeader(theme.spacing(4)),
|
||||
});
|
||||
@@ -104,12 +105,17 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
(state: AppState) => state.system.serverDiagnosticStatus
|
||||
);
|
||||
const [startDiagnostic, setStartDiagnostic] = useState(false);
|
||||
const [diagStarted, setDiagStarted] = useState<boolean>(false);
|
||||
const [downloadDisabled, setDownloadDisabled] = useState(true);
|
||||
const [localMessage, setMessage] = useState<string>("");
|
||||
const [buttonStartText, setButtonStartText] =
|
||||
useState<string>("Start Diagnostic");
|
||||
const [title, setTitle] = useState<string>("New Diagnostic");
|
||||
const [diagFileContent, setDiagFileContent] = useState<string>("");
|
||||
|
||||
const isDiagnosticComplete =
|
||||
serverDiagnosticStatus === DiagStatSuccess ||
|
||||
serverDiagnosticStatus === DiagStatError;
|
||||
|
||||
const download = () => {
|
||||
let element = document.createElement("a");
|
||||
element.setAttribute(
|
||||
@@ -129,19 +135,26 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
useEffect(() => {
|
||||
if (serverDiagnosticStatus === DiagStatInProgress) {
|
||||
setTitle("Diagnostic in progress...");
|
||||
setMessage(
|
||||
"Diagnostic started. Please do not refresh page during diagnosis."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverDiagnosticStatus === DiagStatSuccess && diagStarted) {
|
||||
if (serverDiagnosticStatus === DiagStatSuccess) {
|
||||
setTitle("Diagnostic complete");
|
||||
setMessage("Diagnostic file is ready to be downloaded.");
|
||||
setButtonStartText("Start New Diagnostic");
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverDiagnosticStatus === DiagStatError) {
|
||||
setTitle("Error");
|
||||
setMessage("An error occurred while getting the Diagnostic file.");
|
||||
setButtonStartText("Retry Diagnostic");
|
||||
return;
|
||||
}
|
||||
}, [serverDiagnosticStatus, startDiagnostic, diagStarted]);
|
||||
}, [serverDiagnosticStatus, startDiagnostic]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -186,7 +199,6 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
interval = setInterval(() => {
|
||||
c.send("ok");
|
||||
}, 10 * 1000);
|
||||
setDiagStarted(true);
|
||||
setMessage(
|
||||
"Diagnostic started. Please do not refresh page during diagnosis."
|
||||
);
|
||||
@@ -219,7 +231,7 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
) {
|
||||
// handle close with error
|
||||
console.log("connection closed by server with code:", event.code);
|
||||
setMessage("An error occurred while getting Diagnostic file.");
|
||||
setMessage("An error occurred while getting the Diagnostic file.");
|
||||
dispatch(setServerDiagStat(DiagStatError));
|
||||
} else {
|
||||
console.log("connection closed by server");
|
||||
@@ -242,39 +254,21 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
<Grid item xs={12} className={classes.boxy}>
|
||||
<TestWrapper title={title} advancedVisible={false}>
|
||||
<Grid container className={classes.buttons}>
|
||||
{!diagStarted && (
|
||||
<Grid
|
||||
key="start-diag"
|
||||
item
|
||||
xs={12}
|
||||
className={classes.startDiagnostic}
|
||||
>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={startDiagnostic}
|
||||
onClick={() => setStartDiagnostic(true)}
|
||||
>
|
||||
Start Diagnostic
|
||||
</Button>
|
||||
</Grid>
|
||||
)}
|
||||
{diagStarted && (
|
||||
<Grid
|
||||
key="start-download"
|
||||
item
|
||||
xs={12}
|
||||
className={classes.progressResult}
|
||||
>
|
||||
<div className={classes.localMessage}>{localMessage}</div>
|
||||
{serverDiagnosticStatus === DiagStatInProgress ? (
|
||||
<div className={classes.loading}>
|
||||
<Loader style={{ width: 25, height: 25 }} />
|
||||
</div>
|
||||
) : (
|
||||
<Fragment>
|
||||
{serverDiagnosticStatus !== DiagStatError && (
|
||||
<Grid
|
||||
key="start-download"
|
||||
item
|
||||
xs={12}
|
||||
className={classes.progressResult}
|
||||
>
|
||||
<div className={classes.localMessage}>{localMessage}</div>
|
||||
{serverDiagnosticStatus === DiagStatInProgress ? (
|
||||
<div className={classes.loading}>
|
||||
<Loader style={{ width: 25, height: 25 }} />
|
||||
</div>
|
||||
) : (
|
||||
<Fragment>
|
||||
{serverDiagnosticStatus !== DiagStatError &&
|
||||
!downloadDisabled && (
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
@@ -285,31 +279,36 @@ const HealthInfo = ({ classes }: IHealthInfo) => {
|
||||
Download
|
||||
</Button>
|
||||
)}
|
||||
<Grid item xs={12} className={classes.diagNew}>
|
||||
<Button
|
||||
id="start-new-diagnostic"
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={startDiagnostic}
|
||||
onClick={() => setStartDiagnostic(true)}
|
||||
>
|
||||
Start New Diagnostic
|
||||
</Button>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
)}
|
||||
</Grid>
|
||||
)}
|
||||
<Grid
|
||||
item
|
||||
xs={12}
|
||||
className={clsx(classes.startDiagnostic, {
|
||||
[classes.startDiagnosticCenter]: !isDiagnosticComplete,
|
||||
})}
|
||||
>
|
||||
<Button
|
||||
id="start-new-diagnostic"
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={startDiagnostic}
|
||||
onClick={() => setStartDiagnostic(true)}
|
||||
>
|
||||
{buttonStartText}
|
||||
</Button>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TestWrapper>
|
||||
</Grid>
|
||||
{!diagStarted && (
|
||||
{!startDiagnostic && (
|
||||
<Fragment>
|
||||
<br />
|
||||
<HelpBox
|
||||
title={
|
||||
"During the health diagnostics run all production traffic will be suspended."
|
||||
"During the health diagnostics run, all production traffic will be suspended."
|
||||
}
|
||||
iconComponent={<WarnIcon />}
|
||||
help={<Fragment />}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from "react";
|
||||
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
|
||||
import { ConfirmModalIcon } from "../../../icons";
|
||||
import { DialogContentText } from "@mui/material";
|
||||
|
||||
const ConfirmDeleteTargetModal = ({
|
||||
onConfirm,
|
||||
onClose,
|
||||
serviceName,
|
||||
status,
|
||||
}: {
|
||||
onConfirm: () => void;
|
||||
onClose: () => void;
|
||||
serviceName: string;
|
||||
status: string;
|
||||
}) => {
|
||||
return (
|
||||
<ConfirmDialog
|
||||
title={`Delete Endpoint`}
|
||||
confirmText={"Delete"}
|
||||
isOpen={true}
|
||||
titleIcon={<ConfirmModalIcon />}
|
||||
isLoading={false}
|
||||
onConfirm={onConfirm}
|
||||
onClose={onClose}
|
||||
confirmationContent={
|
||||
<React.Fragment>
|
||||
<DialogContentText>
|
||||
Are you sure you want to delete the notification endpoint ?
|
||||
<br />
|
||||
<b>{serviceName}</b> which is <b>{status}</b>
|
||||
</DialogContentText>
|
||||
</React.Fragment>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConfirmDeleteTargetModal;
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
NotificationEndpointsList,
|
||||
TransformedEndpointItem,
|
||||
} from "./types";
|
||||
import { notificationTransform } from "./utils";
|
||||
import { getNotificationConfigKey, notificationTransform } from "./utils";
|
||||
import { AddIcon, LambdaIcon } from "../../../icons";
|
||||
import TableWrapper from "../Common/TableWrapper/TableWrapper";
|
||||
|
||||
@@ -49,8 +49,12 @@ import PageLayout from "../Common/Layout/PageLayout";
|
||||
import SearchBox from "../Common/SearchBox";
|
||||
import RBIconButton from "../Buckets/BucketDetails/SummaryItems/RBIconButton";
|
||||
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
|
||||
import { setErrorSnackMessage } from "../../../systemSlice";
|
||||
import {
|
||||
setErrorSnackMessage,
|
||||
setServerNeedsRestart,
|
||||
} from "../../../systemSlice";
|
||||
import { useAppDispatch } from "../../../store";
|
||||
import ConfirmDeleteTargetModal from "./ConfirmDeleteTargetModal";
|
||||
|
||||
interface IListNotificationEndpoints {
|
||||
classes: any;
|
||||
@@ -88,6 +92,10 @@ const ListNotificationEndpoints = ({ classes }: IListNotificationEndpoints) => {
|
||||
const [filter, setFilter] = useState<string>("");
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
|
||||
const [isDelConfirmOpen, setIsDelConfirmOpen] = useState<boolean>(false);
|
||||
const [selNotifyEndPoint, setSelNotifyEndpoint] =
|
||||
useState<TransformedEndpointItem | null>();
|
||||
|
||||
//Effects
|
||||
// load records on mount
|
||||
useEffect(() => {
|
||||
@@ -116,6 +124,39 @@ const ListNotificationEndpoints = ({ classes }: IListNotificationEndpoints) => {
|
||||
setIsLoading(true);
|
||||
}, []);
|
||||
|
||||
const resetNotificationConfig = (
|
||||
ep: TransformedEndpointItem | undefined | null
|
||||
) => {
|
||||
if (ep?.name) {
|
||||
const configKey = getNotificationConfigKey(ep.name);
|
||||
let accountId = `:${ep.account_id}`;
|
||||
if (configKey) {
|
||||
api
|
||||
.invoke("POST", `/api/v1/configs/${configKey}${accountId}/reset`)
|
||||
.then((res) => {
|
||||
dispatch(setServerNeedsRestart(true));
|
||||
setSelNotifyEndpoint(null);
|
||||
setIsDelConfirmOpen(false);
|
||||
})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
setIsDelConfirmOpen(false);
|
||||
dispatch(setErrorSnackMessage(err));
|
||||
});
|
||||
} else {
|
||||
setSelNotifyEndpoint(null);
|
||||
setIsDelConfirmOpen(false);
|
||||
console.log(`Unable to find Config key for ${ep.name}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const confirmDelNotifyEndpoint = (record: TransformedEndpointItem) => {
|
||||
setSelNotifyEndpoint(record);
|
||||
setIsDelConfirmOpen(true);
|
||||
};
|
||||
|
||||
const tableActions = [{ type: "delete", onClick: confirmDelNotifyEndpoint }];
|
||||
|
||||
const filteredRecords = records.filter((b: TransformedEndpointItem) => {
|
||||
if (filter === "") {
|
||||
return true;
|
||||
@@ -180,7 +221,7 @@ const ListNotificationEndpoints = ({ classes }: IListNotificationEndpoints) => {
|
||||
<Fragment>
|
||||
<Grid item xs={12} className={classes.tableBlock}>
|
||||
<TableWrapper
|
||||
itemActions={[]}
|
||||
itemActions={tableActions}
|
||||
columns={[
|
||||
{
|
||||
label: "Status",
|
||||
@@ -262,6 +303,19 @@ const ListNotificationEndpoints = ({ classes }: IListNotificationEndpoints) => {
|
||||
)}
|
||||
</Fragment>
|
||||
)}
|
||||
|
||||
{isDelConfirmOpen ? (
|
||||
<ConfirmDeleteTargetModal
|
||||
onConfirm={() => {
|
||||
resetNotificationConfig(selNotifyEndPoint);
|
||||
}}
|
||||
status={`${selNotifyEndPoint?.status}`}
|
||||
serviceName={`${selNotifyEndPoint?.service_name}`}
|
||||
onClose={() => {
|
||||
setIsDelConfirmOpen(false);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</PageLayout>
|
||||
</Fragment>
|
||||
);
|
||||
|
||||
@@ -29,6 +29,8 @@ export interface NotificationEndpointItem {
|
||||
export interface TransformedEndpointItem {
|
||||
service_name: string;
|
||||
status: string;
|
||||
name: string;
|
||||
account_id: string;
|
||||
}
|
||||
|
||||
export interface NotificationEndpointsList {
|
||||
|
||||
@@ -35,6 +35,8 @@ export const notificationTransform = (
|
||||
return notificationElements.map((element) => {
|
||||
return {
|
||||
service_name: `${element.service}:${element.account_id}`,
|
||||
name: element.service,
|
||||
account_id: element.account_id,
|
||||
status: element.status,
|
||||
};
|
||||
});
|
||||
@@ -558,3 +560,20 @@ export const notificationEndpointsFields: any = {
|
||||
...commonFields,
|
||||
],
|
||||
};
|
||||
|
||||
const serviceToConfigMap: Record<string, string> = {
|
||||
webhook: "notify_webhook",
|
||||
amqp: "notify_amqp",
|
||||
kafka: "notify_kafka",
|
||||
mqtt: "notify_mqtt",
|
||||
nats: "notify_nats",
|
||||
nsq: "notify_nsq",
|
||||
mysql: "notify_mysql",
|
||||
postgresql: "notify_postgres", //looks different in server response(postgresql as opposed to postgres) from restapi/admin_notification_endpoints.go
|
||||
elasticsearch: "notify_elasticsearch",
|
||||
redis: "notify_redis",
|
||||
};
|
||||
|
||||
export const getNotificationConfigKey = (serviceName: string) => {
|
||||
return serviceToConfigMap[serviceName];
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ const ApiKeyRegister = ({
|
||||
>
|
||||
<FormTitle
|
||||
icon={<OnlineRegistrationIcon />}
|
||||
title={`API key activation of MinIO Subscription Network License`}
|
||||
title={`Register cluster with API key`}
|
||||
/>
|
||||
</Box>
|
||||
<Box
|
||||
|
||||
@@ -644,7 +644,7 @@ const Register = ({ classes }: IRegister) => {
|
||||
>
|
||||
<FormTitle
|
||||
icon={<OfflineRegistrationIcon />}
|
||||
title={`Offline activation of MinIO Subscription Network License`}
|
||||
title={`Register cluster in an Airgap environment`}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
@@ -849,17 +849,17 @@ const Register = ({ classes }: IRegister) => {
|
||||
scrollButtons="auto"
|
||||
>
|
||||
<Tab
|
||||
label="Online Activation"
|
||||
label="Credentials"
|
||||
id="simple-tab-0"
|
||||
aria-controls="simple-tabpanel-0"
|
||||
/>
|
||||
<Tab
|
||||
label="API Key Activation"
|
||||
label="API Key"
|
||||
id="simple-tab-1"
|
||||
aria-controls="simple-tabpanel-1"
|
||||
/>
|
||||
<Tab
|
||||
label="Offline Activation"
|
||||
label="Airgap"
|
||||
id="simple-tab-2"
|
||||
aria-controls="simple-tabpanel-2"
|
||||
onClick={() => fetchSubnetRegToken()}
|
||||
|
||||
@@ -169,7 +169,7 @@ const RegisterOperator = ({ classes }: IRegister) => {
|
||||
scrollButtons="auto"
|
||||
>
|
||||
<Tab
|
||||
label="API Key Activation"
|
||||
label="API Key"
|
||||
id="simple-tab-0"
|
||||
aria-controls="simple-tabpanel-1"
|
||||
/>
|
||||
|
||||
@@ -30,6 +30,7 @@ const initialState: ConsoleState = {
|
||||
distributedMode: false,
|
||||
permissions: {},
|
||||
allowResources: null,
|
||||
customStyles: null,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -32,4 +32,5 @@ export interface ISessionResponse {
|
||||
distributedMode: boolean;
|
||||
permissions: ISessionPermissions;
|
||||
allowResources: IAllowResources[] | null;
|
||||
customStyles?: string | null;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { snackBarMessage, SRInfoStateType } from "./types";
|
||||
import { ErrorResponseHandler } from "./common/types";
|
||||
import { ErrorResponseHandler, IEmbeddedCustomStyles } from "./common/types";
|
||||
import { AppState } from "./store";
|
||||
import { SubnetInfo } from "./screens/Console/License/types";
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface SystemState {
|
||||
distributedSetup: boolean;
|
||||
siteReplicationInfo: SRInfoStateType;
|
||||
licenseInfo: null | SubnetInfo;
|
||||
overrideStyles: null | IEmbeddedCustomStyles;
|
||||
}
|
||||
|
||||
const initialState: SystemState = {
|
||||
@@ -70,6 +71,7 @@ const initialState: SystemState = {
|
||||
serverDiagnosticStatus: "",
|
||||
distributedSetup: false,
|
||||
licenseInfo: null,
|
||||
overrideStyles: null,
|
||||
};
|
||||
|
||||
export const systemSlice = createSlice({
|
||||
@@ -151,6 +153,12 @@ export const systemSlice = createSlice({
|
||||
setLicenseInfo: (state, action: PayloadAction<SubnetInfo | null>) => {
|
||||
state.licenseInfo = action.payload;
|
||||
},
|
||||
setOverrideStyles: (
|
||||
state,
|
||||
action: PayloadAction<IEmbeddedCustomStyles>
|
||||
) => {
|
||||
state.overrideStyles = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -172,6 +180,7 @@ export const {
|
||||
globalSetDistributedSetup,
|
||||
setSiteReplicationInfo,
|
||||
setLicenseInfo,
|
||||
setOverrideStyles,
|
||||
} = systemSlice.actions;
|
||||
|
||||
export const selDistSet = (state: AppState) => state.system.distributedSetup;
|
||||
|
||||
152
portal-ui/src/utils/stylesUtils.ts
Normal file
152
portal-ui/src/utils/stylesUtils.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
// 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 { IEmbeddedCustomStyles } from "../common/types";
|
||||
import { createTheme } from "@mui/material";
|
||||
|
||||
export const getOverrideColorVariants: (
|
||||
customStyles: string
|
||||
) => false | IEmbeddedCustomStyles = (customStyles) => {
|
||||
try {
|
||||
return JSON.parse(atob(customStyles)) as IEmbeddedCustomStyles;
|
||||
} catch (e) {
|
||||
console.error("Error processing override styles, skipping.", e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const generateOverrideTheme = (overrideVars: IEmbeddedCustomStyles) => {
|
||||
const theme = createTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
light: overrideVars.buttonStyles.hoverColor || "#073052",
|
||||
main: overrideVars.buttonStyles.backgroundColor || "#081C42",
|
||||
dark: overrideVars.buttonStyles.activeColor || "#05122B",
|
||||
contrastText: overrideVars.buttonStyles.textColor || "#fff",
|
||||
},
|
||||
secondary: {
|
||||
light: "#ff7961",
|
||||
main: "#f44336",
|
||||
dark: "#ba000d",
|
||||
contrastText: "#000",
|
||||
},
|
||||
background: {
|
||||
default: overrideVars.backgroundColor,
|
||||
},
|
||||
success: {
|
||||
main: "#4ccb92",
|
||||
},
|
||||
warning: {
|
||||
main: "#FFBD62",
|
||||
},
|
||||
error: {
|
||||
light: "#e03a48",
|
||||
main: "#C83B51",
|
||||
contrastText: "#fff",
|
||||
},
|
||||
},
|
||||
typography: {
|
||||
fontFamily: ["Lato", "sans-serif"].join(","),
|
||||
h1: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
h2: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
h3: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
h4: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
h5: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
h6: {
|
||||
fontWeight: "bold",
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
MuiButton: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
textTransform: "none",
|
||||
borderRadius: 3,
|
||||
height: 40,
|
||||
padding: "0 20px",
|
||||
fontSize: 14,
|
||||
fontWeight: 600,
|
||||
boxShadow: "none",
|
||||
"& .min-icon": {
|
||||
maxHeight: 18,
|
||||
},
|
||||
"&.MuiButton-contained.Mui-disabled": {
|
||||
backgroundColor: "#EAEDEE",
|
||||
fontWeight: 600,
|
||||
color: "#767676",
|
||||
},
|
||||
"& .MuiButton-iconSizeMedium > *:first-of-type": {
|
||||
fontSize: 12,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiPaper: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
backgroundColor: overrideVars.backgroundColor,
|
||||
color: overrideVars.fontColor,
|
||||
},
|
||||
elevation1: {
|
||||
boxShadow: "none",
|
||||
border: "#EAEDEE 1px solid",
|
||||
borderRadius: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiListItem: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
"&.MuiListItem-root.Mui-selected": {
|
||||
background: "inherit",
|
||||
"& .MuiTypography-root": {
|
||||
fontWeight: "bold",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiTab: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
textTransform: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
link: "#2781B0",
|
||||
},
|
||||
});
|
||||
|
||||
return theme;
|
||||
};
|
||||
@@ -264,7 +264,7 @@ const checkLoggingToggle = async (tenantName: string) => {
|
||||
await t
|
||||
.click("#tenant_logging")
|
||||
.click("#confirm-ok")
|
||||
.wait(1000)
|
||||
.wait(3000)
|
||||
.expect(Selector("#image").exists)
|
||||
.notOk()
|
||||
.click("#yaml_button")
|
||||
@@ -277,7 +277,7 @@ const checkLoggingToggle = async (tenantName: string) => {
|
||||
.click(Selector(`a[href$="/logging"]`))
|
||||
.click("#tenant_logging")
|
||||
.click("#confirm-ok")
|
||||
.wait(1000)
|
||||
.wait(3000)
|
||||
.expect(Selector("#image").exists)
|
||||
.ok()
|
||||
.click("#yaml_button")
|
||||
@@ -291,6 +291,7 @@ const checkLoggingToggle = async (tenantName: string) => {
|
||||
const checkLoggingFieldsAcceptValues = async (tenantName: string) => {
|
||||
await goToLoggingSection(tenantName);
|
||||
await t
|
||||
.wait(3000)
|
||||
.typeText("#image", "minio/operator:v4.4.22", { replace: true })
|
||||
.typeText("#diskCapacityGB", "3", { replace: true })
|
||||
.typeText("#cpuRequest", "3", { replace: true })
|
||||
|
||||
@@ -63,7 +63,7 @@ test("Download button exists after Diagnostic is completed", async (t) => {
|
||||
// Only proceed if there is no error
|
||||
const matchingElement = ClientFunction(() =>
|
||||
document.evaluate(
|
||||
"//div[text()='An error occurred while getting Diagnostic file.']",
|
||||
"//div[text()='An error occurred while getting the Diagnostic file.']",
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
@@ -87,7 +87,7 @@ test("Download button is clickable after Diagnostic is completed", async (t) =>
|
||||
// Only proceed if there is no error
|
||||
const matchingElement = ClientFunction(() =>
|
||||
document.evaluate(
|
||||
"//div[text()='An error occurred while getting Diagnostic file.']",
|
||||
"//div[text()='An error occurred while getting the Diagnostic file.']",
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
@@ -111,7 +111,7 @@ test("Start New Diagnostic button exists after Diagnostic is completed", async (
|
||||
// Only proceed if there is no error
|
||||
const matchingElement = ClientFunction(() =>
|
||||
document.evaluate(
|
||||
"//div[text()='An error occurred while getting Diagnostic file.']",
|
||||
"//div[text()='An error occurred while getting the Diagnostic file.']",
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
@@ -139,7 +139,7 @@ test("Start New Diagnostic button is clickable after Diagnostic is completed", a
|
||||
// Only proceed if there is no error
|
||||
const matchingElement = ClientFunction(() =>
|
||||
document.evaluate(
|
||||
"//div[text()='An error occurred while getting Diagnostic file.']",
|
||||
"//div[text()='An error occurred while getting the Diagnostic file.']",
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
|
||||
@@ -11038,6 +11038,11 @@ tiny-warning@^1.0.2, tiny-warning@^1.0.3:
|
||||
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
|
||||
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==
|
||||
|
||||
tinycolor2@^1.4.2:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.2.tgz#3f6a4d1071ad07676d7fa472e1fac40a719d8803"
|
||||
integrity sha512-vJhccZPs965sV/L2sU4oRQVAos0pQXwsvTLkWYdqJ+a8Q5kPFzJTuOFwy7UniPli44NKQGAglksjvOcpo95aZA==
|
||||
|
||||
tmp-promise@^1.0.5:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-1.1.0.tgz#bb924d239029157b9bc1d506a6aa341f8b13e64c"
|
||||
|
||||
@@ -95,6 +95,7 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
AccountAccessKey: claims.AccountAccessKey,
|
||||
Hm: claims.HideMenu,
|
||||
Ob: claims.ObjectBrowser,
|
||||
CustomStyleOb: claims.CustomStyleOB,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -355,6 +356,8 @@ func handleSPA(w http.ResponseWriter, r *http.Request) {
|
||||
sts := r.URL.Query().Get("sts")
|
||||
stsAccessKey := r.URL.Query().Get("sts_a")
|
||||
stsSecretKey := r.URL.Query().Get("sts_s")
|
||||
overridenStyles := r.URL.Query().Get("ov_st")
|
||||
|
||||
// if these three parameters are present we are being asked to issue a session with these values
|
||||
if sts != "" && stsAccessKey != "" && stsSecretKey != "" {
|
||||
creds := credentials.NewStaticV4(stsAccessKey, stsSecretKey, sts)
|
||||
@@ -366,6 +369,14 @@ func handleSPA(w http.ResponseWriter, r *http.Request) {
|
||||
sf.HideMenu = true
|
||||
sf.ObjectBrowser = true
|
||||
|
||||
err := ValidateEncodedStyles(overridenStyles)
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
sf.CustomStyleOB = overridenStyles
|
||||
}
|
||||
|
||||
sessionID, err := login(consoleCreds, sf)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
@@ -51,7 +51,6 @@ const (
|
||||
PrometheusExtraLabels = "CONSOLE_PROMETHEUS_EXTRA_LABELS"
|
||||
ConsoleLogQueryURL = "CONSOLE_LOG_QUERY_URL"
|
||||
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
|
||||
ConsoleObjectBrowserOnly = "CONSOLE_OBJECT_BROWSER_ONLY"
|
||||
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
|
||||
SlashSeparator = "/"
|
||||
)
|
||||
|
||||
@@ -6006,6 +6006,9 @@ func init() {
|
||||
"accountAccessKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"customStyleOb": {
|
||||
"type": "string"
|
||||
},
|
||||
"hm": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -6318,6 +6321,9 @@ func init() {
|
||||
"$ref": "#/definitions/permissionResource"
|
||||
}
|
||||
},
|
||||
"customStyles": {
|
||||
"type": "string"
|
||||
},
|
||||
"distributedMode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -13266,6 +13272,9 @@ func init() {
|
||||
"accountAccessKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"customStyleOb": {
|
||||
"type": "string"
|
||||
},
|
||||
"hm": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -13578,6 +13587,9 @@ func init() {
|
||||
"$ref": "#/definitions/permissionResource"
|
||||
}
|
||||
},
|
||||
"customStyles": {
|
||||
"type": "string"
|
||||
},
|
||||
"distributedMode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
@@ -103,6 +103,7 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
|
||||
}
|
||||
currTime := time.Now().UTC()
|
||||
|
||||
customStyles := session.CustomStyleOb
|
||||
// This actions will be global, meaning has to be attached to all resources
|
||||
conditionValues := map[string][]string{
|
||||
condition.AWSUsername.Name(): {session.AccountAccessKey},
|
||||
@@ -244,6 +245,7 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
|
||||
DistributedMode: erasure,
|
||||
Permissions: resourcePermissions,
|
||||
AllowResources: allowResources,
|
||||
CustomStyles: customStyles,
|
||||
}
|
||||
return sessionResp, nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ package restapi
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -40,6 +43,21 @@ import (
|
||||
// more likely then others.
|
||||
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
|
||||
|
||||
type CustomButtonStyle struct {
|
||||
BackgroundColor *string `json:"backgroundColor"`
|
||||
TextColor *string `json:"textColor"`
|
||||
HoverColor *string `json:"hoverColor"`
|
||||
HoverText *string `json:"hoverText"`
|
||||
ActiveColor *string `json:"activeColor"`
|
||||
ActiveText *string `json:"activeText"`
|
||||
}
|
||||
|
||||
type CustomStyles struct {
|
||||
BackgroundColor *string `json:"backgroundColor"`
|
||||
FontColor *string `json:"fontColor"`
|
||||
ButtonStyles *CustomButtonStyle `json:"buttonStyles"`
|
||||
}
|
||||
|
||||
func RandomCharStringWithAlphabet(n int, alphabet string) string {
|
||||
random := make([]byte, n)
|
||||
if _, err := io.ReadFull(rand.Reader, random); err != nil {
|
||||
@@ -130,6 +148,28 @@ func ExpireSessionCookie() http.Cookie {
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateEncodedStyles(encodedStyles string) error {
|
||||
// encodedStyle JSON validation
|
||||
str, err := base64.StdEncoding.DecodeString(encodedStyles)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var styleElements *CustomStyles
|
||||
|
||||
err = json.Unmarshal(str, &styleElements)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if styleElements.BackgroundColor == nil || styleElements.FontColor == nil || styleElements.ButtonStyles == nil {
|
||||
return errors.New("specified style is not in the correct format")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SanitizeEncodedPrefix replaces spaces for + since those are lost when you do GET parameters
|
||||
func SanitizeEncodedPrefix(rawPrefix string) string {
|
||||
return strings.ReplaceAll(rawPrefix, " ", "+")
|
||||
|
||||
@@ -3729,6 +3729,8 @@ definitions:
|
||||
type: boolean
|
||||
ob:
|
||||
type: boolean
|
||||
customStyleOb:
|
||||
type: string
|
||||
startProfilingItem:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3776,6 +3778,8 @@ definitions:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
customStyles:
|
||||
type: string
|
||||
allowResources:
|
||||
type: array
|
||||
items:
|
||||
|
||||
@@ -1496,6 +1496,78 @@ paths:
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/directpv/drives:
|
||||
get:
|
||||
summary: Get directpv drives list
|
||||
operationId: GetDirectPVDriveList
|
||||
parameters:
|
||||
- name: nodes
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
- name: drives
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: "#/definitions/getDirectPVDriveListResponse"
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/directpv/volumes:
|
||||
get:
|
||||
summary: Get directpv volumes list
|
||||
operationId: GetDirectPVVolumeList
|
||||
parameters:
|
||||
- name: nodes
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
- name: drives
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: "#/definitions/getDirectPVVolumeListResponse"
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/directpv/drives/format:
|
||||
post:
|
||||
summary: Format directpv drives from a list
|
||||
operationId: DirectPVFormatDrive
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/formatConfiguration"
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: "#/definitions/formatDirectPVDrivesResponse"
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
definitions:
|
||||
error:
|
||||
type: object
|
||||
@@ -2936,15 +3008,15 @@ definitions:
|
||||
expires_at:
|
||||
type: string
|
||||
|
||||
getDirectCSIDriveListResponse:
|
||||
getDirectPVDriveListResponse:
|
||||
type: object
|
||||
properties:
|
||||
drives:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/directCSIDriveInfo"
|
||||
$ref: "#/definitions/directPVDriveInfo"
|
||||
|
||||
directCSIDriveInfo:
|
||||
directPVDriveInfo:
|
||||
type: object
|
||||
properties:
|
||||
drive:
|
||||
@@ -2965,15 +3037,15 @@ definitions:
|
||||
message:
|
||||
type: string
|
||||
|
||||
getDirectCSIVolumeListResponse:
|
||||
getDirectPVVolumeListResponse:
|
||||
type: object
|
||||
properties:
|
||||
volumes:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/directCSIVolumeInfo"
|
||||
$ref: "#/definitions/directPVVolumeInfo"
|
||||
|
||||
directCSIVolumeInfo:
|
||||
directPVVolumeInfo:
|
||||
type: object
|
||||
properties:
|
||||
volume:
|
||||
@@ -2986,7 +3058,7 @@ definitions:
|
||||
drive:
|
||||
type: string
|
||||
|
||||
csiFormatErrorResponse:
|
||||
pvFormatErrorResponse:
|
||||
type: object
|
||||
properties:
|
||||
node:
|
||||
@@ -2996,13 +3068,13 @@ definitions:
|
||||
error:
|
||||
type: string
|
||||
|
||||
formatDirectCSIDrivesResponse:
|
||||
formatDirectPVDrivesResponse:
|
||||
type: object
|
||||
properties:
|
||||
formatIssuesList:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/csiFormatErrorResponse"
|
||||
$ref: "#/definitions/pvFormatErrorResponse"
|
||||
|
||||
tenantYAML:
|
||||
type: object
|
||||
|
||||
Reference in New Issue
Block a user