-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathsecret_scope.go
73 lines (57 loc) · 1.6 KB
/
secret_scope.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package resources
import (
"context"
"net/url"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/workspace"
)
type SecretScope struct {
Name string `json:"name"`
InitialManagePrincipal string `json:"initial_manage_principal"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
*workspace.SecretScope
}
func (s *SecretScope) UnmarshalJSON(b []byte) error {
return marshal.Unmarshal(b, s)
}
func (s SecretScope) MarshalJSON() ([]byte, error) {
return marshal.Marshal(s)
}
func (s SecretScope) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) {
scopes, err := w.Secrets.ListScopesAll(ctx)
if err != nil {
return false, nil
}
for _, scope := range scopes {
if scope.Name == name {
return true, nil
}
}
return false, nil
}
func (s SecretScope) ResourceDescription() ResourceDescription {
return ResourceDescription{
SingularName: "secret_scope",
PluralName: "secret_scopes",
SingularTitle: "Secret Scope",
PluralTitle: "Secret Scope",
TerraformResourceName: "databricks_secret_scope",
}
}
func (s SecretScope) TerraformResourceName() string {
return "databricks_secret_scope"
}
func (s SecretScope) GetName() string {
return s.Name
}
func (s SecretScope) GetURL() string {
// Secret scopes do not have a URL
return ""
}
func (s SecretScope) InitializeURL(_ url.URL) {
// Secret scopes do not have a URL
}
func (s SecretScope) IsNil() bool {
return s.SecretScope == nil
}