Add more tests and comments for Godoc

This commit is contained in:
Rosemary Wang committed 2024-08-06 11:51:00 -04:00
1 parent 714c26721d
commit 9e63aea3ec
12 files changed
+345 -23

No files matched your search

+9
View File
@@ -16,6 +16,7 @@ import (
"google.golang.org/protobuf/types/known/structpb"
)
// CatalogAttributes defines a set of attributes for the host catalog
type CatalogAttributes struct {
*cred.CredentialAttributes
}
@@ -51,6 +52,7 @@ func getCatalogAttributes(in *structpb.Struct) (*CatalogAttributes, error) {
}, nil
}
// SetAttributes defines attributes fro the host set
type SetAttributes struct {
Filter string `mapstructure:"filter"`
InstanceGroup string `mapstructure:"instance_group"`
@@ -62,6 +64,12 @@ func getSetAttributes(in *structpb.Struct) (*SetAttributes, error) {
badFields := make(map[string]string)
unknownFields := values.StructFields(in)
if _, filter := unknownFields[ConstListInstancesFilter]; filter {
if _, ig := unknownFields[ConstInstanceGroup]; ig {
return nil, errors.InvalidArgumentError("Error in the attributes provided, cannot define both filter and instance group", nil)
}
}
delete(unknownFields, ConstListInstancesFilter)
delete(unknownFields, ConstInstanceGroup)
@@ -82,6 +90,7 @@ func getSetAttributes(in *structpb.Struct) (*SetAttributes, error) {
inMap[ConstListInstancesFilter] = string(filterVal)
}
}
if instanceGroupRaw, ok := inMap[ConstInstanceGroup]; ok {
switch instanceGroupValue := instanceGroupRaw.(type) {
case string: