/
project.go
65 lines (48 loc) · 1.69 KB
/
project.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
package core
import (
"fmt"
"time"
"github.com/inoxlang/inox/internal/parse"
"github.com/oklog/ulid/v2"
)
type Project interface {
Id() ProjectID
BaseImage() (Image, error)
ListSecrets(ctx *Context) ([]ProjectSecretInfo, error)
GetSecrets(ctx *Context) ([]ProjectSecret, error)
//CanProvideS3Credentials should return true if the project can provide S3 credentials for
//the given S3 provider AT THE MOMENT OF THE CALL. If the error is not nil the boolean result
//should be false.
CanProvideS3Credentials(s3Provider string) (bool, error)
// GetS3CredentialsForBucket creates the bucket bucketName if necessary & returns credentials to access it,
// the returned credentials should not work for other buckets.
GetS3CredentialsForBucket(ctx *Context, bucketName string, provider string) (accessKey, secretKey string, s3Endpoint Host, _ error)
Configuration() ProjectConfiguration
//DevDatabasesDirOnOsFs returns the directory where the project's databases are stored.
DevDatabasesDirOnOsFs() string
}
type ProjectID string
func RandomProjectID(projectName string) ProjectID {
return ProjectID(projectName + "-" + ulid.Make().String())
}
type ProjectConfiguration interface {
AreExposedWebServersAllowed() bool
}
type ProjectSecret struct {
Name SecretName
LastModifDate time.Time
Value *Secret
}
type ProjectSecretInfo struct {
Name SecretName `json:"name"`
LastModifDate time.Time `json:"lastModificationDate"`
}
type SecretName string
func SecretNameFrom(name string) (SecretName, error) {
for _, r := range name {
if !parse.IsIdentChar(r) {
return "", fmt.Errorf("invalid char found in secret's name: '%c'", r)
}
}
return SecretName(name), nil
}