Add more tests and comments for Godoc
This commit is contained in:
12 files changed
+345
-23
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
@@ -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,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"
|
||||
)
|
||||
Reference in new issue
Block a user