blob: 1cb15818ff356826eb62ef8878c85f8946727192 (
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
|
// 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.Arrays;
/**
* Environments in hosted Vespa.
*
* @author bratseth
*/
public enum Environment {
/** The environment in which any external or internal applications serve actual requests */
prod,
/** Production-like environment which runs staging tests before an app is deployed to production */
staging,
/** Environment for running system tests before an app is deployed to staging */
test,
/** Environment used by individual developers to experiment */
dev,
/** Environment used to run performance and stability experiments */
perf;
/** Returns whether deployments to this environment are done manually */
public boolean isManuallyDeployed() { return this == dev || this == perf; }
/** Returns whether this environment is for automated tests */
public boolean isTest() { return this == test || this == staging; }
/** Returns whether this environment is production (prod) */
public boolean isProduction() { return this == prod; }
/** Returns whether this environment can exist in multiple regions. @deprecated they all are */
@Deprecated // TODO: Remove after June 2023
public boolean isMultiRegion() { return true; }
/** Returns the prod environment. This is useful for non-hosted properties where we just need any consistent value */
public static Environment defaultEnvironment() { return prod; }
/** Returns whether this is one of the given environments */
public boolean isAnyOf(Environment ... environments) {
return Arrays.stream(environments).anyMatch(e -> e == this);
}
/** Returns the environment name from the string value returned by value() */
public static Environment from(String value) {
return switch (value) {
case "prod" -> prod;
case "staging" -> staging;
case "test" -> test;
case "dev" -> dev;
case "perf" -> perf;
default -> throw new IllegalArgumentException("'" + value + "' is not a valid environment identifier");
};
}
/** Returns a name of this which is used in external API's and stored in persistent stores */
public String value() {
return switch (this) {
case prod -> "prod";
case staging -> "staging";
case test -> "test";
case dev -> "dev";
case perf -> "perf";
};
}
}
|