-
Notifications
You must be signed in to change notification settings - Fork 401
/
versioning.go
73 lines (60 loc) · 1.63 KB
/
versioning.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
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package testplanet
import (
"fmt"
"os"
"path/filepath"
"time"
"storj.io/storj/private/version"
"storj.io/storj/private/version/checker"
"storj.io/storj/versioncontrol"
)
// newVersionControlServer initializes the Versioning Server
func (planet *Planet) newVersionControlServer() (peer *versioncontrol.Peer, err error) {
prefix := "versioncontrol"
log := planet.log.Named(prefix)
dbDir := filepath.Join(planet.directory, prefix)
if err := os.MkdirAll(dbDir, 0700); err != nil {
return nil, err
}
config := &versioncontrol.Config{
Address: "127.0.0.1:0",
Versions: versioncontrol.OldVersionConfig{
Satellite: "v0.0.1",
Storagenode: "v0.0.1",
Uplink: "v0.0.1",
Gateway: "v0.0.1",
Identity: "v0.0.1",
},
}
peer, err = versioncontrol.New(log, config)
if err != nil {
return nil, err
}
log.Debug(" addr= " + peer.Addr())
return peer, nil
}
// NewVersionInfo returns the Version Info for this planet with tuned metrics.
func (planet *Planet) NewVersionInfo() version.Info {
ver, err := version.NewSemVer("v0.0.1")
if err != nil {
panic(err)
}
info := version.Info{
Timestamp: time.Now(),
CommitHash: "testplanet",
Version: ver,
Release: false,
}
return info
}
// NewVersionConfig returns the Version Config for this planet with tuned metrics.
func (planet *Planet) NewVersionConfig() checker.Config {
config := checker.Config{
CheckInterval: defaultInterval,
}
config.ServerAddress = fmt.Sprintf("http://%s/", planet.VersionControl.Addr())
config.RequestTimeout = time.Second * 15
return config
}