mirror of
https://github.com/minio/minio.git
synced 2025-11-24 03:27:44 -05:00
policy: Do not return an error for invalid value during parsing (#9442)
s3:HardwareInfo was removed recently. Users having that admin action stored in the backend will have an issue starting the server. To fix this, we need to avoid returning an error in Marshal/Unmarshal when they encounter an invalid action and validate only in specific location. Currently the validation is done and in ParseConfig().
This commit is contained in:
@@ -16,10 +16,6 @@
|
||||
|
||||
package policy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Effect - policy statement effect Allow or Deny.
|
||||
type Effect string
|
||||
|
||||
@@ -49,29 +45,3 @@ func (effect Effect) IsValid() bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// MarshalJSON - encodes Effect to JSON data.
|
||||
func (effect Effect) MarshalJSON() ([]byte, error) {
|
||||
if !effect.IsValid() {
|
||||
return nil, Errorf("invalid effect '%v'", effect)
|
||||
}
|
||||
|
||||
return json.Marshal(string(effect))
|
||||
}
|
||||
|
||||
// UnmarshalJSON - decodes JSON data to Effect.
|
||||
func (effect *Effect) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e := Effect(s)
|
||||
if !e.IsValid() {
|
||||
return Errorf("invalid effect '%v'", s)
|
||||
}
|
||||
|
||||
*effect = e
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user