@@ -17,6 +17,7 @@ limitations under the License.
1717package protocol
1818
1919import (
20+ "errors"
2021 "fmt"
2122
2223 cosiapi "sigs.k8s.io/container-object-storage-interface/client/apis/objectstorage/v1alpha2"
@@ -62,20 +63,20 @@ func (GcsBucketInfoTranslator) ApiToRpc(vars map[cosiapi.BucketInfoVar]string) *
6263func (GcsBucketInfoTranslator ) Validate (
6364 vars map [cosiapi.BucketInfoVar ]string , _ cosiapi.BucketAccessAuthenticationType ,
6465) error {
65- errs := []string {}
66+ errs := []error {}
6667
6768 bucketName := vars [cosiapi .BucketInfoVar_GCS_BucketName ]
6869 if bucketName == "" {
69- errs = append (errs , "GCS bucket name cannot be unset" )
70+ errs = append (errs , fmt . Errorf ( "GCS bucket name cannot be unset" ) )
7071 }
7172
7273 projectId := vars [cosiapi .BucketInfoVar_GCS_ProjectId ]
7374 if projectId == "" {
74- errs = append (errs , "GCS project ID cannot be unset" )
75+ errs = append (errs , fmt . Errorf ( "GCS project ID cannot be unset" ) )
7576 }
7677
7778 if len (errs ) > 0 {
78- return fmt .Errorf ("GCS bucket info is invalid: %v " , errs )
79+ return fmt .Errorf ("GCS bucket info is invalid: %w " , errors . Join ( errs ... ) )
7980 }
8081 return nil
8182}
@@ -113,34 +114,34 @@ func (GcsCredentialTranslator) ApiToRpc(vars map[cosiapi.CredentialVar]string) *
113114func (GcsCredentialTranslator ) Validate (
114115 vars map [cosiapi.CredentialVar ]string , authType cosiapi.BucketAccessAuthenticationType ,
115116) error {
116- errs := []string {}
117+ errs := []error {}
117118
118119 switch authType {
119120 case cosiapi .BucketAccessAuthenticationTypeKey :
120121 accessId := vars [cosiapi .CredentialVar_GCS_AccessId ]
121122 if accessId == "" {
122- errs = append (errs , "GCS access ID cannot be unset" )
123+ errs = append (errs , fmt . Errorf ( "GCS access ID cannot be unset" ) )
123124 }
124125
125126 accessSecret := vars [cosiapi .CredentialVar_GCS_AccessSecret ]
126127 if accessSecret == "" {
127- errs = append (errs , "GCS access secret cannot be unset" )
128+ errs = append (errs , fmt . Errorf ( "GCS access secret cannot be unset" ) )
128129 }
129130
130131 case cosiapi .BucketAccessAuthenticationTypeServiceAccount :
131132 privateKeyName := vars [cosiapi .CredentialVar_GCS_PrivateKeyName ]
132133 if privateKeyName == "" {
133- errs = append (errs , "GCS private key name cannot be unset" )
134+ errs = append (errs , fmt . Errorf ( "GCS private key name cannot be unset" ) )
134135 }
135136
136137 serviceAccount := vars [cosiapi .CredentialVar_GCS_ServiceAccount ]
137138 if serviceAccount == "" {
138- errs = append (errs , "GCS service account cannot be unset" )
139+ errs = append (errs , fmt . Errorf ( "GCS service account cannot be unset" ) )
139140 }
140141 }
141142
142143 if len (errs ) > 0 {
143- return fmt .Errorf ("GCS credential info is invalid: %v " , errs )
144+ return fmt .Errorf ("GCS credential info is invalid: %w " , errors . Join ( errs ... ) )
144145 }
145146 return nil
146147}
0 commit comments