-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpusher.go
More file actions
54 lines (47 loc) · 1.23 KB
/
Copy pathpusher.go
File metadata and controls
54 lines (47 loc) · 1.23 KB
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
package deploy
import (
"fmt"
"strings"
"sync"
"github.com/tinywasm/wizard"
)
// Pusher defines the interface for a deployment method.
type Pusher interface {
// Name returns the unique identifier for this pusher (e.g., "webhook", "ssh", "edgeWorker").
Name() string
// Run executes the deployment logic.
Run(cfg *Config, p *Puller) error
// WizardSteps returns the interactive setup steps for this pusher.
WizardSteps(store Store, log func(...any)) []*wizard.Step
}
var (
pushersMu sync.RWMutex
pushers = make(map[string]Pusher)
)
// RegisterPusher adds a pusher to the global registry.
func RegisterPusher(s Pusher) {
pushersMu.Lock()
defer pushersMu.Unlock()
pushers[s.Name()] = s
}
// GetPusher retrieves a pusher by its name (case-insensitive).
func GetPusher(name string) (Pusher, error) {
pushersMu.RLock()
defer pushersMu.RUnlock()
for k, s := range pushers {
if strings.EqualFold(k, name) {
return s, nil
}
}
return nil, fmt.Errorf("deploy: unknown pusher %q", name)
}
// AvailablePushers returns the names of all registered pushers.
func AvailablePushers() []string {
pushersMu.RLock()
defer pushersMu.RUnlock()
var names []string
for name := range pushers {
names = append(names, name)
}
return names
}