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

+4
View File
@@ -11,11 +11,15 @@ import (
"google.golang.org/protobuf/types/known/structpb"
)
// CredentialAttributes contain attributes used for authenticating to Google Cloud
// and accessing a list of instances
type CredentialAttributes struct {
Project string
Zone string
}
// GetCredentialAttributes checks attributes required by Google Cloud to access
// a list of instances and populate them into Boundary's host catalog
func GetCredentialAttributes(in *structpb.Struct) (*CredentialAttributes, error) {
badFields := make(map[string]string)
+11
View File
@@ -29,6 +29,17 @@ func TestGetCredentialAttributes(t *testing.T) {
in: map[string]any{},
expectedErrContains: "missing required value \"zone\"",
},
{
name: "valid project and zone",
in: map[string]any{
ConstProject: "test-project",
ConstZone: "us-central-1",
},
expected: &CredentialAttributes{
Project: "test-project",
Zone: "us-central-1",
},
},
}
for _, tc := range cases {
+4 -6
View File
@@ -4,11 +4,9 @@
package credential
const (
// ConstProject defines the attribute name for a Google Cloud project
ConstProject = "project"
ConstZone = "zone"
)
var AllowedCatalogFields = map[string]struct{}{
ConstProject: {},
ConstZone: {},
}
// ConstZone defines the attribute name for a Google Cloud zone
ConstZone = "zone"
)