// Parse parses RBAC data from a reader and creates a new Authorizer.
Parse parses RBAC data from a reader and creates a new Authorizer.
// Parse parses RBAC data from a reader and creates a new Authorizer .
func Parse(r io.Reader) (Authorizer, error) {
	rbac := struct {
		Roles        []Role        `json:"roles" yaml:"roles"`
		RoleBindings []RoleBinding `json:"roleBindings" yaml:"roleBindings"`
	}{}
	if err := yaml.NewDecoder(r).Decode(&rbac); err != nil {
		return nil, fmt.Errorf("could not parse RBAC data: %w", err)
	}
	return NewAuthorzer(rbac.Roles, rbac.RoleBindings), nil
}
func Parse ( r io . Reader ) ( Authorizer , error ) { rbac := struct { Roles [ ] Role `json:"roles" yaml:"roles"` RoleBindings [ ] RoleBinding `json:"roleBindings" yaml:"roleBindings"` } { } if err := yaml . NewDecoder ( r ) . Decode ( & rbac ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } return NewAuthorzer ( rbac . Roles , rbac . RoleBindings ) , nil }
Parse parses RBAC data from a reader and creates a new Authorizer.
Parse parses RBAC data from a reader and creates a new Authorizer .