Reimplemented DirectPV API in operator console (#2207)
- Updated API to use latest directpv library Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -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
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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