blob: 463d9edcdad937a54246464c04b6eb4b0a518ea9 (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
import java.util.Objects;
/**
* Properties of the cloud service where the zone is deployed.
*
* @author mpolden
*/
public class Cloud {
private final CloudName name;
private final boolean dynamicProvisioning;
private final boolean allowHostSharing;
private final boolean allowEnclave;
private final boolean requireAccessControl;
private final CloudAccount account;
private Cloud(CloudName name, boolean dynamicProvisioning, boolean allowHostSharing, boolean allowEnclave,
boolean requireAccessControl, CloudAccount account) {
this.name = Objects.requireNonNull(name);
this.dynamicProvisioning = dynamicProvisioning;
this.allowHostSharing = allowHostSharing;
this.allowEnclave = allowEnclave;
this.requireAccessControl = requireAccessControl;
this.account = Objects.requireNonNull(account);
if (allowEnclave && account.isUnspecified()) {
throw new IllegalArgumentException("Account must be non-empty in '" + name + "'");
}
}
/** The name of this */
public CloudName name() {
return name;
}
/** Returns whether this can provision hosts dynamically */
public boolean dynamicProvisioning() {
return dynamicProvisioning;
}
/** Returns whether this allows host sharing */
public boolean allowHostSharing() { return allowHostSharing; }
/** Returns whether this allows deployments to enclave */
public boolean allowEnclave() { return allowEnclave; }
/** Returns whether to require access control for all clusters in this */
public boolean requireAccessControl() {
return requireAccessControl;
}
/** Returns the default account of this cloud */
public CloudAccount account() {
return account;
}
/** Returns whether load balancers use proxy protocol v1 or not (e.g. use source NAT). */
public boolean useProxyProtocol() {
return !name.equals(CloudName.AZURE);
}
/** For testing purposes only */
public static Cloud defaultCloud() {
return new Builder().build();
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private CloudName name = CloudName.DEFAULT;
private boolean dynamicProvisioning = false;
private boolean allowHostSharing = true;
private boolean allowEnclave = false;
private boolean requireAccessControl = false;
private CloudAccount account = CloudAccount.empty;
public Builder() {}
public Builder name(CloudName name) {
this.name = name;
return this;
}
public Builder dynamicProvisioning(boolean dynamicProvisioning) {
this.dynamicProvisioning = dynamicProvisioning;
return this;
}
public Builder allowHostSharing(boolean allowHostSharing) {
this.allowHostSharing = allowHostSharing;
return this;
}
public Builder allowEnclave(boolean allowEnclave) {
this.allowEnclave = allowEnclave;
return this;
}
public Builder requireAccessControl(boolean requireAccessControl) {
this.requireAccessControl = requireAccessControl;
return this;
}
public Builder account(CloudAccount account) {
this.account = account;
return this;
}
public Cloud build() {
return new Cloud(name, dynamicProvisioning, allowHostSharing, allowEnclave, requireAccessControl, account);
}
}
@Override
public String toString() {
return "cloud " + name;
}
}
|