Add staticcheck to console API (#2883)
This commit is contained in:
@@ -23,8 +23,8 @@ linters:
|
||||
- gomodguard
|
||||
- gofmt
|
||||
- unused
|
||||
- staticcheck
|
||||
- unconvert
|
||||
- varcheck
|
||||
- gocritic
|
||||
- gofumpt
|
||||
- durationcheck
|
||||
|
||||
@@ -18,7 +18,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
@@ -163,7 +163,7 @@ func loadAllCerts(ctx *cli.Context) error {
|
||||
|
||||
// load ca cert from swagger server tls-ca flag
|
||||
if swaggerServerCACertificate != "" {
|
||||
caCert, caCertErr := ioutil.ReadFile(swaggerServerCACertificate)
|
||||
caCert, caCertErr := os.ReadFile(swaggerServerCACertificate)
|
||||
if caCertErr == nil {
|
||||
restapi.GlobalRootCAs.AppendCertsFromPEM(caCert)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -56,7 +56,7 @@ func TestLoginStrategy(t *testing.T) {
|
||||
}
|
||||
|
||||
if response != nil {
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
|
||||
loginDetails := models.LoginDetails{}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -630,7 +630,7 @@ func Test_PolicyListUsersAPI(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if response != nil {
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
assert.Equal(tt.expectedStatus, response.StatusCode, tt.name+" Failed")
|
||||
if response.StatusCode == 200 {
|
||||
assert.Equal("[\"policyuser4\"]\n", string(bodyBytes))
|
||||
@@ -709,7 +709,7 @@ func Test_PolicyListGroupsAPI(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if response != nil {
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
assert.Equal(tt.expectedStatus, response.StatusCode, tt.name+" Failed")
|
||||
if response.StatusCode == 200 {
|
||||
assert.Equal("[\"testgroup12345\"]\n", string(bodyBytes))
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -777,7 +776,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
|
||||
|
||||
// Get versionID
|
||||
listResponse, _ := ListObjects(bucketName, prefix, "true")
|
||||
bodyBytes, _ := ioutil.ReadAll(listResponse.Body)
|
||||
bodyBytes, _ := io.ReadAll(listResponse.Body)
|
||||
listObjs := models.ListObjectsResponse{}
|
||||
err := json.Unmarshal(bodyBytes, &listObjs)
|
||||
if err != nil {
|
||||
@@ -1058,7 +1057,7 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
|
||||
|
||||
// Get versionID
|
||||
listResponse, _ := ListObjects(bucketName, validPrefix, "true")
|
||||
bodyBytes, _ := ioutil.ReadAll(listResponse.Body)
|
||||
bodyBytes, _ := io.ReadAll(listResponse.Body)
|
||||
listObjs := models.ListObjectsResponse{}
|
||||
err := json.Unmarshal(bodyBytes, &listObjs)
|
||||
if err != nil {
|
||||
@@ -1226,7 +1225,7 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
|
||||
|
||||
// 3. Get versionID
|
||||
listResponse, _ := ListObjects(bucketName, validPrefix, "true")
|
||||
bodyBytes, _ := ioutil.ReadAll(listResponse.Body)
|
||||
bodyBytes, _ := io.ReadAll(listResponse.Body)
|
||||
listObjs := models.ListObjectsResponse{}
|
||||
err := json.Unmarshal(bodyBytes, &listObjs)
|
||||
if err != nil {
|
||||
@@ -1443,7 +1442,7 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
|
||||
|
||||
// Get versionID
|
||||
listResponse, _ := ListObjects(bucketName, prefix, "true")
|
||||
bodyBytes, _ := ioutil.ReadAll(listResponse.Body)
|
||||
bodyBytes, _ := io.ReadAll(listResponse.Body)
|
||||
listObjs := models.ListObjectsResponse{}
|
||||
err := json.Unmarshal(bodyBytes, &listObjs)
|
||||
if err != nil {
|
||||
@@ -1776,7 +1775,7 @@ func TestDownloadObject(t *testing.T) {
|
||||
}
|
||||
|
||||
// 4. Verify the file was downloaded
|
||||
files, err := ioutil.ReadDir(workingDirectory)
|
||||
files, err := os.ReadDir(workingDirectory)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -2169,21 +2168,12 @@ func TestListBuckets(t *testing.T) {
|
||||
// 2. List buckets
|
||||
listBucketsResponse, listBucketsError := ListBuckets()
|
||||
assert.Nil(listBucketsError)
|
||||
if listBucketsError != nil {
|
||||
log.Println(listBucketsError)
|
||||
assert.Fail("Error listing the buckets")
|
||||
return
|
||||
}
|
||||
|
||||
assert.NotNil(listBucketsResponse)
|
||||
assert.NotNil(listBucketsResponse.Body)
|
||||
// 3. Verify list of buckets
|
||||
b, err := io.ReadAll(listBucketsResponse.Body)
|
||||
if listBucketsResponse != nil {
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
assert.Equal(200, listBucketsResponse.StatusCode,
|
||||
"Status Code is incorrect: "+string(b))
|
||||
}
|
||||
b, _ := io.ReadAll(listBucketsResponse.Body)
|
||||
assert.Equal(200, listBucketsResponse.StatusCode,
|
||||
"Status Code is incorrect: "+string(b))
|
||||
for i := 1; i <= numberOfBuckets; i++ {
|
||||
assert.True(strings.Contains(string(b),
|
||||
"testlistbuckets"+strconv.Itoa(i)))
|
||||
@@ -2215,7 +2205,7 @@ func TestBucketsGet(t *testing.T) {
|
||||
|
||||
if response != nil {
|
||||
assert.Equal(200, response.StatusCode, "Status Code is incorrect")
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
|
||||
listBuckets := models.ListBucketsResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &listBuckets)
|
||||
@@ -2255,7 +2245,7 @@ func TestBucketVersioning(t *testing.T) {
|
||||
|
||||
if response != nil {
|
||||
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
|
||||
sessionResponse := models.SessionResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &sessionResponse)
|
||||
@@ -2292,7 +2282,7 @@ func TestBucketVersioning(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, getVersioningResult.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(getVersioningResult.Body)
|
||||
bodyBytes, _ := io.ReadAll(getVersioningResult.Body)
|
||||
structBucketRepl := models.BucketVersioningResponse{
|
||||
ExcludeFolders: false,
|
||||
ExcludedPrefixes: nil,
|
||||
@@ -2369,7 +2359,7 @@ func TestSetBucketTags(t *testing.T) {
|
||||
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
|
||||
request.Header.Add("Content-Type", "application/json")
|
||||
|
||||
response, err := client.Do(request)
|
||||
_, err = client.Do(request)
|
||||
assert.Nil(err)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -2387,14 +2377,14 @@ func TestSetBucketTags(t *testing.T) {
|
||||
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
|
||||
request.Header.Add("Content-Type", "application/json")
|
||||
|
||||
response, err = client.Do(request)
|
||||
response, err := client.Do(request)
|
||||
assert.Nil(err)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
|
||||
bucket := models.Bucket{}
|
||||
err = json.Unmarshal(bodyBytes, &bucket)
|
||||
@@ -2847,7 +2837,7 @@ func TestReplication(t *testing.T) {
|
||||
}
|
||||
|
||||
// 3. Get rule ID and status from response's body
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
structBucketRepl := models.BucketReplicationResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &structBucketRepl)
|
||||
if err != nil {
|
||||
@@ -2929,7 +2919,7 @@ func TestReplication(t *testing.T) {
|
||||
}
|
||||
|
||||
// 9. Get rule ID and status from response's body
|
||||
bodyBytes, _ = ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ = io.ReadAll(response.Body)
|
||||
structBucketRepl = models.BucketReplicationResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &structBucketRepl)
|
||||
if err != nil {
|
||||
@@ -2996,7 +2986,7 @@ func TestReturnsTheStatusOfObjectLockingSupportOnTheBucket(t *testing.T) {
|
||||
}
|
||||
|
||||
// 2. Verify the status to be enabled for this bucket
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
structBucketLocking := models.BucketObLockingResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &structBucketLocking)
|
||||
if err != nil {
|
||||
@@ -3077,7 +3067,7 @@ func TestSetBucketVersioning(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, getVersioningResult.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(getVersioningResult.Body)
|
||||
bodyBytes, _ := io.ReadAll(getVersioningResult.Body)
|
||||
result := models.BucketVersioningResponse{
|
||||
ExcludeFolders: false,
|
||||
ExcludedPrefixes: nil,
|
||||
@@ -3160,7 +3150,7 @@ func TestEnableBucketEncryption(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ := io.ReadAll(resp.Body)
|
||||
result := models.BucketEncryptionInfo{}
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
@@ -3192,7 +3182,7 @@ func TestEnableBucketEncryption(t *testing.T) {
|
||||
assert.Equal(
|
||||
404, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ = ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ = io.ReadAll(resp.Body)
|
||||
result2 := models.Error{}
|
||||
err = json.Unmarshal(bodyBytes, &result2)
|
||||
if err != nil {
|
||||
@@ -3437,7 +3427,7 @@ func TestBucketLifeCycle(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ := io.ReadAll(resp.Body)
|
||||
result := models.BucketLifecycleResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
@@ -3483,7 +3473,7 @@ func TestBucketLifeCycle(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ = ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ = io.ReadAll(resp.Body)
|
||||
result = models.BucketLifecycleResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
@@ -3643,7 +3633,7 @@ func TestAccessRule(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ := io.ReadAll(resp.Body)
|
||||
result := models.ListAccessRulesResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
@@ -3681,7 +3671,7 @@ func TestAccessRule(t *testing.T) {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, "Status Code is incorrect")
|
||||
}
|
||||
bodyBytes, _ = ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, _ = io.ReadAll(resp.Body)
|
||||
result = models.ListAccessRulesResponse{}
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
@@ -3950,21 +3940,13 @@ func TestDeleteRemoteBucket(t *testing.T) {
|
||||
// 3. Get ARN
|
||||
resp, err = GetRemoteBucketARN(sourceBucket)
|
||||
assert.Nil(err)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
bodyBytes, _ := ioutil.ReadAll(resp.Body)
|
||||
assert.NotNil(resp)
|
||||
assert.NotNil(resp.Body)
|
||||
bodyBytes, _ := io.ReadAll(resp.Body)
|
||||
remoteBucket := models.RemoteBucket{}
|
||||
err = json.Unmarshal(bodyBytes, &remoteBucket)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
assert.Nil(err)
|
||||
}
|
||||
if resp != nil {
|
||||
assert.Equal(
|
||||
200, resp.StatusCode, inspectHTTPResponse(resp))
|
||||
}
|
||||
assert.Nil(err)
|
||||
assert.Equal(200, resp.StatusCode, inspectHTTPResponse(resp))
|
||||
|
||||
// 4. Delete Remote Bucket
|
||||
if remoteBucket.RemoteARN != nil {
|
||||
|
||||
@@ -69,23 +69,23 @@ type DiscoveryDoc struct {
|
||||
}
|
||||
|
||||
func (ac Config) Exchange(ctx context.Context, code string, opts ...xoauth2.AuthCodeOption) (*xoauth2.Token, error) {
|
||||
return ac.Exchange(ctx, code, opts...)
|
||||
return ac.Config.Exchange(ctx, code, opts...)
|
||||
}
|
||||
|
||||
func (ac Config) AuthCodeURL(state string, opts ...xoauth2.AuthCodeOption) string {
|
||||
return ac.AuthCodeURL(state, opts...)
|
||||
return ac.Config.AuthCodeURL(state, opts...)
|
||||
}
|
||||
|
||||
func (ac Config) PasswordCredentialsToken(ctx context.Context, username, password string) (*xoauth2.Token, error) {
|
||||
return ac.PasswordCredentialsToken(ctx, username, password)
|
||||
return ac.Config.PasswordCredentialsToken(ctx, username, password)
|
||||
}
|
||||
|
||||
func (ac Config) Client(ctx context.Context, t *xoauth2.Token) *http.Client {
|
||||
return ac.Client(ctx, t)
|
||||
return ac.Config.Client(ctx, t)
|
||||
}
|
||||
|
||||
func (ac Config) TokenSource(ctx context.Context, t *xoauth2.Token) xoauth2.TokenSource {
|
||||
return ac.TokenSource(ctx, t)
|
||||
return ac.Config.TokenSource(ctx, t)
|
||||
}
|
||||
|
||||
// Provider is a wrapper of the oauth2 configuration and the oidc provider
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -295,7 +294,7 @@ func decrypt(ciphertext, associatedData []byte) ([]byte, error) {
|
||||
return nil, fmt.Errorf("invalid nonce size %d, expected %d", len(nonce), aead.NonceSize())
|
||||
}
|
||||
|
||||
sealedBytes, err := ioutil.ReadAll(r)
|
||||
sealedBytes, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -85,7 +84,7 @@ var (
|
||||
func ParsePublicCertFile(certFile string) (x509Certs []*x509.Certificate, err error) {
|
||||
// Read certificate file.
|
||||
var data []byte
|
||||
if data, err = ioutil.ReadFile(certFile); err != nil {
|
||||
if data, err = os.ReadFile(certFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -188,11 +187,11 @@ const EnvCertPassword = "CONSOLE_CERT_PASSWD"
|
||||
// from the provided paths. The private key may be encrypted and is
|
||||
// decrypted using the ENV_VAR: MINIO_CERT_PASSWD.
|
||||
func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
|
||||
certPEMBlock, err := ioutil.ReadFile(certFile)
|
||||
certPEMBlock, err := os.ReadFile(certFile)
|
||||
if err != nil {
|
||||
return tls.Certificate{}, err
|
||||
}
|
||||
keyPEMBlock, err := ioutil.ReadFile(keyFile)
|
||||
keyPEMBlock, err := os.ReadFile(keyFile)
|
||||
if err != nil {
|
||||
return tls.Certificate{}, err
|
||||
}
|
||||
@@ -200,11 +199,13 @@ func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
|
||||
if len(rest) > 0 {
|
||||
return tls.Certificate{}, errors.New("the private key contains additional data")
|
||||
}
|
||||
// nolint:staticcheck // ignore SA1019
|
||||
if x509.IsEncryptedPEMBlock(key) {
|
||||
password := env.Get(EnvCertPassword, "")
|
||||
if len(password) == 0 {
|
||||
return tls.Certificate{}, errors.New("no password")
|
||||
}
|
||||
// nolint:staticcheck // ignore SA1019
|
||||
decryptedKey, decErr := x509.DecryptPEMBlock(key, []byte(password))
|
||||
if decErr != nil {
|
||||
return tls.Certificate{}, decErr
|
||||
|
||||
@@ -18,7 +18,6 @@ package http
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -69,6 +68,6 @@ func DrainBody(respBody io.ReadCloser) {
|
||||
// the same connection for future uses.
|
||||
// - http://stackoverflow.com/a/17961593/4465767
|
||||
defer respBody.Close()
|
||||
io.Copy(ioutil.Discard, respBody)
|
||||
io.Copy(io.Discard, respBody)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ func (h *Target) logEntry(entry interface{}) {
|
||||
func (h *Target) startHTTPLogger() {
|
||||
// Create a routine which sends json logs received
|
||||
// from an internal channel.
|
||||
h.wg.Add(1)
|
||||
go func() {
|
||||
h.wg.Add(1)
|
||||
defer h.wg.Done()
|
||||
for entry := range h.logCh {
|
||||
h.logEntry(entry)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
|
||||
@@ -155,7 +154,7 @@ func subnetReqDo(client xhttp.ClientI, r *http.Request, headers map[string]strin
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
respBytes, e := ioutil.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
||||
respBytes, e := io.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package utils
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"regexp"
|
||||
|
||||
"github.com/minio/console/pkg/http"
|
||||
@@ -35,7 +35,7 @@ func GetLatestMinIOImage(client http.ClientI) (*string, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -229,13 +229,6 @@ func TestEditSiteReplicationInfo(t *testing.T) {
|
||||
getResObj := &models.SiteReplicationInfoResponse{}
|
||||
json.NewDecoder(getResponse.Body).Decode(getResObj)
|
||||
var secondDeploymentID string
|
||||
if getResObj != nil {
|
||||
if len(getResObj.Sites) > 0 {
|
||||
secondDeploymentID = getResObj.Sites[1].DeploymentID
|
||||
}
|
||||
} else {
|
||||
assert.Fail("Unable to get Site deployment info")
|
||||
}
|
||||
fmt.Println("Edit Site Replication")
|
||||
fmt.Println("Editing a valid site deployment id::", secondDeploymentID)
|
||||
updatedSiteInfo := map[string]interface{}{
|
||||
|
||||
@@ -304,11 +304,11 @@ func importConfigResponse(session *models.Principal, params cfgApi.PostConfigsIm
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
file, _, err := params.HTTPRequest.FormFile("file")
|
||||
defer file.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = mAdmin.SetConfig(ctx, file)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
|
||||
@@ -227,7 +227,7 @@ func TestHeal(t *testing.T) {
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getHealOptionsFromReq(req)
|
||||
_, err = getHealOptionsFromReq(req)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("strconv.ParseBool: parsing \"nonbool\": invalid syntax", err.Error())
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func TestHeal(t *testing.T) {
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getHealOptionsFromReq(req)
|
||||
_, err = getHealOptionsFromReq(req)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("strconv.ParseBool: parsing \"nonbool\": invalid syntax", err.Error())
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func TestHeal(t *testing.T) {
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getHealOptionsFromReq(req)
|
||||
_, err = getHealOptionsFromReq(req)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("strconv.ParseBool: parsing \"nonbool\": invalid syntax", err.Error())
|
||||
}
|
||||
@@ -254,7 +254,7 @@ func TestHeal(t *testing.T) {
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getHealOptionsFromReq(req)
|
||||
_, err = getHealOptionsFromReq(req)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("strconv.ParseBool: parsing \"nonbool\": invalid syntax", err.Error())
|
||||
}
|
||||
@@ -263,7 +263,7 @@ func TestHeal(t *testing.T) {
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getHealOptionsFromReq(req)
|
||||
_, err = getHealOptionsFromReq(req)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("strconv.ParseBool: parsing \"nonbool\": invalid syntax", err.Error())
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ type objectsListOpts struct {
|
||||
}
|
||||
|
||||
type ObjectsRequest struct {
|
||||
Mode string `json:"mode,nonempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
BucketName string `json:"bucket_name"`
|
||||
Prefix string `json:"prefix"`
|
||||
Date string `json:"date"`
|
||||
@@ -40,7 +40,7 @@ type ObjectsRequest struct {
|
||||
}
|
||||
|
||||
type WSResponse struct {
|
||||
RequestID int64 `json:"request_id,nonempty"`
|
||||
RequestID int64 `json:"request_id,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
RequestEnd bool `json:"request_end,omitempty"`
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
@@ -49,10 +49,10 @@ type WSResponse struct {
|
||||
}
|
||||
|
||||
type ObjectResponse struct {
|
||||
Name string `json:"name,nonempty"`
|
||||
LastModified string `json:"last_modified,nonempty"`
|
||||
Size int64 `json:"size,nonempty"`
|
||||
VersionID string `json:"version_id,nonempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
LastModified string `json:"last_modified,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
VersionID string `json:"version_id,omitempty"`
|
||||
DeleteMarker bool `json:"delete_flag,omitempty"`
|
||||
IsLatest bool `json:"is_latest,omitempty"`
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ func getListUsersForPolicyResponse(session *models.Principal, params policyApi.L
|
||||
}
|
||||
|
||||
func getUserPolicyResponse(ctx context.Context, session *models.Principal) (string, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
// serialize output
|
||||
if session == nil {
|
||||
|
||||
@@ -18,7 +18,7 @@ package restapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
@@ -55,7 +55,7 @@ func startProfiling(ctx context.Context, conn WSConn, client MinioAdmin, pOpts *
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message, err := ioutil.ReadAll(zippedData)
|
||||
message, err := io.ReadAll(zippedData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -64,10 +64,6 @@ func getSpeedtestOptionsFromReq(req *http.Request) (*madmin.SpeedtestOpts, error
|
||||
return nil, fmt.Errorf("unable to parse object size")
|
||||
}
|
||||
|
||||
if size < 0 {
|
||||
return nil, fmt.Errorf("size is expected to be atleast 0 bytes")
|
||||
}
|
||||
|
||||
optionsSet.Size = int(size)
|
||||
|
||||
paramConcurrent := queryPairs.Get("concurrent")
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestAddServiceAccount(t *testing.T) {
|
||||
minioAddServiceAccountMock = func(ctx context.Context, policy *iampolicy.Policy, user string, accessKey string, secretKey string) (madmin.Credentials, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
saCreds, err = createServiceAccount(ctx, client, policyDefinition)
|
||||
_, err = createServiceAccount(ctx, client, policyDefinition)
|
||||
assert.Error(err)
|
||||
|
||||
// Test-3: if an error occurs on server while creating service account (valid policy), handle it
|
||||
|
||||
@@ -184,7 +184,7 @@ type VersionState string
|
||||
|
||||
const (
|
||||
VersionEnable VersionState = "enable"
|
||||
VersionSuspend = "suspend"
|
||||
VersionSuspend VersionState = "suspend"
|
||||
)
|
||||
|
||||
// removeBucket deletes a bucket
|
||||
@@ -210,7 +210,7 @@ func setBucketVersioningResponse(session *models.Principal, params bucketApi.Set
|
||||
// defining the client to be used
|
||||
amcClient := mcClient{client: s3Client}
|
||||
|
||||
var versioningState VersionState = VersionSuspend
|
||||
versioningState := VersionSuspend
|
||||
|
||||
if params.Body.Versioning {
|
||||
versioningState = VersionEnable
|
||||
|
||||
@@ -56,6 +56,7 @@ func registerSessionHandlers(api *operations.ConsoleAPI) {
|
||||
|
||||
func getClaimsFromToken(sessionToken string) (map[string]interface{}, error) {
|
||||
jp := new(jwtgo.Parser)
|
||||
// nolint:staticcheck // ignore SA1019
|
||||
jp.ValidMethods = []string{
|
||||
"RS256", "RS384", "RS512", "ES256", "ES384", "ES512",
|
||||
"RS3256", "RS3384", "RS3512", "ES3256", "ES3384", "ES3512",
|
||||
|
||||
@@ -291,10 +291,10 @@ func TestWatch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-9: getWatchOptionsFromReq invalid url
|
||||
u, err = url.Parse("http://localhost/api/v1/wach/bucket2?prefix=&suffix=")
|
||||
u, _ = url.Parse("http://localhost/api/v1/wach/bucket2?prefix=&suffix=")
|
||||
req = &http.Request{
|
||||
URL: u,
|
||||
}
|
||||
opts, err = getWatchOptionsFromReq(req)
|
||||
_, err = getWatchOptionsFromReq(req)
|
||||
assert.Error(err)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -282,7 +281,7 @@ func TestBadLogin(t *testing.T) {
|
||||
fmt.Println(err)
|
||||
expectedError := response.Status
|
||||
assert.Equal("400 Bad Request", expectedError)
|
||||
bodyBytes, _ := ioutil.ReadAll(response.Body)
|
||||
bodyBytes, _ := io.ReadAll(response.Body)
|
||||
result2 := models.Error{}
|
||||
err = json.Unmarshal(bodyBytes, &result2)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user