Replace the rapid-based property test for plugin capability IDs
with a table-driven test and Go's built-in fuzzing support.
Preserve the comparison against the historical JSON parser to
catch compatibility regressions, and add explicit test cases for
the supported serialization formats and invalid inputs.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Deprecate Len, Less, and Swap on Privileges in favor of slices.SortFunc.
The sort.Interface implementation is kept for compatibility, but new code can
sort Privileges directly using the generic slices helpers without relying on
the legacy methods.
For example:
slices.SortFunc(privileges, func(a, b plugin.Privilege) int {
return cmp.Compare(a.Name, b.Name)
})
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Make Privileges.Swap only swap the requested elements, as required by
sort.Interface.
Previously, Swap also sorted the Value slices of both elements. Besides being
an unexpected side effect, this did not reliably sort all privilege values,
as elements that were never swapped could remain unsorted.
Also document the sort.Interface methods explicitly.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The wire type of Plugin.Config.Interface.Types is an array of strings,
not of objects with three properties. We just so happen to have a Go
struct type to represent a plugin-interface-type value in memory with
all the fields parsed out for convenience, but that is not part of the
REST API contract documented by the Swager spec.U pdate the Swagger spec
to correctly document that the Types property is an array of strings in
the API, while still generating Go definitions that unmarshal into the
convenient struct type.
Move the definition and marshal/unmarshal methods for
PluginInterfaceType into a more appropriate location than api/types.
Rename the type to one that does not stutter or overload already
heavily overloaded terminology.
Modernize the parser and use property-based testing to assert that it
behaves the same as the old parser for all well-formed inputs.
Signed-off-by: Cory Snider <csnider@mirantis.com>