Migrate grants to more structured output (#194)
This commit is contained in:
1 parent
1a1d3058c9
commit
99653727bb
19 files changed
+757
-642
No files matched your search
@@ -1,51 +1,7 @@
|
||||
// Code generated by "make api"; DO NOT EDIT.
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"github.com/hashicorp/watchtower/api/internal/strutil"
|
||||
)
|
||||
|
||||
type FieldError struct {
|
||||
defaultFields []string
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (s *FieldError) SetDefault(key string) {
|
||||
lowerKey := strings.ToLower(key)
|
||||
validMap := map[string]string{"description": "description", "name": "name"}
|
||||
for k, v := range validMap {
|
||||
if k == lowerKey || v == lowerKey {
|
||||
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, v)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FieldError) UnsetDefault(key string) {
|
||||
lowerKey := strings.ToLower(key)
|
||||
validMap := map[string]string{"description": "description", "name": "name"}
|
||||
for k, v := range validMap {
|
||||
if k == lowerKey || v == lowerKey {
|
||||
s.defaultFields = strutil.StrListDelete(s.defaultFields, v)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s FieldError) MarshalJSON() ([]byte, error) {
|
||||
m := structs.Map(s)
|
||||
if m == nil {
|
||||
m = make(map[string]interface{})
|
||||
}
|
||||
for _, k := range s.defaultFields {
|
||||
m[k] = nil
|
||||
}
|
||||
return json.Marshal(m)
|
||||
}
|
||||
Reference in new issue
Block a user