summaryrefslogtreecommitdiffstats
path: root/client/go/internal/vespa/system.go
blob: b8263dbdec027bff30dec8d9480adacc0436d625 (plain) (blame)
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
package vespa

import "fmt"

// PublicSystem represents the main Vespa Cloud system.
var PublicSystem = System{
	Name:        "public",
	URL:         "https://api-ctl.vespa-cloud.com:4443",
	ConsoleURL:  "https://console.vespa-cloud.com",
	DefaultZone: ZoneID{Environment: "dev", Region: "aws-us-east-1c"},
}

// PublicCDSystem represents the CD variant of the Vespa Cloud system.
var PublicCDSystem = System{
	Name:        "publiccd",
	URL:         "https://api-ctl.cd.vespa-cloud.com:4443",
	ConsoleURL:  "https://console.cd.vespa-cloud.com",
	DefaultZone: ZoneID{Environment: "dev", Region: "aws-us-east-1c"},
}

// MainSystem represents the main hosted Vespa system.
var MainSystem = System{
	Name:         "main",
	URL:          "https://api.vespa.ouryahoo.com:4443",
	ConsoleURL:   "https://console.vespa.ouryahoo.com",
	DefaultZone:  ZoneID{Environment: "dev", Region: "us-east-1"},
	AthenzDomain: "vespa.vespa",
}

// CDSystem represents the CD variant of the hosted Vespa system.
var CDSystem = System{
	Name:         "cd",
	URL:          "https://api-cd.vespa.ouryahoo.com:4443",
	ConsoleURL:   "https://console-cd.vespa.ouryahoo.com",
	DefaultZone:  ZoneID{Environment: "dev", Region: "cd-us-west-1"},
	AthenzDomain: "vespa.vespa.cd",
}

// System represents a Vespa system.
type System struct {
	Name string
	// URL is the API URL for this system.
	URL        string
	ConsoleURL string
	// DefaultZone is default zone to use in manual deployments to this system.
	DefaultZone ZoneID
	// AthenzDomain is the Athenz domain used by this system. This is empty for systems not using Athenz for tenant
	// authentication.
	AthenzDomain string
}

// IsPublic returns whether system s is a public (Vespa Cloud) system.
func (s *System) IsPublic() bool { return s.Name == PublicSystem.Name || s.Name == PublicCDSystem.Name }

// GetSystem returns the system of given name.
func GetSystem(name string) (System, error) {
	switch name {
	case "cd":
		return CDSystem, nil
	case "main":
		return MainSystem, nil
	case "public":
		return PublicSystem, nil
	case "publiccd":
		return PublicCDSystem, nil
	}
	return System{}, fmt.Errorf("invalid system: %s", name)
}