-
Notifications
You must be signed in to change notification settings - Fork 111
/
admin.go
141 lines (112 loc) · 3.11 KB
/
admin.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package s3
import (
"context"
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/rilldata/rill/runtime/drivers"
"github.com/rilldata/rill/runtime/pkg/activity"
"go.uber.org/zap"
)
var spec = drivers.Spec{
DisplayName: "Rill Admin",
ConfigProperties: []drivers.PropertySchema{
{
Key: "access_token",
Secret: true,
},
},
}
func init() {
drivers.Register("admin", driver{})
}
type driver struct{}
var _ drivers.Driver = driver{}
type configProperties struct {
AccessToken string `mapstructure:"access_token"`
}
func (d driver) Open(cfgMap map[string]any, shared bool, client activity.Client, logger *zap.Logger) (drivers.Handle, error) {
if shared {
return nil, fmt.Errorf("admin driver can't be shared")
}
cfg := &configProperties{}
err := mapstructure.Decode(cfgMap, cfg)
if err != nil {
return nil, err
}
h := &Handle{
config: cfg,
logger: logger,
}
return h, nil
}
func (d driver) Drop(config map[string]any, logger *zap.Logger) error {
return drivers.ErrDropNotSupported
}
func (d driver) Spec() drivers.Spec {
return spec
}
func (d driver) HasAnonymousSourceAccess(ctx context.Context, props map[string]any, logger *zap.Logger) (bool, error) {
return false, fmt.Errorf("not implemented")
}
func (d driver) TertiarySourceConnectors(ctx context.Context, src map[string]any, logger *zap.Logger) ([]string, error) {
return nil, fmt.Errorf("not implemented")
}
type Handle struct {
config *configProperties
logger *zap.Logger
}
var _ drivers.Handle = &Handle{}
// Driver implements drivers.Handle.
func (c *Handle) Driver() string {
return "admin"
}
// Config implements drivers.Handle.
func (c *Handle) Config() map[string]any {
m := make(map[string]any, 0)
_ = mapstructure.Decode(c.config, &m)
return m
}
// Migrate implements drivers.Handle.
func (c *Handle) Migrate(ctx context.Context) (err error) {
return nil
}
// MigrationStatus implements drivers.Handle.
func (c *Handle) MigrationStatus(ctx context.Context) (current, desired int, err error) {
return 0, 0, nil
}
// Close implements drivers.Handle.
func (c *Handle) Close() error {
return nil
}
// Registry implements drivers.Handle.
func (c *Handle) AsRegistry() (drivers.RegistryStore, bool) {
return nil, false
}
// Catalog implements drivers.Handle.
func (c *Handle) AsCatalogStore(instanceID string) (drivers.CatalogStore, bool) {
return nil, false
}
// Repo implements drivers.Handle.
func (c *Handle) AsRepoStore(instanceID string) (drivers.RepoStore, bool) {
return nil, false
}
// OLAP implements drivers.Handle.
func (c *Handle) AsOLAP(instanceID string) (drivers.OLAPStore, bool) {
return nil, false
}
// AsObjectStore implements drivers.Handle.
func (c *Handle) AsObjectStore() (drivers.ObjectStore, bool) {
return nil, false
}
// AsFileStore implements drivers.Handle.
func (c *Handle) AsFileStore() (drivers.FileStore, bool) {
return nil, false
}
// AsTransporter implements drivers.Handle.
func (c *Handle) AsTransporter(from, to drivers.Handle) (drivers.Transporter, bool) {
return nil, false
}
// AsSQLStore implements drivers.Handle.
func (c *Handle) AsSQLStore() (drivers.SQLStore, bool) {
return nil, false
}