File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ func (cfg *Config) IsSameStorage(other *Config) bool {
9292}
9393
9494func (cfg * Config ) Cast () error {
95+ if cfg == nil {
96+ return errors .New ("missing minio configuration with minio storage type" )
97+ }
98+
9599 if cfg .Endpoint == "" {
96100 return errors .New ("endpointURL cannot be empty" )
97101 }
Original file line number Diff line number Diff line change @@ -69,14 +69,19 @@ func TestEqual(t *testing.T) {
6969}
7070
7171func TestCast (t * testing.T ) {
72- c := & Config {}
72+ var c * Config
73+ err := c .Cast ()
74+ if err == nil {
75+ t .Fatal ("sigsegv should happened instead" )
76+ }
7377
78+ c = & Config {}
7479 if err := c .Cast (); err == nil {
7580 t .Fatal ("want error when EndpointURL is not specified" )
7681 }
7782
7883 c .Endpoint = "url"
79- err : = c .Cast ()
84+ err = c .Cast ()
8085 if err != nil {
8186 t .Fatalf ("got error during Cast: %v" , err )
8287 }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package oss
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "time"
78
@@ -63,6 +64,9 @@ type Credentials struct {
6364}
6465
6566func (cfg * Config ) Cast () error {
67+ if cfg == nil {
68+ return errors .New ("missing oss configuration with oss storage type" )
69+ }
6670 if cfg .Region == "" {
6771 cfg .Region = defaultOSSRegion
6872 }
You can’t perform that action at this time.
0 commit comments