зеркало из https://github.com/Azure/aks-engine.git
[API] Change how orchestratorVersion is handled (#1108)
* introduce OrchestratorVersionHint * replace places with OrchestratorVersion with OrchestratorVersionHint, and build pass * fill in OrchestratorVersion when converttoapi * fix test * use go-version instead of VersionOrdinal * use k8sVersion instead of k8sVersionHint in comparison * remove duplicate consts, use common * split KubeImagee into images and configs * fix more KubernetesVersion referring * style and deadcode fixes * kube config validate needs version hint string * need string literal to refer to v “1.5.3” * enforcing default “” orchestratorVersion in apiloader * gomega unused in engine_test.go * s/VersionHint/Release replacing the term “VersionHint” with “Release” throughout * chore(gofmt) * chore(glide) go-version * rationalized KubeConfigs - added pkg/acsengine/api.KubernetesReleaseToVersion as a map from major.minor “release” to specific “version”; replaced old usages of `api.KubeImages[<version>][”version”] with `api.KubernetesReleaseToVersion[<version>]` - removed api.KubeImages - all version-specific k8s config now derive from pkg/acsengine.KubeConfigs * calico 1.5 logic now uses OrchestratorRelease * make upgrade scenario working again * fix upgrade test * fix more for upgrade scenario * fix release to versin mapping to 1.7.2
This commit is contained in:
Родитель
2cfe3d1731
Коммит
a60cde2976
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.7.3"
|
||||
"orchestratorRelease": "1.7"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.8.4"
|
||||
"orchestratorRelease": "1.8"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.8.8"
|
||||
"orchestratorRelease": "1.8"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.9.0"
|
||||
"orchestratorRelease": "1.9"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.5.3"
|
||||
"orchestratorRelease": "1.5"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.5.7"
|
||||
"orchestratorRelease": "1.5"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.2"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.7.1"
|
||||
"orchestratorRelease": "1.7"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6",
|
||||
"orchestratorRelease": "1.6",
|
||||
"kubernetesConfig": {
|
||||
"nodeStatusUpdateFrequency": "1m",
|
||||
"ctrlMgrNodeMonitorGracePeriod": "5m",
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
"apiVersion": "vlabs",
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.2"
|
||||
"orchestratorRelease": "1.6"
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.5.7"
|
||||
"orchestratorRelease": "1.5"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.2"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
hash: 8473d8ab8413c505104fa1abbf2dedb9464b7206cfe466cf793d29496776b216
|
||||
updated: 2017-07-31T18:11:55.156633291-07:00
|
||||
hash: 5df50308c509024912fc12bda5f9b15eb2661540f64b719707a403a2e52f659a
|
||||
updated: 2017-08-02T12:48:17.628000263-07:00
|
||||
imports:
|
||||
- name: github.com/alexcesaro/statsd
|
||||
version: 7fea3f0d2fab1ad973e641e51dba45443a311a90
|
||||
|
@ -34,6 +34,8 @@ imports:
|
|||
- currency
|
||||
- name: github.com/go-playground/universal-translator
|
||||
version: b32fa301c9fe55953584134cb6853a13c87ec0a1
|
||||
- name: github.com/hashicorp/go-version
|
||||
version: 03c5bf6be031b6dd45afec16b1cf94fc8938bc77
|
||||
- name: github.com/inconshreveable/mousetrap
|
||||
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
|
||||
- name: github.com/JiangtianLi/gettext
|
||||
|
|
|
@ -50,3 +50,4 @@ testImport:
|
|||
version: v1.1.0
|
||||
- package: github.com/onsi/ginkgo
|
||||
version: v1.3.1
|
||||
- package: github.com/hashicorp/go-version
|
|
@ -180,7 +180,7 @@
|
|||
},
|
||||
"type": "Microsoft.Network/loadBalancers/inboundNatRules"
|
||||
},
|
||||
{{if IsDCOS190}}
|
||||
{{if IsDCOS19}}
|
||||
{
|
||||
"apiVersion": "[variables('apiVersionDefault')]",
|
||||
"dependsOn": [
|
||||
|
@ -207,7 +207,7 @@
|
|||
"name": "[variables('masterNSGName')]",
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{{if IsDCOS190}}
|
||||
{{if IsDCOS19}}
|
||||
{
|
||||
"properties": {
|
||||
"priority": 201,
|
||||
|
@ -281,7 +281,7 @@
|
|||
"[variables('vnetID')]",
|
||||
{{end}}
|
||||
"[variables('masterLbID')]",
|
||||
{{if IsDCOS190}}
|
||||
{{if IsDCOS19}}
|
||||
"[concat(variables('masterLbID'),'/inboundNatRules/SSHPort22-',variables('masterVMNamePrefix'),0)]",
|
||||
{{end}}
|
||||
"[concat(variables('masterLbID'),'/inboundNatRules/SSH-',variables('masterVMNamePrefix'),copyIndex())]"
|
||||
|
@ -298,7 +298,7 @@
|
|||
"id": "[concat(variables('masterLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"
|
||||
}
|
||||
],
|
||||
{{if IsDCOS190}}
|
||||
{{if IsDCOS19}}
|
||||
"loadBalancerInboundNatRules": "[variables('masterLbInboundNatRules')[copyIndex()]]",
|
||||
{{else}}
|
||||
"loadBalancerInboundNatRules": [
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
"[parameters('location')]"
|
||||
],
|
||||
"location": "[variables('locations')[mod(add(2,length(parameters('location'))),add(1,length(parameters('location'))))]]",
|
||||
{{if IsDCOS190}}
|
||||
{{if IsDCOS19}}
|
||||
"masterSshInboundNatRuleIdPrefix": "[concat(variables('masterLbID'),'/inboundNatRules/SSH-',variables('masterVMNamePrefix'))]",
|
||||
"masterSshPort22InboundNatRuleIdPrefix": "[concat(variables('masterLbID'),'/inboundNatRules/SSHPort22-',variables('masterVMNamePrefix'))]",
|
||||
"masterLbInboundNatRules": [
|
||||
|
|
|
@ -80,9 +80,11 @@ const (
|
|||
DCOSPublicAgent DCOSNodeType = "DCOSPublicAgent"
|
||||
)
|
||||
|
||||
// KubeImages represents Docker images used for Kubernetes components based on Kubernetes version
|
||||
var KubeImages = map[string]map[string]string{
|
||||
api.Kubernetes172: {
|
||||
// KubeConfigs represents Docker images used for Kubernetes components based on Kubernetes releases (major.minor)
|
||||
// For instance, Kubernetes release "1.7" would contain the version "1.7.2"
|
||||
var KubeConfigs = map[string]map[string]string{
|
||||
api.KubernetesRelease1Dot7: {
|
||||
"version": "1.7.2",
|
||||
"hyperkube": "hyperkube-amd64:v1.7.2",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
|
@ -105,53 +107,7 @@ var KubeImages = map[string]map[string]string{
|
|||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
},
|
||||
api.Kubernetes171: {
|
||||
"hyperkube": "hyperkube-amd64:v1.7.1",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
"addonresizer": "addon-resizer:1.7",
|
||||
"heapster": "heapster:v1.4.0",
|
||||
"dns": "k8s-dns-kube-dns-amd64:1.14.4",
|
||||
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
|
||||
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.14.4",
|
||||
"pause": "pause-amd64:3.0",
|
||||
"tiller": DefaultTillerImage,
|
||||
"windowszip": "v1.7.1intwinnat.zip",
|
||||
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
|
||||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
},
|
||||
api.Kubernetes170: {
|
||||
"hyperkube": "hyperkube-amd64:v1.7.0",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
"addonresizer": "addon-resizer:1.7",
|
||||
"heapster": "heapster:v1.4.0",
|
||||
"dns": "k8s-dns-kube-dns-amd64:1.14.4",
|
||||
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
|
||||
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.14.4",
|
||||
"pause": "pause-amd64:3.0",
|
||||
"tiller": DefaultTillerImage,
|
||||
"windowszip": "v1.7.0intwinnat.zip",
|
||||
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
|
||||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
},
|
||||
api.Kubernetes166: {
|
||||
api.KubernetesRelease1Dot6: {
|
||||
"hyperkube": "hyperkube-amd64:v1.6.6",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
|
@ -174,43 +130,7 @@ var KubeImages = map[string]map[string]string{
|
|||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
},
|
||||
api.Kubernetes162: {
|
||||
"hyperkube": "hyperkube-amd64:v1.6.2",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
"addonresizer": "addon-resizer:1.6",
|
||||
"heapster": "heapster:v1.2.0",
|
||||
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
|
||||
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
|
||||
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
|
||||
"pause": "pause-amd64:3.0",
|
||||
"tiller": DefaultTillerImage,
|
||||
"windowszip": "v1.6.2intwinnat.zip",
|
||||
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
|
||||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
},
|
||||
|
||||
api.Kubernetes160: {
|
||||
"hyperkube": "hyperkube-amd64:v1.6.0",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
"addonresizer": "addon-resizer:1.6",
|
||||
"heapster": "heapster:v1.2.0",
|
||||
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
|
||||
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
|
||||
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
|
||||
"pause": "pause-amd64:3.0",
|
||||
"tiller": DefaultTillerImage,
|
||||
"windowszip": "v1.6.0intwinnat.zip",
|
||||
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
|
||||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
},
|
||||
|
||||
api.Kubernetes157: {
|
||||
api.KubernetesRelease1Dot5: {
|
||||
"hyperkube": "hyperkube-amd64:v1.5.7",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
|
@ -227,24 +147,6 @@ var KubeImages = map[string]map[string]string{
|
|||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
},
|
||||
|
||||
api.Kubernetes153: {
|
||||
"hyperkube": "hyperkube-amd64:v1.5.3",
|
||||
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
|
||||
"exechealthz": "exechealthz-amd64:1.2",
|
||||
"addonresizer": "addon-resizer:1.6",
|
||||
"heapster": "heapster:v1.2.0",
|
||||
"dns": "kubedns-amd64:1.7",
|
||||
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
|
||||
"dnsmasq": "kube-dnsmasq-amd64:1.3",
|
||||
"pause": "pause-amd64:3.0",
|
||||
"windowszip": "v1.5.3intwinnat.zip",
|
||||
"tiller": DefaultTillerImage,
|
||||
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
|
||||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
},
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
version "github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -23,8 +24,6 @@ var (
|
|||
|
||||
DCOSSpecConfig: DCOSSpecConfig{
|
||||
DCOS173BootstrapDownloadURL: fmt.Sprintf(MsecndDCOSBootstrapDownloadURL, "testing", "df308b6fc3bd91e1277baa5a3db928ae70964722"),
|
||||
DCOS184BootstrapDownloadURL: fmt.Sprintf(AzureEdgeDCOSBootstrapDownloadURL, "testing", "5b4aa43610c57ee1d60b4aa0751a1fb75824c083"),
|
||||
DCOS187BootstrapDownloadURL: fmt.Sprintf(AzureEdgeDCOSBootstrapDownloadURL, "stable", "e73ba2b1cd17795e4dcb3d6647d11a29b9c35084"),
|
||||
DCOS188BootstrapDownloadURL: fmt.Sprintf(AzureEdgeDCOSBootstrapDownloadURL, "stable", "5df43052907c021eeb5de145419a3da1898c58a5"),
|
||||
DCOS190BootstrapDownloadURL: fmt.Sprintf(AzureEdgeDCOSBootstrapDownloadURL, "stable", "58fd0833ce81b6244fc73bf65b5deb43217b0bd7"),
|
||||
},
|
||||
|
@ -43,8 +42,6 @@ var (
|
|||
},
|
||||
DCOSSpecConfig: DCOSSpecConfig{
|
||||
DCOS173BootstrapDownloadURL: fmt.Sprintf(AzureChinaCloudDCOSBootstrapDownloadURL, "df308b6fc3bd91e1277baa5a3db928ae70964722"),
|
||||
DCOS184BootstrapDownloadURL: fmt.Sprintf(AzureChinaCloudDCOSBootstrapDownloadURL, "5b4aa43610c57ee1d60b4aa0751a1fb75824c083"),
|
||||
DCOS187BootstrapDownloadURL: fmt.Sprintf(AzureChinaCloudDCOSBootstrapDownloadURL, "e73ba2b1cd17795e4dcb3d6647d11a29b9c35084"),
|
||||
DCOS188BootstrapDownloadURL: fmt.Sprintf(AzureChinaCloudDCOSBootstrapDownloadURL, "5df43052907c021eeb5de145419a3da1898c58a5"),
|
||||
},
|
||||
}
|
||||
|
@ -76,7 +73,7 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
|
|||
|
||||
cloudSpecConfig := GetCloudSpecConfig(location)
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
k8sVersion := a.OrchestratorProfile.OrchestratorVersion
|
||||
k8sRelease := a.OrchestratorProfile.OrchestratorRelease
|
||||
if a.OrchestratorProfile.KubernetesConfig == nil {
|
||||
a.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
|
||||
}
|
||||
|
@ -96,16 +93,16 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
|
|||
a.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
|
||||
}
|
||||
if a.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency = KubeImages[k8sVersion]["nodestatusfreq"]
|
||||
a.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency = KubeConfigs[k8sRelease]["nodestatusfreq"]
|
||||
}
|
||||
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod = KubeImages[k8sVersion]["nodegraceperiod"]
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod = KubeConfigs[k8sRelease]["nodegraceperiod"]
|
||||
}
|
||||
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout = KubeImages[k8sVersion]["podeviction"]
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout = KubeConfigs[k8sRelease]["podeviction"]
|
||||
}
|
||||
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod = KubeImages[k8sVersion]["routeperiod"]
|
||||
a.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod = KubeConfigs[k8sRelease]["routeperiod"]
|
||||
}
|
||||
// Enforce sane cloudprovider backoff defaults, if CloudProviderBackoff is true in KubernetesConfig
|
||||
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff == true {
|
||||
|
@ -122,8 +119,11 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
|
|||
a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffRetries = DefaultKubernetesCloudProviderBackoffRetries
|
||||
}
|
||||
}
|
||||
k8sVersion, _ := version.NewVersion(api.KubernetesReleaseToVersion[k8sRelease])
|
||||
minVersionK8sVersionForCloudProviderRateLimit, _ := version.NewVersion("1.6.6")
|
||||
// Enforce sane cloudprovider rate limit defaults, if CloudProviderRateLimit is true in KubernetesConfig
|
||||
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit == true && (k8sVersion == api.Kubernetes172 || k8sVersion == api.Kubernetes171 || k8sVersion == api.Kubernetes170 || k8sVersion == api.Kubernetes166) {
|
||||
// For k8s version greater or equal to 1.6.6, we will set the default CloudProviderRate* settings
|
||||
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit == true && k8sVersion.Compare(minVersionK8sVersionForCloudProviderRateLimit) != -1 {
|
||||
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS == 0 {
|
||||
a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS = DefaultKubernetesCloudProviderRateLimitQPS
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
"github.com/ghodss/yaml"
|
||||
goversion "github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -30,8 +31,6 @@ const (
|
|||
|
||||
const (
|
||||
dcosCustomData173 = "dcoscustomdata173.t"
|
||||
dcosCustomData184 = "dcoscustomdata184.t"
|
||||
dcosCustomData187 = "dcoscustomdata187.t"
|
||||
dcosCustomData188 = "dcoscustomdata188.t"
|
||||
dcosCustomData190 = "dcoscustomdata190.t"
|
||||
dcosProvision = "dcosprovision.sh"
|
||||
|
@ -389,9 +388,9 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (paramsMap, err
|
|||
cloudSpecConfig := GetCloudSpecConfig(location)
|
||||
// Kubernetes Parameters
|
||||
if properties.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
KubernetesVersion := properties.OrchestratorProfile.OrchestratorVersion
|
||||
KubernetesRelease := properties.OrchestratorProfile.OrchestratorRelease
|
||||
|
||||
kubernetesHyperkubeSpec := properties.OrchestratorProfile.KubernetesConfig.KubernetesImageBase + KubeImages[KubernetesVersion]["hyperkube"]
|
||||
kubernetesHyperkubeSpec := properties.OrchestratorProfile.KubernetesConfig.KubernetesImageBase + KubeConfigs[KubernetesRelease]["hyperkube"]
|
||||
if properties.OrchestratorProfile.KubernetesConfig.CustomHyperkubeImage != "" {
|
||||
kubernetesHyperkubeSpec = properties.OrchestratorProfile.KubernetesConfig.CustomHyperkubeImage
|
||||
}
|
||||
|
@ -406,15 +405,15 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (paramsMap, err
|
|||
addSecret(parametersMap, "kubeConfigPrivateKey", properties.CertificateProfile.KubeConfigPrivateKey, true)
|
||||
addValue(parametersMap, "dockerEngineDownloadRepo", cloudSpecConfig.DockerSpecConfig.DockerEngineRepo)
|
||||
addValue(parametersMap, "kubernetesHyperkubeSpec", kubernetesHyperkubeSpec)
|
||||
addValue(parametersMap, "kubernetesAddonManagerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["addonmanager"])
|
||||
addValue(parametersMap, "kubernetesAddonResizerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["addonresizer"])
|
||||
addValue(parametersMap, "kubernetesDashboardSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["dashboard"])
|
||||
addValue(parametersMap, "kubernetesDNSMasqSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["dnsmasq"])
|
||||
addValue(parametersMap, "kubernetesExecHealthzSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["exechealthz"])
|
||||
addValue(parametersMap, "kubernetesHeapsterSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["heapster"])
|
||||
addValue(parametersMap, "kubernetesTillerSpec", cloudSpecConfig.KubernetesSpecConfig.TillerImageBase+KubeImages[KubernetesVersion]["tiller"])
|
||||
addValue(parametersMap, "kubernetesKubeDNSSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["dns"])
|
||||
addValue(parametersMap, "kubernetesPodInfraContainerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["pause"])
|
||||
addValue(parametersMap, "kubernetesAddonManagerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["addonmanager"])
|
||||
addValue(parametersMap, "kubernetesAddonResizerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["addonresizer"])
|
||||
addValue(parametersMap, "kubernetesDashboardSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["dashboard"])
|
||||
addValue(parametersMap, "kubernetesDNSMasqSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["dnsmasq"])
|
||||
addValue(parametersMap, "kubernetesExecHealthzSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["exechealthz"])
|
||||
addValue(parametersMap, "kubernetesHeapsterSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["heapster"])
|
||||
addValue(parametersMap, "kubernetesTillerSpec", cloudSpecConfig.KubernetesSpecConfig.TillerImageBase+KubeConfigs[KubernetesRelease]["tiller"])
|
||||
addValue(parametersMap, "kubernetesKubeDNSSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["dns"])
|
||||
addValue(parametersMap, "kubernetesPodInfraContainerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["pause"])
|
||||
addValue(parametersMap, "kubernetesNodeStatusUpdateFrequency", properties.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency)
|
||||
addValue(parametersMap, "kubernetesCtrlMgrNodeMonitorGracePeriod", properties.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod)
|
||||
addValue(parametersMap, "kubernetesCtrlMgrPodEvictionTimeout", properties.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout)
|
||||
|
@ -442,20 +441,16 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (paramsMap, err
|
|||
}
|
||||
}
|
||||
|
||||
if strings.HasPrefix(string(properties.OrchestratorProfile.OrchestratorType), string(api.DCOS)) {
|
||||
if strings.HasPrefix(properties.OrchestratorProfile.OrchestratorType, api.DCOS) {
|
||||
dcosBootstrapURL := cloudSpecConfig.DCOSSpecConfig.DCOS188BootstrapDownloadURL
|
||||
switch properties.OrchestratorProfile.OrchestratorType {
|
||||
case api.DCOS:
|
||||
switch properties.OrchestratorProfile.OrchestratorVersion {
|
||||
case api.DCOS173:
|
||||
switch properties.OrchestratorProfile.OrchestratorRelease {
|
||||
case api.DCOSRelease1Dot7:
|
||||
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS173BootstrapDownloadURL
|
||||
case api.DCOS184:
|
||||
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS184BootstrapDownloadURL
|
||||
case api.DCOS187:
|
||||
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS187BootstrapDownloadURL
|
||||
case api.DCOS188:
|
||||
case api.DCOSRelease1Dot8:
|
||||
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS188BootstrapDownloadURL
|
||||
case api.DCOS190:
|
||||
case api.DCOSRelease1Dot9:
|
||||
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS190BootstrapDownloadURL
|
||||
}
|
||||
}
|
||||
|
@ -481,9 +476,9 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (paramsMap, err
|
|||
addValue(parametersMap, "windowsAdminUsername", properties.WindowsProfile.AdminUsername)
|
||||
addSecret(parametersMap, "windowsAdminPassword", properties.WindowsProfile.AdminPassword, false)
|
||||
if properties.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
KubernetesVersion := properties.OrchestratorProfile.OrchestratorVersion
|
||||
addValue(parametersMap, "kubeBinariesSASURL", cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase+KubeImages[KubernetesVersion]["windowszip"])
|
||||
addValue(parametersMap, "kubeBinariesVersion", KubernetesVersion)
|
||||
KubernetesRelease := properties.OrchestratorProfile.OrchestratorRelease
|
||||
addValue(parametersMap, "kubeBinariesSASURL", cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase+KubeConfigs[KubernetesRelease]["windowszip"])
|
||||
addValue(parametersMap, "kubeBinariesVersion", api.KubernetesReleaseToVersion[KubernetesRelease])
|
||||
}
|
||||
for i, s := range properties.WindowsProfile.Secrets {
|
||||
addValue(parametersMap, fmt.Sprintf("windowsKeyVaultID%d", i), s.SourceVault.ID)
|
||||
|
@ -530,36 +525,6 @@ func addSecret(m paramsMap, k string, v interface{}, encode bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// VersionOrdinal checks equality between two orchestrator version numbers
|
||||
func VersionOrdinal(version string) string {
|
||||
// ISO/IEC 14651:2011
|
||||
const maxByte = 1<<8 - 1
|
||||
vo := make([]byte, 0, len(version)+8)
|
||||
j := -1
|
||||
for i := 0; i < len(version); i++ {
|
||||
b := version[i]
|
||||
if '0' > b || b > '9' {
|
||||
vo = append(vo, b)
|
||||
j = -1
|
||||
continue
|
||||
}
|
||||
if j == -1 {
|
||||
vo = append(vo, 0x00)
|
||||
j = len(vo) - 1
|
||||
}
|
||||
if vo[j] == 1 && vo[j+1] == '0' {
|
||||
vo[j+1] = b
|
||||
continue
|
||||
}
|
||||
if vo[j]+1 > maxByte {
|
||||
panic("VersionOrdinal: invalid version")
|
||||
}
|
||||
vo = append(vo, b)
|
||||
vo[j]++
|
||||
}
|
||||
return string(vo)
|
||||
}
|
||||
|
||||
// getStorageAccountType returns the support managed disk storage tier for a give VM size
|
||||
func getStorageAccountType(sizeName string) (string, error) {
|
||||
spl := strings.Split(sizeName, "_")
|
||||
|
@ -576,32 +541,15 @@ func getStorageAccountType(sizeName string) (string, error) {
|
|||
// getTemplateFuncMap returns all functions used in template generation
|
||||
func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"IsDCOS173": func() bool {
|
||||
"IsDCOS19": func() bool {
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS &&
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion == api.DCOS173
|
||||
},
|
||||
"IsDCOS184": func() bool {
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS &&
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion == api.DCOS184
|
||||
},
|
||||
"IsDCOS187": func() bool {
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS &&
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion == api.DCOS187
|
||||
},
|
||||
"IsDCOS188": func() bool {
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS &&
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion == api.DCOS188
|
||||
},
|
||||
"IsDCOS190": func() bool {
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS &&
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion == api.DCOS190
|
||||
cs.Properties.OrchestratorProfile.OrchestratorRelease == api.DCOSRelease1Dot9
|
||||
},
|
||||
"IsKubernetesVersionGe": func(version string) bool {
|
||||
targetVersion := version
|
||||
targetVersionOrdinal := VersionOrdinal(targetVersion)
|
||||
orchestratorVersionOrdinal := VersionOrdinal(cs.Properties.OrchestratorProfile.OrchestratorVersion)
|
||||
targetVersion, _ := goversion.NewVersion(version)
|
||||
orchestratorVersion, _ := goversion.NewVersion(cs.Properties.OrchestratorProfile.OrchestratorVersion)
|
||||
return cs.Properties.OrchestratorProfile.OrchestratorType == api.Kubernetes &&
|
||||
orchestratorVersionOrdinal >= targetVersionOrdinal
|
||||
orchestratorVersion.Compare(targetVersion) != -1
|
||||
},
|
||||
"GetKubernetesLabels": func(profile *api.AgentPoolProfile) string {
|
||||
var buf bytes.Buffer
|
||||
|
@ -664,14 +612,20 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
"GetDCOSMasterCustomData": func() string {
|
||||
masterProvisionScript := getDCOSMasterProvisionScript()
|
||||
masterAttributeContents := getDCOSMasterCustomNodeLabels()
|
||||
str := getSingleLineDCOSCustomData(cs.Properties.OrchestratorProfile.OrchestratorType, cs.Properties.OrchestratorProfile.OrchestratorVersion, cs.Properties.MasterProfile.Count, masterProvisionScript, masterAttributeContents)
|
||||
str := getSingleLineDCOSCustomData(
|
||||
cs.Properties.OrchestratorProfile.OrchestratorType,
|
||||
cs.Properties.OrchestratorProfile.OrchestratorRelease,
|
||||
cs.Properties.MasterProfile.Count, masterProvisionScript, masterAttributeContents)
|
||||
|
||||
return fmt.Sprintf("\"customData\": \"[base64(concat('#cloud-config\\n\\n', '%s'))]\",", str)
|
||||
},
|
||||
"GetDCOSAgentCustomData": func(profile *api.AgentPoolProfile) string {
|
||||
agentProvisionScript := getDCOSAgentProvisionScript(profile)
|
||||
attributeContents := getDCOSAgentCustomNodeLabels(profile)
|
||||
str := getSingleLineDCOSCustomData(cs.Properties.OrchestratorProfile.OrchestratorType, cs.Properties.OrchestratorProfile.OrchestratorVersion, cs.Properties.MasterProfile.Count, agentProvisionScript, attributeContents)
|
||||
str := getSingleLineDCOSCustomData(
|
||||
cs.Properties.OrchestratorProfile.OrchestratorType,
|
||||
cs.Properties.OrchestratorProfile.OrchestratorRelease,
|
||||
cs.Properties.MasterProfile.Count, agentProvisionScript, attributeContents)
|
||||
|
||||
return fmt.Sprintf("\"customData\": \"[base64(concat('#cloud-config\\n\\n', '%s'))]\",", str)
|
||||
},
|
||||
|
@ -727,8 +681,7 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
}
|
||||
|
||||
var addonYamls map[string]string
|
||||
if profile.OrchestratorProfile.OrchestratorVersion == api.Kubernetes153 ||
|
||||
profile.OrchestratorProfile.OrchestratorVersion == api.Kubernetes157 {
|
||||
if profile.OrchestratorProfile.OrchestratorRelease == api.KubernetesRelease1Dot5 {
|
||||
addonYamls = kubernetesAddonYamls15
|
||||
} else {
|
||||
addonYamls = kubernetesAddonYamls
|
||||
|
@ -740,8 +693,7 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
|
||||
// add calico manifests
|
||||
if profile.OrchestratorProfile.KubernetesConfig.NetworkPolicy == "calico" {
|
||||
if profile.OrchestratorProfile.OrchestratorVersion == api.Kubernetes153 ||
|
||||
profile.OrchestratorProfile.OrchestratorVersion == api.Kubernetes157 {
|
||||
if profile.OrchestratorProfile.OrchestratorRelease == api.KubernetesRelease1Dot5 {
|
||||
calicoAddonYamls = calicoAddonYamls15
|
||||
}
|
||||
for placeholder, filename := range calicoAddonYamls {
|
||||
|
@ -855,28 +807,28 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
cloudSpecConfig := GetCloudSpecConfig(cs.Location)
|
||||
switch attr {
|
||||
case "kubernetesHyperkubeSpec":
|
||||
val = cs.Properties.OrchestratorProfile.KubernetesConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["hyperkube"]
|
||||
val = cs.Properties.OrchestratorProfile.KubernetesConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["hyperkube"]
|
||||
if cs.Properties.OrchestratorProfile.KubernetesConfig.CustomHyperkubeImage != "" {
|
||||
val = cs.Properties.OrchestratorProfile.KubernetesConfig.CustomHyperkubeImage
|
||||
}
|
||||
case "kubernetesAddonManagerSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["addonmanager"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["addonmanager"]
|
||||
case "kubernetesAddonResizerSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["addonresizer"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["addonresizer"]
|
||||
case "kubernetesDashboardSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["dashboard"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["dashboard"]
|
||||
case "kubernetesDNSMasqSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["dnsmasq"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["dnsmasq"]
|
||||
case "kubernetesExecHealthzSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["exechealthz"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["exechealthz"]
|
||||
case "kubernetesHeapsterSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["heapster"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["heapster"]
|
||||
case "kubernetesTillerSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.TillerImageBase + KubeImages[kubernetesVersion]["tiller"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.TillerImageBase + KubeConfigs[kubernetesVersion]["tiller"]
|
||||
case "kubernetesKubeDNSSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["dns"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["dns"]
|
||||
case "kubernetesPodInfraContainerSpec":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["pause"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[kubernetesVersion]["pause"]
|
||||
case "kubernetesNodeStatusUpdateFrequency":
|
||||
val = cs.Properties.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency
|
||||
case "kubernetesCtrlMgrNodeMonitorGracePeriod":
|
||||
|
@ -902,11 +854,11 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
case "cloudProviderRatelimitBucket":
|
||||
val = strconv.Itoa(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitBucket)
|
||||
case "kubeBinariesSASURL":
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + KubeImages[kubernetesVersion]["windowszip"]
|
||||
val = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + KubeConfigs[kubernetesVersion]["windowszip"]
|
||||
case "kubeClusterCidr":
|
||||
val = "10.244.0.0/16"
|
||||
case "kubeBinariesVersion":
|
||||
val = string(api.KubernetesDefaultVersion)
|
||||
val = api.KubernetesReleaseToVersion[cs.Properties.OrchestratorProfile.OrchestratorRelease]
|
||||
case "caPrivateKey":
|
||||
// The base64 encoded "NotAvailable"
|
||||
val = "Tm90QXZhaWxhYmxlCg=="
|
||||
|
@ -943,51 +895,36 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
}
|
||||
}
|
||||
|
||||
func getPackageGUID(orchestratorType string, orchestratorVersion string, masterCount int) string {
|
||||
if orchestratorType == api.DCOS && orchestratorVersion == api.DCOS190 {
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "bcc883b7a3191412cf41824bdee06c1142187a0b"
|
||||
case 3:
|
||||
return "dcff7e24c0c1827bebeb7f1a806f558054481b33"
|
||||
case 5:
|
||||
return "b41bfa84137a6374b2ff5eb1655364d7302bd257"
|
||||
}
|
||||
} else if orchestratorType == api.DCOS && orchestratorVersion == api.DCOS188 {
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "441385ce2f5942df7e29075c12fb38fa5e92cbba"
|
||||
case 3:
|
||||
return "b1cd359287504efb780257bd12cc3a63704e42d4"
|
||||
case 5:
|
||||
return "d9b61156dfcc9383e014851529738aa550ef57d9"
|
||||
}
|
||||
} else if orchestratorType == api.DCOS && orchestratorVersion == api.DCOS187 {
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "556978041b6ed059cc0f474501083e35ea5645b8"
|
||||
case 3:
|
||||
return "1eb387eda0403c7fd6f1dacf66e530be74c3c3de"
|
||||
case 5:
|
||||
return "2e38627207dc70f46296b9649f9ee2a43500ec15"
|
||||
}
|
||||
} else if orchestratorType == api.DCOS && orchestratorVersion == api.DCOS184 {
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "5ac6a7d060584c58c704e1f625627a591ecbde4e"
|
||||
case 3:
|
||||
return "42bd1d74e9a2b23836bd78919c716c20b98d5a0e"
|
||||
case 5:
|
||||
return "97947a91e2c024ed4f043bfcdad49da9418d3095"
|
||||
}
|
||||
} else if orchestratorType == api.DCOS && orchestratorVersion == api.DCOS173 {
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "6b604c1331c2b8b52bb23d1ea8a8d17e0f2b7428"
|
||||
case 3:
|
||||
return "6af5097e7956962a3d4318d28fbf280a47305485"
|
||||
case 5:
|
||||
return "376e07e0dbad2af3da2c03bc92bb07e84b3dafd5"
|
||||
func getPackageGUID(orchestratorType string, orchestratorRelease string, masterCount int) string {
|
||||
if orchestratorType == api.DCOS {
|
||||
switch orchestratorRelease {
|
||||
case api.DCOSRelease1Dot9:
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "bcc883b7a3191412cf41824bdee06c1142187a0b"
|
||||
case 3:
|
||||
return "dcff7e24c0c1827bebeb7f1a806f558054481b33"
|
||||
case 5:
|
||||
return "b41bfa84137a6374b2ff5eb1655364d7302bd257"
|
||||
}
|
||||
case api.DCOSRelease1Dot8:
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "441385ce2f5942df7e29075c12fb38fa5e92cbba"
|
||||
case 3:
|
||||
return "b1cd359287504efb780257bd12cc3a63704e42d4"
|
||||
case 5:
|
||||
return "d9b61156dfcc9383e014851529738aa550ef57d9"
|
||||
}
|
||||
case api.DCOSRelease1Dot7:
|
||||
switch masterCount {
|
||||
case 1:
|
||||
return "6b604c1331c2b8b52bb23d1ea8a8d17e0f2b7428"
|
||||
case 3:
|
||||
return "6af5097e7956962a3d4318d28fbf280a47305485"
|
||||
case 5:
|
||||
return "376e07e0dbad2af3da2c03bc92bb07e84b3dafd5"
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
@ -1308,20 +1245,16 @@ touch /etc/mesosphere/roles/azure_master`
|
|||
}
|
||||
|
||||
// getSingleLineForTemplate returns the file as a single line for embedding in an arm template
|
||||
func getSingleLineDCOSCustomData(orchestratorType string, orchestratorVersion string, masterCount int, provisionContent string, attributeContents string) string {
|
||||
func getSingleLineDCOSCustomData(orchestratorType string, orchestratorRelease string, masterCount int, provisionContent string, attributeContents string) string {
|
||||
yamlFilename := ""
|
||||
switch orchestratorType {
|
||||
case api.DCOS:
|
||||
switch orchestratorVersion {
|
||||
case api.DCOS173:
|
||||
switch orchestratorRelease {
|
||||
case api.DCOSRelease1Dot7:
|
||||
yamlFilename = dcosCustomData173
|
||||
case api.DCOS184:
|
||||
yamlFilename = dcosCustomData184
|
||||
case api.DCOS187:
|
||||
yamlFilename = dcosCustomData187
|
||||
case api.DCOS188:
|
||||
case api.DCOSRelease1Dot8:
|
||||
yamlFilename = dcosCustomData188
|
||||
case api.DCOS190:
|
||||
case api.DCOSRelease1Dot9:
|
||||
yamlFilename = dcosCustomData190
|
||||
}
|
||||
default:
|
||||
|
@ -1363,7 +1296,7 @@ func getSingleLineDCOSCustomData(orchestratorType string, orchestratorVersion st
|
|||
yamlStr = rVariable.ReplaceAllString(yamlStr, "',variables('$1'),'")
|
||||
|
||||
// replace the internal values
|
||||
guid := getPackageGUID(orchestratorType, orchestratorVersion, masterCount)
|
||||
guid := getPackageGUID(orchestratorType, orchestratorRelease, masterCount)
|
||||
yamlStr = strings.Replace(yamlStr, "DCOSGUID", guid, -1)
|
||||
publicIPStr := getDCOSCustomDataPublicIPStr(orchestratorType, masterCount)
|
||||
yamlStr = strings.Replace(yamlStr, "DCOSCUSTOMDATAPUBLICIPSTR", publicIPStr, -1)
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/Azure/acs-engine/pkg/api/vlabs"
|
||||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
"github.com/leonelquinteros/gotext"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -213,33 +212,6 @@ func addTestCertificateProfile(api *api.CertificateProfile) {
|
|||
api.KubeConfigPrivateKey = "kubeConfigPrivateKey"
|
||||
}
|
||||
|
||||
func TestVersionOrdinal(t *testing.T) {
|
||||
RegisterTestingT(t)
|
||||
v172 := "1.7.2"
|
||||
v171 := "1.7.1"
|
||||
v170 := "1.7.0"
|
||||
v166 := "1.6.6"
|
||||
v162 := "1.6.2"
|
||||
v160 := "1.6.0"
|
||||
v153 := "1.5.3"
|
||||
v16 := "1.6"
|
||||
|
||||
Expect(v171 < v172).To(BeTrue())
|
||||
Expect(v170 < v171).To(BeTrue())
|
||||
Expect(v166 < v170).To(BeTrue())
|
||||
Expect(v166 > v162).To(BeTrue())
|
||||
Expect(v162 < v166).To(BeTrue())
|
||||
Expect(v162 > v160).To(BeTrue())
|
||||
Expect(v160 < v162).To(BeTrue())
|
||||
Expect(v153 < v160).To(BeTrue())
|
||||
|
||||
//testing with different version length
|
||||
Expect(v171 > v162).To(BeTrue())
|
||||
Expect(v16 < v162).To(BeTrue())
|
||||
Expect(v16 > v153).To(BeTrue())
|
||||
|
||||
}
|
||||
|
||||
func TestGetStorageAccountType(t *testing.T) {
|
||||
validPremiumVMSize := "Standard_DS2_v2"
|
||||
validStandardVMSize := "Standard_D2_v2"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.5.3"
|
||||
"orchestratorRelease": "1.5"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.2"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.7.3"
|
||||
"orchestratorRelease": "1.7"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.8.4"
|
||||
"orchestratorRelease": "1.8"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.8.7"
|
||||
"orchestratorRelease": "1.8"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.8.8"
|
||||
"orchestratorRelease": "1.8"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "DCOS",
|
||||
"orchestratorVersion": "1.9.0"
|
||||
"orchestratorRelease": "1.9"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 3,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"properties": {
|
||||
"orchestratorProfile": {
|
||||
"orchestratorType": "Kubernetes",
|
||||
"orchestratorVersion": "1.6.6"
|
||||
"orchestratorRelease": "1.6"
|
||||
},
|
||||
"masterProfile": {
|
||||
"count": 1,
|
||||
|
|
|
@ -34,8 +34,6 @@ type DockerSpecConfig struct {
|
|||
//DCOSSpecConfig is the configurations of DCOS
|
||||
type DCOSSpecConfig struct {
|
||||
DCOS173BootstrapDownloadURL string
|
||||
DCOS184BootstrapDownloadURL string
|
||||
DCOS187BootstrapDownloadURL string
|
||||
DCOS188BootstrapDownloadURL string
|
||||
DCOS190BootstrapDownloadURL string
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ func (a *Apiloader) LoadContainerService(contents []byte, version string, valida
|
|||
if e := json.Unmarshal(contents, &containerService); e != nil {
|
||||
return nil, e
|
||||
}
|
||||
setContainerServiceDefaultsv20170701(containerService)
|
||||
if e := containerService.Properties.Validate(); validate && e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
@ -89,6 +90,7 @@ func (a *Apiloader) LoadContainerService(contents []byte, version string, valida
|
|||
if e := json.Unmarshal(contents, &containerService); e != nil {
|
||||
return nil, e
|
||||
}
|
||||
setContainerServiceDefaultsvlabs(containerService)
|
||||
if e := containerService.Properties.Validate(); validate && e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
@ -188,3 +190,17 @@ func setContainerServiceDefaultsv20170131(c *v20170131.ContainerService) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sets default container service property values for any appropriate zero values
|
||||
func setContainerServiceDefaultsv20170701(c *v20170701.ContainerService) {
|
||||
if c.Properties.OrchestratorProfile != nil {
|
||||
c.Properties.OrchestratorProfile.OrchestratorVersion = ""
|
||||
}
|
||||
}
|
||||
|
||||
// Sets default container service property values for any appropriate zero values
|
||||
func setContainerServiceDefaultsvlabs(c *vlabs.ContainerService) {
|
||||
if c.Properties.OrchestratorProfile != nil {
|
||||
c.Properties.OrchestratorProfile.OrchestratorVersion = ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,3 +37,39 @@ const (
|
|||
// ManagedDisks means that the nodes use managed disks for their os and attached volumes
|
||||
ManagedDisks = "ManagedDisks"
|
||||
)
|
||||
|
||||
const (
|
||||
// KubernetesRelease1Dot7 is the major.minor string prefix for 1.7 versions of kubernetes
|
||||
KubernetesRelease1Dot7 string = "1.7"
|
||||
// KubernetesRelease1Dot6 is the major.minor string prefix for 1.6 versions of kubernetes
|
||||
KubernetesRelease1Dot6 string = "1.6"
|
||||
// KubernetesRelease1Dot5 is the major.minor string prefix for 1.5 versions of kubernetes
|
||||
KubernetesRelease1Dot5 string = "1.5"
|
||||
// KubernetesDefaultRelease is the default major.minor version for kubernetes
|
||||
KubernetesDefaultRelease string = KubernetesRelease1Dot6
|
||||
)
|
||||
|
||||
// KubeReleaseToVersion maps a major.minor release to an full major.minor.patch version
|
||||
var KubeReleaseToVersion = map[string]string{
|
||||
KubernetesRelease1Dot7: "1.7.2",
|
||||
KubernetesRelease1Dot6: "1.6.6",
|
||||
KubernetesRelease1Dot5: "1.5.7",
|
||||
}
|
||||
|
||||
const (
|
||||
// DCOSRelease1Dot9 is the major.minor string prefix for 1.9 versions of DCOS
|
||||
DCOSRelease1Dot9 string = "1.9"
|
||||
// DCOSRelease1Dot8 is the major.minor string prefix for 1.8 versions of DCOS
|
||||
DCOSRelease1Dot8 string = "1.8"
|
||||
// DCOSRelease1Dot7 is the major.minor string prefix for 1.7 versions of DCOS
|
||||
DCOSRelease1Dot7 string = "1.7"
|
||||
// DCOSDefaultRelease is the default major.minor version for DCOS
|
||||
DCOSDefaultRelease string = DCOSRelease1Dot9
|
||||
)
|
||||
|
||||
// DCOSReleaseToVersion maps a major.minor release to an full major.minor.patch version
|
||||
var DCOSReleaseToVersion = map[string]string{
|
||||
DCOSRelease1Dot9: "1.9.0",
|
||||
DCOSRelease1Dot8: "1.8.8",
|
||||
DCOSRelease1Dot7: "1.7.3",
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ func HandleValidationErrors(e validator.ValidationErrors) error {
|
|||
"Properties.WindowsProfile.AdminUsername",
|
||||
"Properties.WindowsProfile.AdminPassword":
|
||||
return fmt.Errorf("missing %s", ns)
|
||||
case "Properties.OrchestratorProfile.OrchestratorVersion":
|
||||
return fmt.Errorf("OrchestratorVersion is a readyonly field, leave it empty")
|
||||
case "Properties.MasterProfile.Count":
|
||||
return fmt.Errorf("MasterProfile count needs to be 1, 3, or 5")
|
||||
case "Properties.MasterProfile.OSDiskSizeGB":
|
||||
|
|
|
@ -51,40 +51,40 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
// Kubernetes153 is the string constant for Kubernetes 1.5.3
|
||||
Kubernetes153 string = "1.5.3"
|
||||
// Kubernetes157 is the string constant for Kubernetes 1.5.7
|
||||
Kubernetes157 string = "1.5.7"
|
||||
// Kubernetes160 is the string constant for Kubernetes 1.6.0
|
||||
Kubernetes160 string = "1.6.0"
|
||||
// Kubernetes162 is the string constant for Kubernetes 1.6.2
|
||||
Kubernetes162 string = "1.6.2"
|
||||
// Kubernetes166 is the string constant for Kubernetes 1.6.6
|
||||
Kubernetes166 string = "1.6.6"
|
||||
// Kubernetes170 is the string constant for Kubernetes 1.7.0
|
||||
Kubernetes170 string = "1.7.0"
|
||||
// Kubernetes171 is the string constant for Kubernetes 1.7.1
|
||||
Kubernetes171 string = "1.7.1"
|
||||
// Kubernetes172 is the string constant for Kubernetes 1.7.2
|
||||
Kubernetes172 string = "1.7.2"
|
||||
// KubernetesDefaultVersion is the string constant for current Kubernetes version
|
||||
KubernetesDefaultVersion string = Kubernetes166
|
||||
// KubernetesRelease1Dot7 is the major.minor string prefix for 1.7 versions of kubernetes
|
||||
KubernetesRelease1Dot7 string = "1.7"
|
||||
// KubernetesRelease1Dot6 is the major.minor string prefix for 1.6 versions of kubernetes
|
||||
KubernetesRelease1Dot6 string = "1.6"
|
||||
// KubernetesRelease1Dot5 is the major.minor string prefix for 1.5 versions of kubernetes
|
||||
KubernetesRelease1Dot5 string = "1.5"
|
||||
// KubernetesDefaultRelease is the default major.minor version for kubernetes
|
||||
KubernetesDefaultRelease string = KubernetesRelease1Dot6
|
||||
)
|
||||
|
||||
const (
|
||||
// DCOS190 is the string constant for DCOS 1.9.0
|
||||
DCOS190 string = "1.9.0"
|
||||
// DCOS188 is the string constant for DCOS 1.8.8
|
||||
DCOS188 string = "1.8.8"
|
||||
// DCOS187 is the string constant for DCOS 1.8.7
|
||||
DCOS187 string = "1.8.7"
|
||||
// DCOS184 is the string constant for DCOS 1.8.4
|
||||
DCOS184 string = "1.8.4"
|
||||
// DCOS173 is the string constant for DCOS 1.7.3
|
||||
DCOS173 string = "1.7.3"
|
||||
// DCOSLatest is the string constant for latest DCOS version
|
||||
DCOSLatest string = DCOS190
|
||||
// DCOSRelease1Dot9 is the major.minor string prefix for 1.9 versions of DCOS
|
||||
DCOSRelease1Dot9 string = "1.9"
|
||||
// DCOSRelease1Dot8 is the major.minor string prefix for 1.8 versions of DCOS
|
||||
DCOSRelease1Dot8 string = "1.8"
|
||||
// DCOSRelease1Dot7 is the major.minor string prefix for 1.7 versions of DCOS
|
||||
DCOSRelease1Dot7 string = "1.7"
|
||||
// DCOSDefaultRelease is the default major.minor version for DCOS
|
||||
DCOSDefaultRelease string = DCOSRelease1Dot9
|
||||
)
|
||||
|
||||
// DCOSReleaseToVersion maps a major.minor release to an full major.minor.patch version
|
||||
var DCOSReleaseToVersion = map[string]string{
|
||||
DCOSRelease1Dot9: "1.9.0",
|
||||
DCOSRelease1Dot8: "1.8.8",
|
||||
DCOSRelease1Dot7: "1.7.3",
|
||||
}
|
||||
|
||||
// KubernetesReleaseToVersion maps a major.minor release to an full major.minor.patch version
|
||||
var KubernetesReleaseToVersion = map[string]string{
|
||||
KubernetesRelease1Dot7: "1.7.2",
|
||||
KubernetesRelease1Dot6: "1.6.6",
|
||||
KubernetesRelease1Dot5: "1.5.7",
|
||||
}
|
||||
|
||||
// To identify programmatically generated public agent pools
|
||||
const publicAgentPoolSuffix = "-public"
|
||||
|
|
|
@ -525,6 +525,10 @@ func convertOrchestratorProfileToV20170701(api *OrchestratorProfile, o *v2017070
|
|||
o.OrchestratorType = api.OrchestratorType
|
||||
}
|
||||
|
||||
if api.OrchestratorRelease != "" {
|
||||
o.OrchestratorRelease = api.OrchestratorRelease
|
||||
}
|
||||
|
||||
if api.OrchestratorVersion != "" {
|
||||
o.OrchestratorVersion = api.OrchestratorVersion
|
||||
}
|
||||
|
@ -533,6 +537,10 @@ func convertOrchestratorProfileToV20170701(api *OrchestratorProfile, o *v2017070
|
|||
func convertOrchestratorProfileToVLabs(api *OrchestratorProfile, o *vlabs.OrchestratorProfile) {
|
||||
o.OrchestratorType = api.OrchestratorType
|
||||
|
||||
if api.OrchestratorRelease != "" {
|
||||
o.OrchestratorRelease = api.OrchestratorRelease
|
||||
}
|
||||
|
||||
if api.OrchestratorVersion != "" {
|
||||
o.OrchestratorVersion = api.OrchestratorVersion
|
||||
}
|
||||
|
|
|
@ -469,25 +469,30 @@ func convertVLabsWindowsProfile(vlabs *vlabs.WindowsProfile, api *WindowsProfile
|
|||
func convertV20160930OrchestratorProfile(v20160930 *v20160930.OrchestratorProfile, api *OrchestratorProfile) {
|
||||
api.OrchestratorType = v20160930.OrchestratorType
|
||||
if api.OrchestratorType == Kubernetes {
|
||||
api.OrchestratorVersion = Kubernetes153
|
||||
api.OrchestratorRelease = KubernetesRelease1Dot5
|
||||
api.OrchestratorVersion = KubernetesReleaseToVersion[api.OrchestratorRelease]
|
||||
} else if api.OrchestratorType == DCOS {
|
||||
api.OrchestratorVersion = DCOS190
|
||||
api.OrchestratorRelease = DCOSRelease1Dot9
|
||||
api.OrchestratorVersion = DCOSReleaseToVersion[api.OrchestratorRelease]
|
||||
}
|
||||
}
|
||||
|
||||
func convertV20160330OrchestratorProfile(v20160330 *v20160330.OrchestratorProfile, api *OrchestratorProfile) {
|
||||
api.OrchestratorType = v20160330.OrchestratorType
|
||||
if api.OrchestratorType == DCOS {
|
||||
api.OrchestratorVersion = DCOS190
|
||||
api.OrchestratorRelease = DCOSRelease1Dot9
|
||||
api.OrchestratorVersion = DCOSReleaseToVersion[api.OrchestratorRelease]
|
||||
}
|
||||
}
|
||||
|
||||
func convertV20170131OrchestratorProfile(v20170131 *v20170131.OrchestratorProfile, api *OrchestratorProfile) {
|
||||
api.OrchestratorType = v20170131.OrchestratorType
|
||||
if api.OrchestratorType == Kubernetes {
|
||||
api.OrchestratorVersion = KubernetesDefaultVersion
|
||||
api.OrchestratorRelease = KubernetesDefaultRelease
|
||||
api.OrchestratorVersion = KubernetesReleaseToVersion[api.OrchestratorRelease]
|
||||
} else if api.OrchestratorType == DCOS {
|
||||
api.OrchestratorVersion = DCOS190
|
||||
api.OrchestratorRelease = DCOSRelease1Dot9
|
||||
api.OrchestratorVersion = DCOSReleaseToVersion[api.OrchestratorRelease]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,73 +503,52 @@ func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProf
|
|||
api.OrchestratorType = v20170701cs.OrchestratorType
|
||||
}
|
||||
|
||||
if api.OrchestratorType == Kubernetes {
|
||||
|
||||
switch v20170701cs.OrchestratorVersion {
|
||||
case v20170701.Kubernetes166:
|
||||
api.OrchestratorVersion = Kubernetes166
|
||||
case v20170701.Kubernetes157:
|
||||
api.OrchestratorVersion = Kubernetes157
|
||||
switch api.OrchestratorType {
|
||||
case Kubernetes:
|
||||
switch v20170701cs.OrchestratorRelease {
|
||||
case KubernetesRelease1Dot7, KubernetesRelease1Dot6, KubernetesRelease1Dot5:
|
||||
api.OrchestratorRelease = v20170701cs.OrchestratorRelease
|
||||
default:
|
||||
api.OrchestratorVersion = KubernetesDefaultVersion
|
||||
api.OrchestratorRelease = KubernetesDefaultRelease
|
||||
}
|
||||
} else if api.OrchestratorType == DCOS {
|
||||
switch v20170701cs.OrchestratorVersion {
|
||||
case v20170701.DCOS187:
|
||||
api.OrchestratorVersion = DCOS187
|
||||
case v20170701.DCOS188:
|
||||
api.OrchestratorVersion = DCOS188
|
||||
case v20170701.DCOS190:
|
||||
api.OrchestratorVersion = DCOS190
|
||||
api.OrchestratorVersion = KubernetesReleaseToVersion[api.OrchestratorRelease]
|
||||
case DCOS:
|
||||
switch v20170701cs.OrchestratorRelease {
|
||||
case DCOSRelease1Dot9, DCOSRelease1Dot8:
|
||||
api.OrchestratorRelease = v20170701cs.OrchestratorRelease
|
||||
default:
|
||||
api.OrchestratorVersion = DCOSLatest
|
||||
api.OrchestratorRelease = DCOSDefaultRelease
|
||||
}
|
||||
api.OrchestratorVersion = DCOSReleaseToVersion[api.OrchestratorRelease]
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func convertVLabsOrchestratorProfile(vlabscs *vlabs.OrchestratorProfile, api *OrchestratorProfile) {
|
||||
api.OrchestratorType = vlabscs.OrchestratorType
|
||||
if api.OrchestratorType == Kubernetes {
|
||||
switch api.OrchestratorType {
|
||||
case Kubernetes:
|
||||
if vlabscs.KubernetesConfig != nil {
|
||||
api.KubernetesConfig = &KubernetesConfig{}
|
||||
convertVLabsKubernetesConfig(vlabscs.KubernetesConfig, api.KubernetesConfig)
|
||||
}
|
||||
|
||||
switch vlabscs.OrchestratorVersion {
|
||||
case vlabs.Kubernetes172:
|
||||
api.OrchestratorVersion = Kubernetes172
|
||||
case vlabs.Kubernetes171:
|
||||
api.OrchestratorVersion = Kubernetes171
|
||||
case vlabs.Kubernetes170:
|
||||
api.OrchestratorVersion = Kubernetes170
|
||||
case vlabs.Kubernetes166:
|
||||
api.OrchestratorVersion = Kubernetes166
|
||||
case vlabs.Kubernetes162:
|
||||
api.OrchestratorVersion = Kubernetes162
|
||||
case vlabs.Kubernetes160:
|
||||
api.OrchestratorVersion = Kubernetes160
|
||||
case vlabs.Kubernetes157:
|
||||
api.OrchestratorVersion = Kubernetes157
|
||||
case vlabs.Kubernetes153:
|
||||
api.OrchestratorVersion = Kubernetes153
|
||||
switch vlabscs.OrchestratorRelease {
|
||||
case KubernetesRelease1Dot7, KubernetesRelease1Dot6, KubernetesRelease1Dot5:
|
||||
api.OrchestratorRelease = vlabscs.OrchestratorRelease
|
||||
default:
|
||||
api.OrchestratorVersion = KubernetesDefaultVersion
|
||||
api.OrchestratorRelease = KubernetesDefaultRelease
|
||||
}
|
||||
} else if api.OrchestratorType == DCOS {
|
||||
switch vlabscs.OrchestratorVersion {
|
||||
case vlabs.DCOS173:
|
||||
api.OrchestratorVersion = DCOS173
|
||||
case vlabs.DCOS184:
|
||||
api.OrchestratorVersion = DCOS184
|
||||
case vlabs.DCOS187:
|
||||
api.OrchestratorVersion = DCOS187
|
||||
case vlabs.DCOS188:
|
||||
api.OrchestratorVersion = DCOS188
|
||||
case vlabs.DCOS190:
|
||||
api.OrchestratorVersion = DCOS190
|
||||
api.OrchestratorVersion = KubernetesReleaseToVersion[api.OrchestratorRelease]
|
||||
case DCOS:
|
||||
switch vlabscs.OrchestratorRelease {
|
||||
case DCOSRelease1Dot9, DCOSRelease1Dot8, DCOSRelease1Dot7:
|
||||
api.OrchestratorRelease = vlabscs.OrchestratorRelease
|
||||
default:
|
||||
api.OrchestratorVersion = DCOSLatest
|
||||
api.OrchestratorRelease = DCOSDefaultRelease
|
||||
}
|
||||
api.OrchestratorVersion = DCOSReleaseToVersion[api.OrchestratorRelease]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ const (
|
|||
// OrchestratorProfile contains Orchestrator properties
|
||||
type OrchestratorProfile struct {
|
||||
OrchestratorType string `json:"orchestratorType"`
|
||||
OrchestratorRelease string `json:"orchestratorRelease"`
|
||||
OrchestratorVersion string `json:"orchestratorVersion"`
|
||||
KubernetesConfig *KubernetesConfig `json:"kubernetesConfig,omitempty"`
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ const exampleAPIModel = `{
|
|||
func TestIsDCOS(t *testing.T) {
|
||||
dCOSProfile := &OrchestratorProfile{
|
||||
OrchestratorType: "DCOS",
|
||||
OrchestratorVersion: "vlabs",
|
||||
OrchestratorRelease: "vlabs",
|
||||
}
|
||||
if !dCOSProfile.IsDCOS() {
|
||||
t.Fatalf("unable to detect DCOS orchestrator profile from OrchestratorType=%s", dCOSProfile.OrchestratorType)
|
||||
}
|
||||
kubernetesProfile := &OrchestratorProfile{
|
||||
OrchestratorType: "Kubernetes",
|
||||
OrchestratorVersion: "vlabs",
|
||||
OrchestratorRelease: "vlabs",
|
||||
}
|
||||
if kubernetesProfile.IsDCOS() {
|
||||
t.Fatalf("unexpectedly detected DCOS orchestrator profile from OrchestratorType=%s", kubernetesProfile.OrchestratorType)
|
||||
|
|
|
@ -47,33 +47,3 @@ const (
|
|||
// ManagedDisks means that the nodes use managed disks for their os and attached volumes
|
||||
ManagedDisks = "ManagedDisks"
|
||||
)
|
||||
|
||||
const (
|
||||
// DCOS190 is the string constant for DCOS 1.9.0
|
||||
DCOS190 string = "1.9.0"
|
||||
// DCOS188 is the string constant for DCOS 1.8.8
|
||||
DCOS188 string = "1.8.8"
|
||||
// DCOS187 is the string constant for DCOS 1.8.7
|
||||
DCOS187 string = "1.8.7"
|
||||
// DCOS184 is the string constant for DCOS 1.8.4
|
||||
DCOS184 string = "1.8.4"
|
||||
// DCOS173 is the string constant for DCOS 1.7.3
|
||||
DCOS173 string = "1.7.3"
|
||||
// DCOSLatest is the string constant for latest DCOS version
|
||||
DCOSLatest string = DCOS190
|
||||
)
|
||||
|
||||
const (
|
||||
// Kubernetes153 is the string constant for Kubernetes 1.5.3
|
||||
Kubernetes153 string = "1.5.3"
|
||||
// Kubernetes157 is the string constant for Kubernetes 1.5.3
|
||||
Kubernetes157 string = "1.5.7"
|
||||
// Kubernetes160 is the string constant for Kubernetes 1.6.0
|
||||
Kubernetes160 string = "1.6.0"
|
||||
// Kubernetes162 is the string constant for Kubernetes 1.6.2
|
||||
Kubernetes162 string = "1.6.2"
|
||||
// Kubernetes166 is the string constant for Kubernetes 1.6.6
|
||||
Kubernetes166 string = "1.6.6"
|
||||
// KubernetesDefaultVersion is the string constant for current Kubernetes version
|
||||
KubernetesDefaultVersion string = Kubernetes166
|
||||
)
|
||||
|
|
|
@ -108,7 +108,8 @@ const (
|
|||
// OrchestratorProfile contains Orchestrator properties
|
||||
type OrchestratorProfile struct {
|
||||
OrchestratorType string `json:"orchestratorType" validate:"required"`
|
||||
OrchestratorVersion string `json:"orchestratorVersion"`
|
||||
OrchestratorRelease string `json:"orchestratorRelease"`
|
||||
OrchestratorVersion string `json:"orchestratorVersion" validate:"len=0"`
|
||||
}
|
||||
|
||||
// MasterProfile represents the definition of master cluster
|
||||
|
|
|
@ -27,22 +27,22 @@ func (o *OrchestratorProfile) Validate() error {
|
|||
switch o.OrchestratorType {
|
||||
case Swarm:
|
||||
case DCOS:
|
||||
switch o.OrchestratorVersion {
|
||||
case DCOS187:
|
||||
case DCOS188:
|
||||
case DCOS190:
|
||||
switch o.OrchestratorRelease {
|
||||
case common.DCOSRelease1Dot8:
|
||||
case common.DCOSRelease1Dot9:
|
||||
case "":
|
||||
default:
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator version: %s", o.OrchestratorVersion)
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator release: %s", o.OrchestratorRelease)
|
||||
}
|
||||
case DockerCE:
|
||||
case Kubernetes:
|
||||
switch o.OrchestratorVersion {
|
||||
case Kubernetes166:
|
||||
case Kubernetes157:
|
||||
switch o.OrchestratorRelease {
|
||||
case common.KubernetesRelease1Dot7:
|
||||
case common.KubernetesRelease1Dot6:
|
||||
case common.KubernetesRelease1Dot5:
|
||||
case "":
|
||||
default:
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator version: %s", o.OrchestratorVersion)
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator release: %s", o.OrchestratorRelease)
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -65,41 +65,3 @@ const (
|
|||
var (
|
||||
NetworkPolicyValues = [...]string{"", "none", "azure", "calico"}
|
||||
)
|
||||
|
||||
const (
|
||||
// DCOS190 is the string constant for DCOS 1.9.0
|
||||
DCOS190 string = "1.9.0"
|
||||
// DCOS188 is the string constant for DCOS 1.8.8
|
||||
DCOS188 string = "1.8.8"
|
||||
// DCOS187 is the string constant for DCOS 1.8.7
|
||||
DCOS187 string = "1.8.7"
|
||||
// DCOS184 is the string constant for DCOS 1.8.4
|
||||
DCOS184 string = "1.8.4"
|
||||
// DCOS173 is the string constant for DCOS 1.7.3
|
||||
DCOS173 string = "1.7.3"
|
||||
// DCOSLatest is the string constant for latest DCOS version
|
||||
DCOSLatest string = DCOS190
|
||||
)
|
||||
|
||||
const (
|
||||
// Kubernetes153 is the string constant for Kubernetes 1.5.3
|
||||
Kubernetes153 string = "1.5.3"
|
||||
// Kubernetes157 is the string constant for Kubernetes 1.5.7
|
||||
Kubernetes157 string = "1.5.7"
|
||||
// Kubernetes160 is the string constant for Kubernetes 1.6.0
|
||||
Kubernetes160 string = "1.6.0"
|
||||
// Kubernetes162 is the string constant for Kubernetes 1.6.2
|
||||
Kubernetes162 string = "1.6.2"
|
||||
// Kubernetes166 is the string constant for Kubernetes 1.6.6
|
||||
Kubernetes166 string = "1.6.6"
|
||||
// Kubernetes170 is the string constant for Kubernetes 1.7.0
|
||||
Kubernetes170 string = "1.7.0"
|
||||
// Kubernetes171 is the string constant for Kubernetes 1.7.1
|
||||
Kubernetes171 string = "1.7.1"
|
||||
// Kubernetes172 is the string constant for Kubernetes 1.7.2
|
||||
Kubernetes172 string = "1.7.2"
|
||||
// KubernetesLatest is the string constant for latest Kubernetes version
|
||||
KubernetesLatest string = Kubernetes166
|
||||
// KubernetesDefaultVersion is the string constant for current Kubernetes version
|
||||
KubernetesDefaultVersion string = Kubernetes166
|
||||
)
|
||||
|
|
|
@ -129,7 +129,8 @@ const (
|
|||
// OrchestratorProfile contains Orchestrator properties
|
||||
type OrchestratorProfile struct {
|
||||
OrchestratorType string `json:"orchestratorType" validate:"required"`
|
||||
OrchestratorVersion string `json:"orchestratorVersion"`
|
||||
OrchestratorRelease string `json:"orchestratorRelease"`
|
||||
OrchestratorVersion string `json:"orchestratorVersion" validate:"len=0"`
|
||||
KubernetesConfig *KubernetesConfig `json:"kubernetesConfig,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -146,13 +147,13 @@ func (o *OrchestratorProfile) UnmarshalJSON(b []byte) error {
|
|||
// Unmarshal OrchestratorType, format it as well
|
||||
orchestratorType := o.OrchestratorType
|
||||
switch {
|
||||
case strings.EqualFold(orchestratorType, string(DCOS)):
|
||||
case strings.EqualFold(orchestratorType, DCOS):
|
||||
o.OrchestratorType = DCOS
|
||||
case strings.EqualFold(orchestratorType, string(Swarm)):
|
||||
case strings.EqualFold(orchestratorType, Swarm):
|
||||
o.OrchestratorType = Swarm
|
||||
case strings.EqualFold(orchestratorType, string(Kubernetes)):
|
||||
case strings.EqualFold(orchestratorType, Kubernetes):
|
||||
o.OrchestratorType = Kubernetes
|
||||
case strings.EqualFold(orchestratorType, string(SwarmMode)):
|
||||
case strings.EqualFold(orchestratorType, SwarmMode):
|
||||
o.OrchestratorType = SwarmMode
|
||||
default:
|
||||
return fmt.Errorf("OrchestratorType has unknown orchestrator: %s", orchestratorType)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package vlabs
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
)
|
||||
|
||||
// UpgradeContainerService API model
|
||||
type UpgradeContainerService struct {
|
||||
|
@ -10,16 +14,13 @@ type UpgradeContainerService struct {
|
|||
// Validate implements APIObject
|
||||
func (ucs *UpgradeContainerService) Validate() error {
|
||||
switch ucs.OrchestratorProfile.OrchestratorType {
|
||||
case DCOS:
|
||||
case Swarm:
|
||||
case SwarmMode:
|
||||
case DCOS, SwarmMode, Swarm:
|
||||
return fmt.Errorf("Upgrade is not supported for orchestrator: %s", ucs.OrchestratorProfile.OrchestratorType)
|
||||
case Kubernetes:
|
||||
switch ucs.OrchestratorProfile.OrchestratorVersion {
|
||||
case Kubernetes162:
|
||||
case Kubernetes160:
|
||||
switch ucs.OrchestratorProfile.OrchestratorRelease {
|
||||
case common.KubernetesRelease1Dot6:
|
||||
default:
|
||||
return fmt.Errorf("Invalid orchestrator version: %s", ucs.OrchestratorProfile.OrchestratorVersion)
|
||||
return fmt.Errorf("Upgrade is not supported to orchestrator release: %s", ucs.OrchestratorProfile.OrchestratorRelease)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,39 +24,34 @@ func init() {
|
|||
|
||||
// Validate implements APIObject
|
||||
func (o *OrchestratorProfile) Validate() error {
|
||||
// Don't need to call validate.Struct(o)
|
||||
// It is handled by Properties.Validate()
|
||||
switch o.OrchestratorType {
|
||||
case DCOS:
|
||||
switch o.OrchestratorVersion {
|
||||
case DCOS173:
|
||||
case DCOS184:
|
||||
case DCOS187:
|
||||
case DCOS188:
|
||||
case DCOS190:
|
||||
switch o.OrchestratorRelease {
|
||||
case common.DCOSRelease1Dot7:
|
||||
case common.DCOSRelease1Dot8:
|
||||
case common.DCOSRelease1Dot9:
|
||||
case "":
|
||||
default:
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator version: %s", o.OrchestratorVersion)
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator release: %s", o.OrchestratorRelease)
|
||||
}
|
||||
|
||||
case Swarm:
|
||||
case SwarmMode:
|
||||
|
||||
case Kubernetes:
|
||||
switch o.OrchestratorVersion {
|
||||
case Kubernetes172:
|
||||
case Kubernetes171:
|
||||
case Kubernetes170:
|
||||
case Kubernetes166:
|
||||
case Kubernetes162:
|
||||
case Kubernetes160:
|
||||
case Kubernetes157:
|
||||
case Kubernetes153:
|
||||
switch o.OrchestratorRelease {
|
||||
case common.KubernetesRelease1Dot7:
|
||||
case common.KubernetesRelease1Dot6:
|
||||
case common.KubernetesRelease1Dot5:
|
||||
case "":
|
||||
default:
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator version: %s", o.OrchestratorVersion)
|
||||
return fmt.Errorf("OrchestratorProfile has unknown orchestrator release: %s", o.OrchestratorRelease)
|
||||
}
|
||||
|
||||
if o.KubernetesConfig != nil {
|
||||
err := o.KubernetesConfig.Validate(o.OrchestratorVersion)
|
||||
err := o.KubernetesConfig.Validate(o.OrchestratorRelease)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -285,18 +280,16 @@ func (a *Properties) Validate() error {
|
|||
}
|
||||
|
||||
// Validate validates the KubernetesConfig.
|
||||
func (a *KubernetesConfig) Validate(k8sVersion string) error {
|
||||
func (a *KubernetesConfig) Validate(k8sRelease string) error {
|
||||
// number of minimum retries allowed for kubelet to post node status
|
||||
const minKubeletRetries = 4
|
||||
// k8s versions that have cloudprovider backoff enabled
|
||||
var backoffEnabledVersions = map[string]bool{
|
||||
Kubernetes172: true,
|
||||
Kubernetes171: true,
|
||||
Kubernetes166: true,
|
||||
Kubernetes170: true,
|
||||
// k8s releases that have cloudprovider backoff enabled
|
||||
var backoffEnabledReleases = map[string]bool{
|
||||
common.KubernetesRelease1Dot7: true,
|
||||
common.KubernetesRelease1Dot6: true,
|
||||
}
|
||||
// k8s versions that have cloudprovider rate limiting enabled (currently identical with backoff enabled versions)
|
||||
ratelimitEnabledVersions := backoffEnabledVersions
|
||||
// k8s releases that have cloudprovider rate limiting enabled (currently identical with backoff enabled releases)
|
||||
ratelimitEnabledReleases := backoffEnabledReleases
|
||||
|
||||
if a.ClusterSubnet != "" {
|
||||
_, subnet, err := net.ParseCIDR(a.ClusterSubnet)
|
||||
|
@ -361,14 +354,14 @@ func (a *KubernetesConfig) Validate(k8sVersion string) error {
|
|||
}
|
||||
|
||||
if a.CloudProviderBackoff {
|
||||
if !backoffEnabledVersions[k8sVersion] {
|
||||
return fmt.Errorf("cloudprovider backoff functionality not available in kubernetes version %s", k8sVersion)
|
||||
if !backoffEnabledReleases[k8sRelease] {
|
||||
return fmt.Errorf("cloudprovider backoff functionality not available in kubernetes release %s", k8sRelease)
|
||||
}
|
||||
}
|
||||
|
||||
if a.CloudProviderRateLimit {
|
||||
if !ratelimitEnabledVersions[k8sVersion] {
|
||||
return fmt.Errorf("cloudprovider rate limiting functionality not available in kubernetes version %s", k8sVersion)
|
||||
if !ratelimitEnabledReleases[k8sRelease] {
|
||||
return fmt.Errorf("cloudprovider rate limiting functionality not available in kubernetes release %s", k8sRelease)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package vlabs
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
)
|
||||
|
||||
const (
|
||||
ValidKubernetesNodeStatusUpdateFrequency = "10s"
|
||||
|
@ -34,11 +38,11 @@ func Test_OrchestratorProfile_Validate(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_KubernetesConfig_Validate(t *testing.T) {
|
||||
// Tests that should pass across all versions
|
||||
for _, k8sVersion := range []string{Kubernetes153, Kubernetes157, Kubernetes160, Kubernetes162, Kubernetes166, Kubernetes170, Kubernetes171, Kubernetes172} {
|
||||
// Tests that should pass across all releases
|
||||
for _, k8sRelease := range []string{common.KubernetesRelease1Dot5, common.KubernetesRelease1Dot6, common.KubernetesRelease1Dot7} {
|
||||
c := KubernetesConfig{}
|
||||
if err := c.Validate(k8sVersion); err != nil {
|
||||
t.Errorf("should not error on empty KubernetesConfig: %v, version %s", err, k8sVersion)
|
||||
if err := c.Validate(k8sRelease); err != nil {
|
||||
t.Errorf("should not error on empty KubernetesConfig: %v, release %s", err, k8sRelease)
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
|
@ -57,35 +61,35 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
|
|||
CloudProviderRateLimitQPS: ValidKubernetesCloudProviderRateLimitQPS,
|
||||
CloudProviderRateLimitBucket: ValidKubernetesCloudProviderRateLimitBucket,
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err != nil {
|
||||
if err := c.Validate(k8sRelease); err != nil {
|
||||
t.Errorf("should not error on a KubernetesConfig with valid param values: %v", err)
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
ClusterSubnet: "10.16.x.0/invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid ClusterSubnet")
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
DockerBridgeSubnet: "10.120.1.0/invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid DockerBridgeSubnet")
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
NodeStatusUpdateFrequency: "invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid NodeStatusUpdateFrequency")
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
CtrlMgrNodeMonitorGracePeriod: "invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid CtrlMgrNodeMonitorGracePeriod")
|
||||
}
|
||||
|
||||
|
@ -93,43 +97,43 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
|
|||
NodeStatusUpdateFrequency: "10s",
|
||||
CtrlMgrNodeMonitorGracePeriod: "30s",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error when CtrlMgrRouteReconciliationPeriod is not sufficiently larger than NodeStatusUpdateFrequency")
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
CtrlMgrPodEvictionTimeout: "invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid CtrlMgrPodEvictionTimeout")
|
||||
}
|
||||
|
||||
c = KubernetesConfig{
|
||||
CtrlMgrRouteReconciliationPeriod: "invalid",
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error on invalid CtrlMgrRouteReconciliationPeriod")
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that apply to pre-1.6.6 versions
|
||||
for _, k8sVersion := range []string{Kubernetes153, Kubernetes157, Kubernetes160, Kubernetes162} {
|
||||
// Tests that apply to pre-1.6 releases
|
||||
for _, k8sRelease := range []string{common.KubernetesRelease1Dot5} {
|
||||
c := KubernetesConfig{
|
||||
CloudProviderBackoff: true,
|
||||
CloudProviderRateLimit: true,
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err == nil {
|
||||
if err := c.Validate(k8sRelease); err == nil {
|
||||
t.Error("should error because backoff and rate limiting are not available before v1.6.6")
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that apply to 1.6.6 and later versions
|
||||
for _, k8sVersion := range []string{Kubernetes166, Kubernetes170, Kubernetes171, Kubernetes172} {
|
||||
// Tests that apply to 1.6 and later releases
|
||||
for _, k8sRelease := range []string{common.KubernetesRelease1Dot6, common.KubernetesRelease1Dot7} {
|
||||
c := KubernetesConfig{
|
||||
CloudProviderBackoff: true,
|
||||
CloudProviderRateLimit: true,
|
||||
}
|
||||
if err := c.Validate(k8sVersion); err != nil {
|
||||
if err := c.Validate(k8sRelease); err != nil {
|
||||
t.Error("should not error when basic backoff and rate limiting are set to true with no options")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
"github.com/Azure/azure-sdk-for-go/arm/compute"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/satori/go.uuid"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
// ClusterTopology contains resources of the cluster the upgrade operation
|
||||
|
@ -71,24 +71,26 @@ func (uc *UpgradeCluster) UpgradeCluster(subscriptionID uuid.UUID, resourceGroup
|
|||
return uc.Translator.Errorf("Error while querying ARM for resources: %+v", err)
|
||||
}
|
||||
|
||||
switch ucs.OrchestratorProfile.OrchestratorVersion {
|
||||
case api.Kubernetes162:
|
||||
log.Infoln(fmt.Sprintf("Upgrading to Kubernetes 1.6.2"))
|
||||
upgrader := Kubernetes162upgrader{
|
||||
switch ucs.OrchestratorProfile.OrchestratorRelease {
|
||||
case api.KubernetesRelease1Dot6:
|
||||
log.Infoln(fmt.Sprintf("Upgrading to Kubernetes release 1.6"))
|
||||
upgrader := Kubernetes16upgrader{
|
||||
Translator: uc.Translator,
|
||||
}
|
||||
upgrader.ClusterTopology = uc.ClusterTopology
|
||||
upgrader.UpgradeModel = uc.UpgradeModel
|
||||
upgrader.Client = uc.Client
|
||||
if err := upgrader.RunUpgrade(); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return uc.Translator.Errorf("Upgrade to Kubernetes version: %s is not supported from version: %s",
|
||||
ucs.OrchestratorProfile.OrchestratorVersion,
|
||||
uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion)
|
||||
return uc.Translator.Errorf("Upgrade to Kubernetes release: %s is not supported from release: %s",
|
||||
ucs.OrchestratorProfile.OrchestratorRelease,
|
||||
uc.DataModel.Properties.OrchestratorProfile.OrchestratorRelease)
|
||||
}
|
||||
|
||||
log.Infoln(fmt.Sprintf("Cluster upraded successfully to Kubernetes version: %s",
|
||||
log.Infoln(fmt.Sprintf("Cluster upraded successfully to Kubernetes release %s, version: %s",
|
||||
ucs.OrchestratorProfile.OrchestratorRelease,
|
||||
ucs.OrchestratorProfile.OrchestratorVersion))
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
. "github.com/Azure/acs-engine/pkg/test"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/satori/go.uuid"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
func TestUpgradeCluster(t *testing.T) {
|
||||
|
@ -42,7 +42,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
subID, _ := uuid.FromString("DEC923E3-1EF1-4745-9516-37906D56DEC4")
|
||||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", &cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("Error while querying ARM for resources: ListVirtualMachines failed"))
|
||||
|
||||
// Clean up
|
||||
|
@ -55,7 +55,8 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
ucs := api.UpgradeContainerService{}
|
||||
ucs.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
ucs.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ucs.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot6
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.KubernetesReleaseToVersion[api.KubernetesRelease1Dot6]
|
||||
|
||||
uc := UpgradeCluster{}
|
||||
|
||||
|
@ -67,6 +68,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("DeleteVirtualMachine failed"))
|
||||
})
|
||||
|
||||
|
@ -76,7 +78,8 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
ucs := api.UpgradeContainerService{}
|
||||
ucs.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
ucs.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ucs.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot6
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.KubernetesReleaseToVersion[api.KubernetesRelease1Dot6]
|
||||
|
||||
uc := UpgradeCluster{}
|
||||
|
||||
|
@ -87,7 +90,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
subID, _ := uuid.FromString("DEC923E3-1EF1-4745-9516-37906D56DEC4")
|
||||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("DeployTemplate failed"))
|
||||
})
|
||||
|
||||
|
@ -97,7 +100,8 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
ucs := api.UpgradeContainerService{}
|
||||
ucs.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
ucs.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ucs.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot6
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.KubernetesReleaseToVersion[api.KubernetesRelease1Dot6]
|
||||
|
||||
uc := UpgradeCluster{}
|
||||
|
||||
|
@ -108,7 +112,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
subID, _ := uuid.FromString("DEC923E3-1EF1-4745-9516-37906D56DEC4")
|
||||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("GetVirtualMachine failed"))
|
||||
})
|
||||
|
||||
|
@ -118,7 +122,8 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
ucs := api.UpgradeContainerService{}
|
||||
ucs.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
ucs.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ucs.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot6
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.KubernetesReleaseToVersion[api.KubernetesRelease1Dot6]
|
||||
|
||||
uc := UpgradeCluster{}
|
||||
|
||||
|
@ -129,7 +134,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
subID, _ := uuid.FromString("DEC923E3-1EF1-4745-9516-37906D56DEC4")
|
||||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("GetStorageClient failed"))
|
||||
})
|
||||
|
||||
|
@ -139,7 +144,8 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
ucs := api.UpgradeContainerService{}
|
||||
ucs.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
ucs.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ucs.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot6
|
||||
ucs.OrchestratorProfile.OrchestratorVersion = api.KubernetesReleaseToVersion[api.KubernetesRelease1Dot6]
|
||||
|
||||
uc := UpgradeCluster{}
|
||||
|
||||
|
@ -150,7 +156,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
subID, _ := uuid.FromString("DEC923E3-1EF1-4745-9516-37906D56DEC4")
|
||||
|
||||
err := uc.UpgradeCluster(subID, "TestRg", cs, &ucs, "12345678")
|
||||
|
||||
Expect(err).NotTo(BeNil())
|
||||
Expect(err.Error()).To(Equal("DeleteNetworkInterface failed"))
|
||||
})
|
||||
})
|
||||
|
@ -196,7 +202,8 @@ func createContainerService(containerServiceName string, masterCount int, agentC
|
|||
|
||||
cs.Properties.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
cs.Properties.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = api.Kubernetes153
|
||||
cs.Properties.OrchestratorProfile.OrchestratorRelease = api.KubernetesRelease1Dot5
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.5.3"
|
||||
|
||||
return &cs
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
// Compiler to verify QueueMessageProcessor implements OperationsProcessor
|
||||
var _ UpgradeNode = &UpgradeAgentNode{}
|
||||
|
||||
// UpgradeAgentNode upgrades a Kubernetes 1.5.3 agent node to 1.6.2
|
||||
// UpgradeAgentNode upgrades a Kubernetes 1.5 agent node to 1.6
|
||||
type UpgradeAgentNode struct {
|
||||
Translator *i18n.Translator
|
||||
TemplateMap map[string]interface{}
|
|
@ -15,7 +15,7 @@ import (
|
|||
// Compiler to verify QueueMessageProcessor implements OperationsProcessor
|
||||
var _ UpgradeNode = &UpgradeMasterNode{}
|
||||
|
||||
// UpgradeMasterNode upgrades a Kubernetes 1.5.3 master node to 1.6.2
|
||||
// UpgradeMasterNode upgrades a Kubernetes 1.5 master node to 1.6
|
||||
type UpgradeMasterNode struct {
|
||||
Translator *i18n.Translator
|
||||
TemplateMap map[string]interface{}
|
|
@ -12,36 +12,40 @@ import (
|
|||
)
|
||||
|
||||
// Compiler to verify QueueMessageProcessor implements OperationsProcessor
|
||||
var _ UpgradeWorkFlow = &Kubernetes162upgrader{}
|
||||
var _ UpgradeWorkFlow = &Kubernetes16upgrader{}
|
||||
|
||||
// Kubernetes162upgrader upgrades a Kubernetes 1.5.3 cluster to 1.6.2
|
||||
type Kubernetes162upgrader struct {
|
||||
// Kubernetes16upgrader upgrades a Kubernetes 1.5 cluster to 1.6
|
||||
type Kubernetes16upgrader struct {
|
||||
Translator *i18n.Translator
|
||||
ClusterTopology
|
||||
GoalStateDataModel *api.ContainerService
|
||||
|
||||
Client armhelpers.ACSEngineClient
|
||||
UpgradeModel *api.UpgradeContainerService
|
||||
Client armhelpers.ACSEngineClient
|
||||
}
|
||||
|
||||
// ClusterPreflightCheck does preflight check
|
||||
func (ku *Kubernetes162upgrader) ClusterPreflightCheck() error {
|
||||
// Check that current cluster is 1.5.3
|
||||
if ku.DataModel.Properties.OrchestratorProfile.OrchestratorVersion != api.Kubernetes153 {
|
||||
return ku.Translator.Errorf("Upgrade to Kubernetes 1.6.2 is not supported from version: %s",
|
||||
ku.DataModel.Properties.OrchestratorProfile.OrchestratorVersion)
|
||||
func (ku *Kubernetes16upgrader) ClusterPreflightCheck() error {
|
||||
// Check that current cluster is 1.5
|
||||
if ku.DataModel.Properties.OrchestratorProfile.OrchestratorRelease != api.KubernetesRelease1Dot5 {
|
||||
return fmt.Errorf("Upgrade to Kubernetes 1.6 is not supported from orchestrator release: %s",
|
||||
ku.DataModel.Properties.OrchestratorProfile.OrchestratorRelease)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunUpgrade runs the upgrade pipeline
|
||||
func (ku *Kubernetes162upgrader) RunUpgrade() error {
|
||||
func (ku *Kubernetes16upgrader) RunUpgrade() error {
|
||||
if err := ku.ClusterPreflightCheck(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ku.GoalStateDataModel = ku.ClusterTopology.DataModel
|
||||
ku.GoalStateDataModel.Properties.OrchestratorProfile.OrchestratorVersion = api.Kubernetes162
|
||||
ku.GoalStateDataModel.Properties.OrchestratorProfile = &api.OrchestratorProfile{
|
||||
OrchestratorType: api.Kubernetes,
|
||||
OrchestratorRelease: ku.UpgradeModel.OrchestratorProfile.OrchestratorRelease,
|
||||
OrchestratorVersion: api.KubernetesReleaseToVersion[ku.UpgradeModel.OrchestratorProfile.OrchestratorRelease],
|
||||
}
|
||||
|
||||
if err := ku.upgradeMasterNodes(); err != nil {
|
||||
return err
|
||||
|
@ -55,11 +59,11 @@ func (ku *Kubernetes162upgrader) RunUpgrade() error {
|
|||
}
|
||||
|
||||
// Validate will run validation post upgrade
|
||||
func (ku *Kubernetes162upgrader) Validate() error {
|
||||
func (ku *Kubernetes16upgrader) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ku *Kubernetes162upgrader) upgradeMasterNodes() error {
|
||||
func (ku *Kubernetes16upgrader) upgradeMasterNodes() error {
|
||||
log.Infoln(fmt.Sprintf("Master nodes StorageProfile: %s", ku.GoalStateDataModel.Properties.MasterProfile.StorageProfile))
|
||||
// Upgrade Master VMs
|
||||
templateMap, parametersMap, err := ku.generateUpgradeTemplate(ku.GoalStateDataModel)
|
||||
|
@ -174,7 +178,7 @@ func (ku *Kubernetes162upgrader) upgradeMasterNodes() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ku *Kubernetes162upgrader) upgradeAgentPools() error {
|
||||
func (ku *Kubernetes16upgrader) upgradeAgentPools() error {
|
||||
for _, agentPool := range ku.ClusterTopology.AgentPools {
|
||||
// Upgrade Agent VMs
|
||||
templateMap, parametersMap, err := ku.generateUpgradeTemplate(ku.GoalStateDataModel)
|
||||
|
@ -279,7 +283,7 @@ func (ku *Kubernetes162upgrader) upgradeAgentPools() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ku *Kubernetes162upgrader) generateUpgradeTemplate(upgradeContainerService *api.ContainerService) (map[string]interface{}, map[string]interface{}, error) {
|
||||
func (ku *Kubernetes16upgrader) generateUpgradeTemplate(upgradeContainerService *api.ContainerService) (map[string]interface{}, map[string]interface{}, error) {
|
||||
var err error
|
||||
ctx := acsengine.Context{
|
||||
Translator: ku.Translator,
|
|
@ -0,0 +1,11 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.0
|
||||
- 1.1
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
|
||||
script:
|
||||
- go test
|
|
@ -0,0 +1,354 @@
|
|||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. “Contributor”
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. “Contributor Version”
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor’s Contribution.
|
||||
|
||||
1.3. “Contribution”
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. “Covered Software”
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. “Incompatible With Secondary Licenses”
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of version
|
||||
1.1 or earlier of the License, but not also under the terms of a
|
||||
Secondary License.
|
||||
|
||||
1.6. “Executable Form”
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. “Larger Work”
|
||||
|
||||
means a work that combines Covered Software with other material, in a separate
|
||||
file or files, that is not Covered Software.
|
||||
|
||||
1.8. “License”
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. “Licensable”
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether at the
|
||||
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||
this License.
|
||||
|
||||
1.10. “Modifications”
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to, deletion
|
||||
from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. “Patent Claims” of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by such Contributor that
|
||||
would be infringed, but for the grant of the License, by the making,
|
||||
using, selling, offering for sale, having made, import, or transfer of
|
||||
either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. “Secondary License”
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. “Source Code Form”
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. “You” (or “Your”)
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, “You” includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, “control” means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or as
|
||||
part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its Contributions
|
||||
or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||
effective for each Contribution on the date the Contributor first distributes
|
||||
such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under this
|
||||
License. No additional rights or licenses will be implied from the distribution
|
||||
or licensing of Covered Software under this License. Notwithstanding Section
|
||||
2.1(b) above, no patent license is granted by a Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party’s
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||
Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks, or
|
||||
logos of any Contributor (except as may be necessary to comply with the
|
||||
notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this License
|
||||
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||
under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its Contributions
|
||||
are its original creation(s) or it has sufficient rights to grant the
|
||||
rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under applicable
|
||||
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under the
|
||||
terms of this License. You must inform recipients that the Source Code Form
|
||||
of the Covered Software is governed by the terms of this License, and how
|
||||
they can obtain a copy of this License. You may not attempt to alter or
|
||||
restrict the recipients’ rights in the Source Code Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this License,
|
||||
or sublicense it under different terms, provided that the license for
|
||||
the Executable Form does not attempt to limit or alter the recipients’
|
||||
rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for the
|
||||
Covered Software. If the Larger Work is a combination of Covered Software
|
||||
with a work governed by one or more Secondary Licenses, and the Covered
|
||||
Software is not Incompatible With Secondary Licenses, this License permits
|
||||
You to additionally distribute such Covered Software under the terms of
|
||||
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||
their option, further distribute the Covered Software under the terms of
|
||||
either this License or such Secondary License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices (including
|
||||
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||
of liability) contained within the Source Code Form of the Covered
|
||||
Software, except that You may alter any license notices to the extent
|
||||
required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||
of any Contributor. You must make it absolutely clear that any such
|
||||
warranty, support, indemnity, or liability obligation is offered by You
|
||||
alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute, judicial
|
||||
order, or regulation then You must: (a) comply with the terms of this License
|
||||
to the maximum extent possible; and (b) describe the limitations and the code
|
||||
they affect. Such description must be placed in a text file included with all
|
||||
distributions of the Covered Software under this License. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||
if such Contributor fails to notify You of the non-compliance by some
|
||||
reasonable means prior to 60 days after You have come back into compliance.
|
||||
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||
some reasonable means, this is the first time You have received notice of
|
||||
non-compliance with this License from such Contributor, and You become
|
||||
compliant prior to 30 days after Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||
and cross-claims) alleging that a Contributor Version directly or
|
||||
indirectly infringes any patent, then the rights granted to You by any and
|
||||
all Contributors for the Covered Software under Section 2.1 of this License
|
||||
shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an “as is” basis, without
|
||||
warranty of any kind, either expressed, implied, or statutory, including,
|
||||
without limitation, warranties that the Covered Software is free of defects,
|
||||
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||
risk as to the quality and performance of the Covered Software is with You.
|
||||
Should any Covered Software prove defective in any respect, You (not any
|
||||
Contributor) assume the cost of any necessary servicing, repair, or
|
||||
correction. This disclaimer of warranty constitutes an essential part of this
|
||||
License. No use of any Covered Software is authorized under this License
|
||||
except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from such
|
||||
party’s negligence to the extent applicable law prohibits such limitation.
|
||||
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts of
|
||||
a jurisdiction where the defendant maintains its principal place of business
|
||||
and such litigation shall be governed by laws of that jurisdiction, without
|
||||
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject matter
|
||||
hereof. If any provision of this License is held to be unenforceable, such
|
||||
provision shall be reformed only to the extent necessary to make it
|
||||
enforceable. Any law or regulation which provides that the language of a
|
||||
contract shall be construed against the drafter shall not be used to construe
|
||||
this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version of
|
||||
the License under which You originally received the Covered Software, or
|
||||
under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a modified
|
||||
version of this License if you rename the license and remove any
|
||||
references to the name of the license steward (except to note that such
|
||||
modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||
directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||
|
||||
This Source Code Form is “Incompatible
|
||||
With Secondary Licenses”, as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
# Versioning Library for Go
|
||||
[![Build Status](https://travis-ci.org/hashicorp/go-version.svg?branch=master)](https://travis-ci.org/hashicorp/go-version)
|
||||
|
||||
go-version is a library for parsing versions and version constraints,
|
||||
and verifying versions against a set of constraints. go-version
|
||||
can sort a collection of versions properly, handles prerelease/beta
|
||||
versions, can increment versions, etc.
|
||||
|
||||
Versions used with go-version must follow [SemVer](http://semver.org/).
|
||||
|
||||
## Installation and Usage
|
||||
|
||||
Package documentation can be found on
|
||||
[GoDoc](http://godoc.org/github.com/hashicorp/go-version).
|
||||
|
||||
Installation can be done with a normal `go get`:
|
||||
|
||||
```
|
||||
$ go get github.com/hashicorp/go-version
|
||||
```
|
||||
|
||||
#### Version Parsing and Comparison
|
||||
|
||||
```go
|
||||
v1, err := version.NewVersion("1.2")
|
||||
v2, err := version.NewVersion("1.5+metadata")
|
||||
|
||||
// Comparison example. There is also GreaterThan, Equal, and just
|
||||
// a simple Compare that returns an int allowing easy >=, <=, etc.
|
||||
if v1.LessThan(v2) {
|
||||
fmt.Printf("%s is less than %s", v1, v2)
|
||||
}
|
||||
```
|
||||
|
||||
#### Version Constraints
|
||||
|
||||
```go
|
||||
v1, err := version.NewVersion("1.2")
|
||||
|
||||
// Constraints example.
|
||||
constraints, err := version.NewConstraint(">= 1.0, < 1.4")
|
||||
if constraints.Check(v1) {
|
||||
fmt.Printf("%s satisfies constraints %s", v1, constraints)
|
||||
}
|
||||
```
|
||||
|
||||
#### Version Sorting
|
||||
|
||||
```go
|
||||
versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"}
|
||||
versions := make([]*version.Version, len(versionsRaw))
|
||||
for i, raw := range versionsRaw {
|
||||
v, _ := version.NewVersion(raw)
|
||||
versions[i] = v
|
||||
}
|
||||
|
||||
// After this, the versions are properly sorted
|
||||
sort.Sort(version.Collection(versions))
|
||||
```
|
||||
|
||||
## Issues and Contributing
|
||||
|
||||
If you find an issue with this library, please report an issue. If you'd
|
||||
like, we welcome any contributions. Fork this library and submit a pull
|
||||
request.
|
|
@ -0,0 +1,178 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Constraint represents a single constraint for a version, such as
|
||||
// ">= 1.0".
|
||||
type Constraint struct {
|
||||
f constraintFunc
|
||||
check *Version
|
||||
original string
|
||||
}
|
||||
|
||||
// Constraints is a slice of constraints. We make a custom type so that
|
||||
// we can add methods to it.
|
||||
type Constraints []*Constraint
|
||||
|
||||
type constraintFunc func(v, c *Version) bool
|
||||
|
||||
var constraintOperators map[string]constraintFunc
|
||||
|
||||
var constraintRegexp *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
constraintOperators = map[string]constraintFunc{
|
||||
"": constraintEqual,
|
||||
"=": constraintEqual,
|
||||
"!=": constraintNotEqual,
|
||||
">": constraintGreaterThan,
|
||||
"<": constraintLessThan,
|
||||
">=": constraintGreaterThanEqual,
|
||||
"<=": constraintLessThanEqual,
|
||||
"~>": constraintPessimistic,
|
||||
}
|
||||
|
||||
ops := make([]string, 0, len(constraintOperators))
|
||||
for k := range constraintOperators {
|
||||
ops = append(ops, regexp.QuoteMeta(k))
|
||||
}
|
||||
|
||||
constraintRegexp = regexp.MustCompile(fmt.Sprintf(
|
||||
`^\s*(%s)\s*(%s)\s*$`,
|
||||
strings.Join(ops, "|"),
|
||||
VersionRegexpRaw))
|
||||
}
|
||||
|
||||
// NewConstraint will parse one or more constraints from the given
|
||||
// constraint string. The string must be a comma-separated list of
|
||||
// constraints.
|
||||
func NewConstraint(v string) (Constraints, error) {
|
||||
vs := strings.Split(v, ",")
|
||||
result := make([]*Constraint, len(vs))
|
||||
for i, single := range vs {
|
||||
c, err := parseSingle(single)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result[i] = c
|
||||
}
|
||||
|
||||
return Constraints(result), nil
|
||||
}
|
||||
|
||||
// Check tests if a version satisfies all the constraints.
|
||||
func (cs Constraints) Check(v *Version) bool {
|
||||
for _, c := range cs {
|
||||
if !c.Check(v) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Returns the string format of the constraints
|
||||
func (cs Constraints) String() string {
|
||||
csStr := make([]string, len(cs))
|
||||
for i, c := range cs {
|
||||
csStr[i] = c.String()
|
||||
}
|
||||
|
||||
return strings.Join(csStr, ",")
|
||||
}
|
||||
|
||||
// Check tests if a constraint is validated by the given version.
|
||||
func (c *Constraint) Check(v *Version) bool {
|
||||
return c.f(v, c.check)
|
||||
}
|
||||
|
||||
func (c *Constraint) String() string {
|
||||
return c.original
|
||||
}
|
||||
|
||||
func parseSingle(v string) (*Constraint, error) {
|
||||
matches := constraintRegexp.FindStringSubmatch(v)
|
||||
if matches == nil {
|
||||
return nil, fmt.Errorf("Malformed constraint: %s", v)
|
||||
}
|
||||
|
||||
check, err := NewVersion(matches[2])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Constraint{
|
||||
f: constraintOperators[matches[1]],
|
||||
check: check,
|
||||
original: v,
|
||||
}, nil
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Constraint functions
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
func constraintEqual(v, c *Version) bool {
|
||||
return v.Equal(c)
|
||||
}
|
||||
|
||||
func constraintNotEqual(v, c *Version) bool {
|
||||
return !v.Equal(c)
|
||||
}
|
||||
|
||||
func constraintGreaterThan(v, c *Version) bool {
|
||||
return v.Compare(c) == 1
|
||||
}
|
||||
|
||||
func constraintLessThan(v, c *Version) bool {
|
||||
return v.Compare(c) == -1
|
||||
}
|
||||
|
||||
func constraintGreaterThanEqual(v, c *Version) bool {
|
||||
return v.Compare(c) >= 0
|
||||
}
|
||||
|
||||
func constraintLessThanEqual(v, c *Version) bool {
|
||||
return v.Compare(c) <= 0
|
||||
}
|
||||
|
||||
func constraintPessimistic(v, c *Version) bool {
|
||||
// If the version being checked is naturally less than the constraint, then there
|
||||
// is no way for the version to be valid against the constraint
|
||||
if v.LessThan(c) {
|
||||
return false
|
||||
}
|
||||
// We'll use this more than once, so grab the length now so it's a little cleaner
|
||||
// to write the later checks
|
||||
cs := len(c.segments)
|
||||
|
||||
// If the version being checked has less specificity than the constraint, then there
|
||||
// is no way for the version to be valid against the constraint
|
||||
if cs > len(v.segments) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check the segments in the constraint against those in the version. If the version
|
||||
// being checked, at any point, does not have the same values in each index of the
|
||||
// constraints segments, then it cannot be valid against the constraint.
|
||||
for i := 0; i < c.si-1; i++ {
|
||||
if v.segments[i] != c.segments[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Check the last part of the segment in the constraint. If the version segment at
|
||||
// this index is less than the constraints segment at this index, then it cannot
|
||||
// be valid against the constraint
|
||||
if c.segments[cs-1] > v.segments[cs-1] {
|
||||
return false
|
||||
}
|
||||
|
||||
// If nothing has rejected the version by now, it's valid
|
||||
return true
|
||||
}
|
113
vendor/github.com/hashicorp/go-version/constraint_test.go
сгенерированный
поставляемый
Normal file
113
vendor/github.com/hashicorp/go-version/constraint_test.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,113 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewConstraint(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
count int
|
||||
err bool
|
||||
}{
|
||||
{">= 1.2", 1, false},
|
||||
{"1.0", 1, false},
|
||||
{">= 1.x", 0, true},
|
||||
{">= 1.2, < 1.0", 2, false},
|
||||
|
||||
// Out of bounds
|
||||
{"11387778780781445675529500000000000000000", 0, true},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewConstraint(tc.input)
|
||||
if tc.err && err == nil {
|
||||
t.Fatalf("expected error for input: %s", tc.input)
|
||||
} else if !tc.err && err != nil {
|
||||
t.Fatalf("error for input %s: %s", tc.input, err)
|
||||
}
|
||||
|
||||
if len(v) != tc.count {
|
||||
t.Fatalf("input: %s\nexpected len: %d\nactual: %d",
|
||||
tc.input, tc.count, len(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintCheck(t *testing.T) {
|
||||
cases := []struct {
|
||||
constraint string
|
||||
version string
|
||||
check bool
|
||||
}{
|
||||
{">= 1.0, < 1.2", "1.1.5", true},
|
||||
{"< 1.0, < 1.2", "1.1.5", false},
|
||||
{"= 1.0", "1.1.5", false},
|
||||
{"= 1.0", "1.0.0", true},
|
||||
{"1.0", "1.0.0", true},
|
||||
{"~> 1.0", "2.0", false},
|
||||
{"~> 1.0", "1.1", true},
|
||||
{"~> 1.0", "1.2.3", true},
|
||||
{"~> 1.0.0", "1.2.3", false},
|
||||
{"~> 1.0.0", "1.0.7", true},
|
||||
{"~> 1.0.0", "1.1.0", false},
|
||||
{"~> 1.0.7", "1.0.4", false},
|
||||
{"~> 1.0.7", "1.0.7", true},
|
||||
{"~> 1.0.7", "1.0.8", true},
|
||||
{"~> 1.0.7", "1.0.7.5", true},
|
||||
{"~> 1.0.7", "1.0.6.99", false},
|
||||
{"~> 1.0.7", "1.0.8.0", true},
|
||||
{"~> 1.0.9.5", "1.0.9.5", true},
|
||||
{"~> 1.0.9.5", "1.0.9.4", false},
|
||||
{"~> 1.0.9.5", "1.0.9.6", true},
|
||||
{"~> 1.0.9.5", "1.0.9.5.0", true},
|
||||
{"~> 1.0.9.5", "1.0.9.5.1", true},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
c, err := NewConstraint(tc.constraint)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := c.Check(v)
|
||||
expected := tc.check
|
||||
if actual != expected {
|
||||
t.Fatalf("Version: %s\nConstraint: %s\nExpected: %#v",
|
||||
tc.version, tc.constraint, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintsString(t *testing.T) {
|
||||
cases := []struct {
|
||||
constraint string
|
||||
result string
|
||||
}{
|
||||
{">= 1.0, < 1.2", ""},
|
||||
{"~> 1.0.7", ""},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
c, err := NewConstraint(tc.constraint)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := c.String()
|
||||
expected := tc.result
|
||||
if expected == "" {
|
||||
expected = tc.constraint
|
||||
}
|
||||
|
||||
if actual != expected {
|
||||
t.Fatalf("Constraint: %s\nExpected: %#v\nActual: %s",
|
||||
tc.constraint, expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,322 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// The compiled regular expression used to test the validity of a version.
|
||||
var versionRegexp *regexp.Regexp
|
||||
|
||||
// The raw regular expression string used for testing the validity
|
||||
// of a version.
|
||||
const VersionRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` +
|
||||
`(-?([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
|
||||
`(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
|
||||
`?`
|
||||
|
||||
// Version represents a single version.
|
||||
type Version struct {
|
||||
metadata string
|
||||
pre string
|
||||
segments []int64
|
||||
si int
|
||||
}
|
||||
|
||||
func init() {
|
||||
versionRegexp = regexp.MustCompile("^" + VersionRegexpRaw + "$")
|
||||
}
|
||||
|
||||
// NewVersion parses the given version and returns a new
|
||||
// Version.
|
||||
func NewVersion(v string) (*Version, error) {
|
||||
matches := versionRegexp.FindStringSubmatch(v)
|
||||
if matches == nil {
|
||||
return nil, fmt.Errorf("Malformed version: %s", v)
|
||||
}
|
||||
segmentsStr := strings.Split(matches[1], ".")
|
||||
segments := make([]int64, len(segmentsStr))
|
||||
si := 0
|
||||
for i, str := range segmentsStr {
|
||||
val, err := strconv.ParseInt(str, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
segments[i] = int64(val)
|
||||
si++
|
||||
}
|
||||
|
||||
// Even though we could support more than three segments, if we
|
||||
// got less than three, pad it with 0s. This is to cover the basic
|
||||
// default usecase of semver, which is MAJOR.MINOR.PATCH at the minimum
|
||||
for i := len(segments); i < 3; i++ {
|
||||
segments = append(segments, 0)
|
||||
}
|
||||
|
||||
return &Version{
|
||||
metadata: matches[7],
|
||||
pre: matches[4],
|
||||
segments: segments,
|
||||
si: si,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Must is a helper that wraps a call to a function returning (*Version, error)
|
||||
// and panics if error is non-nil.
|
||||
func Must(v *Version, err error) *Version {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Compare compares this version to another version. This
|
||||
// returns -1, 0, or 1 if this version is smaller, equal,
|
||||
// or larger than the other version, respectively.
|
||||
//
|
||||
// If you want boolean results, use the LessThan, Equal,
|
||||
// or GreaterThan methods.
|
||||
func (v *Version) Compare(other *Version) int {
|
||||
// A quick, efficient equality check
|
||||
if v.String() == other.String() {
|
||||
return 0
|
||||
}
|
||||
|
||||
segmentsSelf := v.Segments64()
|
||||
segmentsOther := other.Segments64()
|
||||
|
||||
// If the segments are the same, we must compare on prerelease info
|
||||
if reflect.DeepEqual(segmentsSelf, segmentsOther) {
|
||||
preSelf := v.Prerelease()
|
||||
preOther := other.Prerelease()
|
||||
if preSelf == "" && preOther == "" {
|
||||
return 0
|
||||
}
|
||||
if preSelf == "" {
|
||||
return 1
|
||||
}
|
||||
if preOther == "" {
|
||||
return -1
|
||||
}
|
||||
|
||||
return comparePrereleases(preSelf, preOther)
|
||||
}
|
||||
|
||||
// Get the highest specificity (hS), or if they're equal, just use segmentSelf length
|
||||
lenSelf := len(segmentsSelf)
|
||||
lenOther := len(segmentsOther)
|
||||
hS := lenSelf
|
||||
if lenSelf < lenOther {
|
||||
hS = lenOther
|
||||
}
|
||||
// Compare the segments
|
||||
// Because a constraint could have more/less specificity than the version it's
|
||||
// checking, we need to account for a lopsided or jagged comparison
|
||||
for i := 0; i < hS; i++ {
|
||||
if i > lenSelf-1 {
|
||||
// This means Self had the lower specificity
|
||||
// Check to see if the remaining segments in Other are all zeros
|
||||
if !allZero(segmentsOther[i:]) {
|
||||
// if not, it means that Other has to be greater than Self
|
||||
return -1
|
||||
}
|
||||
break
|
||||
} else if i > lenOther-1 {
|
||||
// this means Other had the lower specificity
|
||||
// Check to see if the remaining segments in Self are all zeros -
|
||||
if !allZero(segmentsSelf[i:]) {
|
||||
//if not, it means that Self has to be greater than Other
|
||||
return 1
|
||||
}
|
||||
break
|
||||
}
|
||||
lhs := segmentsSelf[i]
|
||||
rhs := segmentsOther[i]
|
||||
if lhs == rhs {
|
||||
continue
|
||||
} else if lhs < rhs {
|
||||
return -1
|
||||
}
|
||||
// Otherwis, rhs was > lhs, they're not equal
|
||||
return 1
|
||||
}
|
||||
|
||||
// if we got this far, they're equal
|
||||
return 0
|
||||
}
|
||||
|
||||
func allZero(segs []int64) bool {
|
||||
for _, s := range segs {
|
||||
if s != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func comparePart(preSelf string, preOther string) int {
|
||||
if preSelf == preOther {
|
||||
return 0
|
||||
}
|
||||
|
||||
selfNumeric := true
|
||||
_, err := strconv.ParseInt(preSelf, 10, 64)
|
||||
if err != nil {
|
||||
selfNumeric = false
|
||||
}
|
||||
|
||||
otherNumeric := true
|
||||
_, err = strconv.ParseInt(preOther, 10, 64)
|
||||
if err != nil {
|
||||
otherNumeric = false
|
||||
}
|
||||
|
||||
// if a part is empty, we use the other to decide
|
||||
if preSelf == "" {
|
||||
if otherNumeric {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
if preOther == "" {
|
||||
if selfNumeric {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
if selfNumeric && !otherNumeric {
|
||||
return -1
|
||||
} else if !selfNumeric && otherNumeric {
|
||||
return 1
|
||||
} else if preSelf > preOther {
|
||||
return 1
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
func comparePrereleases(v string, other string) int {
|
||||
// the same pre release!
|
||||
if v == other {
|
||||
return 0
|
||||
}
|
||||
|
||||
// split both pre releases for analyse their parts
|
||||
selfPreReleaseMeta := strings.Split(v, ".")
|
||||
otherPreReleaseMeta := strings.Split(other, ".")
|
||||
|
||||
selfPreReleaseLen := len(selfPreReleaseMeta)
|
||||
otherPreReleaseLen := len(otherPreReleaseMeta)
|
||||
|
||||
biggestLen := otherPreReleaseLen
|
||||
if selfPreReleaseLen > otherPreReleaseLen {
|
||||
biggestLen = selfPreReleaseLen
|
||||
}
|
||||
|
||||
// loop for parts to find the first difference
|
||||
for i := 0; i < biggestLen; i = i + 1 {
|
||||
partSelfPre := ""
|
||||
if i < selfPreReleaseLen {
|
||||
partSelfPre = selfPreReleaseMeta[i]
|
||||
}
|
||||
|
||||
partOtherPre := ""
|
||||
if i < otherPreReleaseLen {
|
||||
partOtherPre = otherPreReleaseMeta[i]
|
||||
}
|
||||
|
||||
compare := comparePart(partSelfPre, partOtherPre)
|
||||
// if parts are equals, continue the loop
|
||||
if compare != 0 {
|
||||
return compare
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Equal tests if two versions are equal.
|
||||
func (v *Version) Equal(o *Version) bool {
|
||||
return v.Compare(o) == 0
|
||||
}
|
||||
|
||||
// GreaterThan tests if this version is greater than another version.
|
||||
func (v *Version) GreaterThan(o *Version) bool {
|
||||
return v.Compare(o) > 0
|
||||
}
|
||||
|
||||
// LessThan tests if this version is less than another version.
|
||||
func (v *Version) LessThan(o *Version) bool {
|
||||
return v.Compare(o) < 0
|
||||
}
|
||||
|
||||
// Metadata returns any metadata that was part of the version
|
||||
// string.
|
||||
//
|
||||
// Metadata is anything that comes after the "+" in the version.
|
||||
// For example, with "1.2.3+beta", the metadata is "beta".
|
||||
func (v *Version) Metadata() string {
|
||||
return v.metadata
|
||||
}
|
||||
|
||||
// Prerelease returns any prerelease data that is part of the version,
|
||||
// or blank if there is no prerelease data.
|
||||
//
|
||||
// Prerelease information is anything that comes after the "-" in the
|
||||
// version (but before any metadata). For example, with "1.2.3-beta",
|
||||
// the prerelease information is "beta".
|
||||
func (v *Version) Prerelease() string {
|
||||
return v.pre
|
||||
}
|
||||
|
||||
// Segments returns the numeric segments of the version as a slice of ints.
|
||||
//
|
||||
// This excludes any metadata or pre-release information. For example,
|
||||
// for a version "1.2.3-beta", segments will return a slice of
|
||||
// 1, 2, 3.
|
||||
func (v *Version) Segments() []int {
|
||||
segmentSlice := make([]int, len(v.segments))
|
||||
for i, v := range v.segments {
|
||||
segmentSlice[i] = int(v)
|
||||
}
|
||||
return segmentSlice
|
||||
}
|
||||
|
||||
// Segments64 returns the numeric segments of the version as a slice of int64s.
|
||||
//
|
||||
// This excludes any metadata or pre-release information. For example,
|
||||
// for a version "1.2.3-beta", segments will return a slice of
|
||||
// 1, 2, 3.
|
||||
func (v *Version) Segments64() []int64 {
|
||||
return v.segments
|
||||
}
|
||||
|
||||
// String returns the full version string included pre-release
|
||||
// and metadata information.
|
||||
func (v *Version) String() string {
|
||||
var buf bytes.Buffer
|
||||
fmtParts := make([]string, len(v.segments))
|
||||
for i, s := range v.segments {
|
||||
// We can ignore err here since we've pre-parsed the values in segments
|
||||
str := strconv.FormatInt(s, 10)
|
||||
fmtParts[i] = str
|
||||
}
|
||||
fmt.Fprintf(&buf, strings.Join(fmtParts, "."))
|
||||
if v.pre != "" {
|
||||
fmt.Fprintf(&buf, "-%s", v.pre)
|
||||
}
|
||||
if v.metadata != "" {
|
||||
fmt.Fprintf(&buf, "+%s", v.metadata)
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
17
vendor/github.com/hashicorp/go-version/version_collection.go
сгенерированный
поставляемый
Normal file
17
vendor/github.com/hashicorp/go-version/version_collection.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,17 @@
|
|||
package version
|
||||
|
||||
// Collection is a type that implements the sort.Interface interface
|
||||
// so that versions can be sorted.
|
||||
type Collection []*Version
|
||||
|
||||
func (v Collection) Len() int {
|
||||
return len(v)
|
||||
}
|
||||
|
||||
func (v Collection) Less(i, j int) bool {
|
||||
return v[i].LessThan(v[j])
|
||||
}
|
||||
|
||||
func (v Collection) Swap(i, j int) {
|
||||
v[i], v[j] = v[j], v[i]
|
||||
}
|
46
vendor/github.com/hashicorp/go-version/version_collection_test.go
сгенерированный
поставляемый
Normal file
46
vendor/github.com/hashicorp/go-version/version_collection_test.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,46 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCollection(t *testing.T) {
|
||||
versionsRaw := []string{
|
||||
"1.1.1",
|
||||
"1.0",
|
||||
"1.2",
|
||||
"2",
|
||||
"0.7.1",
|
||||
}
|
||||
|
||||
versions := make([]*Version, len(versionsRaw))
|
||||
for i, raw := range versionsRaw {
|
||||
v, err := NewVersion(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
versions[i] = v
|
||||
}
|
||||
|
||||
sort.Sort(Collection(versions))
|
||||
|
||||
actual := make([]string, len(versions))
|
||||
for i, v := range versions {
|
||||
actual[i] = v.String()
|
||||
}
|
||||
|
||||
expected := []string{
|
||||
"0.7.1",
|
||||
"1.0.0",
|
||||
"1.1.1",
|
||||
"1.2.0",
|
||||
"2.0.0",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewVersion(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
err bool
|
||||
}{
|
||||
{"1.2.3", false},
|
||||
{"1.0", false},
|
||||
{"1", false},
|
||||
{"1.2.beta", true},
|
||||
{"foo", true},
|
||||
{"1.2-5", false},
|
||||
{"1.2-beta.5", false},
|
||||
{"\n1.2", true},
|
||||
{"1.2.0-x.Y.0+metadata", false},
|
||||
{"1.2.0-x.Y.0+metadata-width-hypen", false},
|
||||
{"1.2.3-rc1-with-hypen", false},
|
||||
{"1.2.3.4", false},
|
||||
{"1.2.0.4-x.Y.0+metadata", false},
|
||||
{"1.2.0.4-x.Y.0+metadata-width-hypen", false},
|
||||
{"1.2.3.4-rc1-with-hypen", false},
|
||||
{"1.2.3.4", false},
|
||||
{"v1.2.3", false},
|
||||
{"foo1.2.3", true},
|
||||
{"1.7rc2", false},
|
||||
{"v1.7rc2", false},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
_, err := NewVersion(tc.version)
|
||||
if tc.err && err == nil {
|
||||
t.Fatalf("expected error for version: %s", tc.version)
|
||||
} else if !tc.err && err != nil {
|
||||
t.Fatalf("error for version %s: %s", tc.version, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionCompare(t *testing.T) {
|
||||
cases := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected int
|
||||
}{
|
||||
{"1.2.3", "1.4.5", -1},
|
||||
{"1.2-beta", "1.2-beta", 0},
|
||||
{"1.2", "1.1.4", 1},
|
||||
{"1.2", "1.2-beta", 1},
|
||||
{"1.2+foo", "1.2+beta", 0},
|
||||
{"v1.2", "v1.2-beta", 1},
|
||||
{"v1.2+foo", "v1.2+beta", 0},
|
||||
{"v1.2.3.4", "v1.2.3.4", 0},
|
||||
{"v1.2.0.0", "v1.2", 0},
|
||||
{"v1.2.0.0.1", "v1.2", 1},
|
||||
{"v1.2", "v1.2.0.0", 0},
|
||||
{"v1.2", "v1.2.0.0.1", -1},
|
||||
{"v1.2.0.0", "v1.2.0.0.1", -1},
|
||||
{"v1.2.3.0", "v1.2.3.4", -1},
|
||||
{"1.7rc2", "1.7rc1", 1},
|
||||
{"1.7rc2", "1.7", -1},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v1.Compare(v2)
|
||||
expected := tc.expected
|
||||
if actual != expected {
|
||||
t.Fatalf(
|
||||
"%s <=> %s\nexpected: %d\nactual: %d",
|
||||
tc.v1, tc.v2,
|
||||
expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparePreReleases(t *testing.T) {
|
||||
cases := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected int
|
||||
}{
|
||||
{"1.2-beta.2", "1.2-beta.2", 0},
|
||||
{"1.2-beta.1", "1.2-beta.2", -1},
|
||||
{"3.2-alpha.1", "3.2-alpha", 1},
|
||||
{"1.2-beta.2", "1.2-beta.1", 1},
|
||||
{"1.2-beta", "1.2-beta.3", -1},
|
||||
{"1.2-alpha", "1.2-beta.3", -1},
|
||||
{"1.2-beta", "1.2-alpha.3", 1},
|
||||
{"3.0-alpha.3", "3.0-rc.1", -1},
|
||||
{"3.0-alpha3", "3.0-rc1", -1},
|
||||
{"3.0-alpha.1", "3.0-alpha.beta", -1},
|
||||
{"5.4-alpha", "5.4-alpha.beta", 1},
|
||||
{"v1.2-beta.2", "v1.2-beta.2", 0},
|
||||
{"v1.2-beta.1", "v1.2-beta.2", -1},
|
||||
{"v3.2-alpha.1", "v3.2-alpha", 1},
|
||||
{"v3.2-rc.1-1-g123", "v3.2-rc.2", 1},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v1.Compare(v2)
|
||||
expected := tc.expected
|
||||
if actual != expected {
|
||||
t.Fatalf(
|
||||
"%s <=> %s\nexpected: %d\nactual: %d",
|
||||
tc.v1, tc.v2,
|
||||
expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionMetadata(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
expected string
|
||||
}{
|
||||
{"1.2.3", ""},
|
||||
{"1.2-beta", ""},
|
||||
{"1.2.0-x.Y.0", ""},
|
||||
{"1.2.0-x.Y.0+metadata", "metadata"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v.Metadata()
|
||||
expected := tc.expected
|
||||
if actual != expected {
|
||||
t.Fatalf("expected: %s\nactual: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionPrerelease(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
expected string
|
||||
}{
|
||||
{"1.2.3", ""},
|
||||
{"1.2-beta", "beta"},
|
||||
{"1.2.0-x.Y.0", "x.Y.0"},
|
||||
{"1.2.0-x.Y.0+metadata", "x.Y.0"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v.Prerelease()
|
||||
expected := tc.expected
|
||||
if actual != expected {
|
||||
t.Fatalf("expected: %s\nactual: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionSegments(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
expected []int
|
||||
}{
|
||||
{"1.2.3", []int{1, 2, 3}},
|
||||
{"1.2-beta", []int{1, 2, 0}},
|
||||
{"1-x.Y.0", []int{1, 0, 0}},
|
||||
{"1.2.0-x.Y.0+metadata", []int{1, 2, 0}},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v.Segments()
|
||||
expected := tc.expected
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("expected: %#v\nactual: %#v", expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionSegments64(t *testing.T) {
|
||||
cases := []struct {
|
||||
version string
|
||||
expected []int64
|
||||
}{
|
||||
{"1.2.3", []int64{1, 2, 3}},
|
||||
{"1.2-beta", []int64{1, 2, 0}},
|
||||
{"1-x.Y.0", []int64{1, 0, 0}},
|
||||
{"1.2.0-x.Y.0+metadata", []int64{1, 2, 0}},
|
||||
{"1.4.9223372036854775807", []int64{1, 4, 9223372036854775807}},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v.Segments64()
|
||||
expected := tc.expected
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("expected: %#v\nactual: %#v", expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionString(t *testing.T) {
|
||||
cases := [][]string{
|
||||
{"1.2.3", "1.2.3"},
|
||||
{"1.2-beta", "1.2.0-beta"},
|
||||
{"1.2.0-x.Y.0", "1.2.0-x.Y.0"},
|
||||
{"1.2.0-x.Y.0+metadata", "1.2.0-x.Y.0+metadata"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := NewVersion(tc[0])
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := v.String()
|
||||
expected := tc[1]
|
||||
if actual != expected {
|
||||
t.Fatalf("expected: %s\nactual: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче