-
Notifications
You must be signed in to change notification settings - Fork 1
/
renovate.go
67 lines (56 loc) · 2.27 KB
/
renovate.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
package cimodules
import (
"context"
"strconv"
"time"
"dagger.io/dagger"
)
type RenovateOpts struct {
Platform string
Autodiscover bool
AutodiscoverFilter string
Repositories string
Env map[string]string
Secret map[string]dagger.SecretID
LogLevel string
Image Image
}
var defaultRenovateImage = Image{
Name: "renovate/renovate",
//# renovate: datasource=docker depName=renovate/renovate versioning=docker
Version: "38.135.1",
Suffix: "",
}
func renovate(ctx context.Context, client dagger.Client, opts RenovateOpts) error {
image := client.Container().From(createImageString(defaultRenovateImage, opts.Image))
// used to avoid dagger caching
// we want this function to be executed every time we run it
cacheHack := time.Now()
renovate := image.WithEnvVariable("RENOVATE_PLATFORM", opts.Platform)
renovate = renovate.WithEnvVariable("RENOVATE_EXTENDS", "github>whitesource/merge-confidence:beta")
renovate = renovate.WithEnvVariable("RENOVATE_REQUIRE_CONFIG", "required")
renovate = renovate.WithEnvVariable("RENOVATE_GIT_AUTHOR", "Renovate Bot <[email protected]>")
renovate = renovate.WithEnvVariable("RENOVATE_PIN_DIGEST", "true")
renovate = renovate.WithEnvVariable("RENOVATE_DEPENDENCY_DASHBOARD", "false")
renovate = renovate.WithEnvVariable("RENOVATE_LABELS", "renovate")
renovate = renovate.WithEnvVariable("RENOVATE_AUTODISCOVER", strconv.FormatBool(opts.Autodiscover))
renovate = renovate.WithEnvVariable("RENOVATE_AUTODISCOVER_FILTER", opts.AutodiscoverFilter)
renovate = renovate.WithEnvVariable("RENOVATE_REPOSITORIES", opts.Repositories)
renovate = renovate.WithEnvVariable("LOG_LEVEL", opts.LogLevel)
// pass this value to avoid dagger caching
// we want this container to be executed every time we run it
renovate = renovate.WithEnvVariable("CACHE_HACK", cacheHack.String())
// write env secrets - access-tokens etc.
for key, val := range opts.Secret {
renovate = renovate.WithSecretVariable(key, client.LoadSecretFromID(val))
}
// write dditional env variables
for key, val := range opts.Env {
renovate = renovate.WithEnvVariable(key, val)
}
_, err := renovate.WithExec([]string{}, dagger.ContainerWithExecOpts{}).Stdout(ctx)
if err != nil {
return err
}
return nil
}