-
Notifications
You must be signed in to change notification settings - Fork 33
/
storage.go
35 lines (31 loc) · 996 Bytes
/
storage.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
package module
import (
"context"
"fmt"
"io"
"path"
)
// Storage represents the repository of Terraform modules.
type Storage interface {
GetModule(ctx context.Context, namespace, name, provider, version string) (Module, error)
ListModuleVersions(ctx context.Context, namespace, name, provider string) ([]Module, error)
UploadModule(ctx context.Context, namespace, name, provider, version string, body io.Reader) (Module, error)
}
func storagePrefix(prefix, namespace, name, provider string) string {
return path.Join(
prefix,
fmt.Sprintf("namespace=%s", namespace),
fmt.Sprintf("name=%s", name),
fmt.Sprintf("provider=%s", provider),
)
}
func storagePath(prefix, namespace, name, provider, version string) string {
return path.Join(
prefix,
fmt.Sprintf("namespace=%s", namespace),
fmt.Sprintf("name=%s", name),
fmt.Sprintf("provider=%s", provider),
fmt.Sprintf("version=%s", version),
fmt.Sprintf("%s-%s-%s-%s.tar.gz", namespace, name, provider, version),
)
}