fixed all linting warnings/errors, now enforcing (#1369)

This commit is contained in:
Jack Francis 2017-08-29 15:34:24 -07:00 коммит произвёл GitHub
Родитель f93c3807c2
Коммит 562f208e91
30 изменённых файлов: 103 добавлений и 96 удалений

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -100,7 +100,7 @@ write_files:
permissions: "0644"
owner: "root"
content: |
KUBELET_CLUSTER_DNS={{WrapAsVariable "kubeDnsServiceIP"}}
KUBELET_CLUSTER_DNS={{WrapAsVariable "kubeDNSServiceIP"}}
KUBELET_API_SERVERS=https://{{WrapAsVariable "kubernetesAPIServerIP"}}:443
KUBELET_IMAGE={{WrapAsVariable "kubernetesHyperkubeSpec"}}
KUBELET_NETWORK_PLUGIN=kubenet

Просмотреть файл

@ -184,7 +184,7 @@ write_files:
permissions: "0644"
owner: "root"
content: |
KUBELET_CLUSTER_DNS={{WrapAsVariable "kubeDnsServiceIP"}}
KUBELET_CLUSTER_DNS={{WrapAsVariable "kubeDNSServiceIP"}}
KUBELET_API_SERVERS={{WrapAsVerbatim "concat('https://', variables('masterPrivateIpAddrs')[copyIndex(variables('masterOffset'))], ':443')"}}
KUBELET_IMAGE={{WrapAsVariable "kubernetesHyperkubeSpec"}}
KUBELET_NETWORK_PLUGIN=
@ -255,7 +255,7 @@ write_files:
sed -i "s|<kubernetesHeapsterSpec>|{{WrapAsVariable "kubernetesHeapsterSpec"}}|g; s|<kubernetesAddonResizerSpec>|{{WrapAsVariable "kubernetesAddonResizerSpec"}}|g" "/etc/kubernetes/addons/kube-heapster-deployment.yaml"
sed -i "s|<kubernetesDashboardSpec>|{{WrapAsVariable "kubernetesDashboardSpec"}}|g" "/etc/kubernetes/addons/kubernetes-dashboard-deployment.yaml"
sed -i "s|<kubernetesTillerSpec>|{{WrapAsVariable "kubernetesTillerSpec"}}|g" "/etc/kubernetes/addons/kube-tiller-deployment.yaml"
sed -i "s|<kubeDnsServiceIP>|{{WrapAsVariable "kubeDnsServiceIP"}}|g" "/etc/kubernetes/addons/kube-dns-deployment.yaml"
sed -i "s|<kubeDNSServiceIP>|{{WrapAsVariable "kubeDNSServiceIP"}}|g" "/etc/kubernetes/addons/kube-dns-deployment.yaml"
{{if .OrchestratorProfile.KubernetesConfig.EnableRbac }}
# If RBAC enabled then add parameters to API server and Controller manager configuration

Просмотреть файл

@ -141,7 +141,7 @@
"virtualNetworkName": "[concat(variables('orchestratorName'), '-vnet-', variables('nameSuffix'))]",
{{end}}
"vnetCidr": "[parameters('vnetCidr')]",
"kubeDnsServiceIP": "[parameters('kubeDnsServiceIP')]",
"kubeDNSServiceIP": "[parameters('kubeDNSServiceIP')]",
"kubeServiceCidr": "[parameters('kubeServiceCidr')]",
"kubeClusterCidr": "[parameters('kubeClusterCidr')]",
"dockerBridgeCidr": "[parameters('dockerBridgeCidr')]",

Просмотреть файл

@ -84,8 +84,8 @@
},
"type": "string"
},
"kubeDnsServiceIP": {
{{PopulateClassicModeDefaultValue "kubeDnsServiceIP"}}
"kubeDNSServiceIP": {
{{PopulateClassicModeDefaultValue "kubeDNSServiceIP"}}
"metadata": {
"description": "Kubernetes DNS IP"
},

Просмотреть файл

@ -105,7 +105,7 @@
"orchestratorName": "swarm",
"osImageSKU": "14.04.5-LTS",
"osImageVersion": "14.04.201706190",
{{GetSwarmVersions}}
{{getSwarmVersions}}
{{end}}
"locations": [
"[resourceGroup().location]",

Просмотреть файл

@ -1,6 +1,7 @@
package acsengine
// AUTOGENERATED FILE - last generated 2017-08-08 21:39:37
// AzureLocations provides all azure regions in prod.
// Related powershell to refresh this list:
// Get-AzureRmLocation | Select-Object -Property Location

Просмотреть файл

@ -68,9 +68,9 @@ const (
DefaultKubernetesCloudProviderRateLimitBucket = 10
// DefaultTillerImage defines the Helm Tiller deployment version on Kubernetes Clusters
DefaultTillerImage = "tiller:v2.6.0"
// DefaultKubernetesDnsServiceIP specifies the IP address that kube-dns
// DefaultKubernetesDNSServiceIP specifies the IP address that kube-dns
// listens on by default. must by in the default Service CIDR range.
DefaultKubernetesDnsServiceIP = "10.0.0.10"
DefaultKubernetesDNSServiceIP = "10.0.0.10"
// DefaultKubernetesServiceCIDR specifies the IP subnet that kubernetes will
// create Service IPs within.
DefaultKubernetesServiceCIDR = "10.0.0.0/16"
@ -86,11 +86,13 @@ const (
)
const (
// Swarm orchestrator and docker compose versions
SwarmVersion = "swarm:1.1.0"
// SwarmVersion is the Swarm orchestrator version
SwarmVersion = "swarm:1.1.0"
// SwarmDockerComposeVersion is the Docker Compose version
SwarmDockerComposeVersion = "1.6.2"
// DockerCE orchestrator and docker compose versions
DockerCEVersion = "17.03.*"
// DockerCEVersion is the DockerCE orchestrator version
DockerCEVersion = "17.03.*"
// DockerCEDockerComposeVersion is the Docker Compose version
DockerCEDockerComposeVersion = "1.14.0"
)

Просмотреть файл

@ -167,8 +167,8 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
a.OrchestratorProfile.KubernetesConfig.MaxPods = DefaultKubernetesMaxPods
}
}
if a.OrchestratorProfile.KubernetesConfig.DnsServiceIP == "" {
a.OrchestratorProfile.KubernetesConfig.DnsServiceIP = DefaultKubernetesDnsServiceIP
if a.OrchestratorProfile.KubernetesConfig.DNSServiceIP == "" {
a.OrchestratorProfile.KubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIP
}
if a.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet == "" {
a.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
@ -353,11 +353,11 @@ func setDefaultCerts(a *api.Properties) (bool, error) {
a.CertificateProfile.CaPrivateKey = caPair.PrivateKeyPem
}
cidrFirstIp, err := common.CidrStringFirstIp(a.OrchestratorProfile.KubernetesConfig.ServiceCIDR)
cidrFirstIP, err := common.CidrStringFirstIP(a.OrchestratorProfile.KubernetesConfig.ServiceCIDR)
if err != nil {
return false, err
}
ips = append(ips, cidrFirstIp)
ips = append(ips, cidrFirstIP)
apiServerPair, clientPair, kubeConfigPair, err := CreatePki(masterExtraFQDNs, ips, DefaultKubernetesClusterDomain, caPair)
if err != nil {

Просмотреть файл

@ -492,7 +492,7 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (paramsMap, err
addValue(parametersMap, "kubernetesEndpoint", properties.HostedMasterProfile.FQDN)
}
addValue(parametersMap, "dockerEngineDownloadRepo", cloudSpecConfig.DockerSpecConfig.DockerEngineRepo)
addValue(parametersMap, "kubeDnsServiceIP", properties.OrchestratorProfile.KubernetesConfig.DnsServiceIP)
addValue(parametersMap, "kubeDNSServiceIP", properties.OrchestratorProfile.KubernetesConfig.DNSServiceIP)
addValue(parametersMap, "kubeServiceCidr", properties.OrchestratorProfile.KubernetesConfig.ServiceCIDR)
addValue(parametersMap, "kubernetesHyperkubeSpec", kubernetesHyperkubeSpec)
addValue(parametersMap, "kubernetesAddonManagerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[KubernetesRelease]["addonmanager"])
@ -760,11 +760,11 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
}
return GetMasterAgentAllowedSizes()
},
"GetSwarmVersions": func() string {
return GetSwarmVersions(SwarmVersion, SwarmDockerComposeVersion)
"getSwarmVersions": func() string {
return getSwarmVersions(SwarmVersion, SwarmDockerComposeVersion)
},
"GetSwarmModeVersions": func() string {
return GetSwarmVersions(DockerCEVersion, DockerCEDockerComposeVersion)
return getSwarmVersions(DockerCEVersion, DockerCEDockerComposeVersion)
},
"GetSizeMap": func() string {
if t.ClassicMode {
@ -990,8 +990,8 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
val = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + KubeConfigs[kubernetesRelease]["windowszip"]
case "kubeClusterCidr":
val = DefaultKubernetesClusterSubnet
case "kubeDnsServiceIP":
val = DefaultKubernetesDnsServiceIP
case "kubeDNSServiceIP":
val = DefaultKubernetesDNSServiceIP
case "kubeServiceCidr":
val = DefaultKubernetesServiceCIDR
case "kubeBinariesVersion":
@ -1522,6 +1522,6 @@ func getKubernetesPodStartIndex(properties *api.Properties) int {
return nodeCount + 1
}
func GetSwarmVersions(orchestratorVersion, dockerComposeVersion string) string {
func getSwarmVersions(orchestratorVersion, dockerComposeVersion string) string {
return fmt.Sprintf("\"orchestratorVersion\": \"%s\",\n\"dockerComposeVersion\": \"%s\",\n", orchestratorVersion, dockerComposeVersion)
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -50,10 +50,12 @@ type KubernetesSpecConfig struct {
CalicoConfigDownloadURL string
}
//AzureEndpointConfig describes an Azure endpoint
type AzureEndpointConfig struct {
ResourceManagerVMDNSSuffix string
}
//AzureOSImageConfig describes an Azure OS image
type AzureOSImageConfig struct {
ImageOffer string
ImageSku string

Просмотреть файл

@ -2,8 +2,8 @@ package common
import "net"
// CidrStringFirstIp returns the first IP of the provided subnet.
func CidrFirstIp(cidr net.IP) net.IP {
// CidrFirstIP returns the first IP of the provided subnet.
func CidrFirstIP(cidr net.IP) net.IP {
for j := len(cidr) - 1; j >= 0; j-- {
cidr[j]++
if cidr[j] > 0 {
@ -13,18 +13,18 @@ func CidrFirstIp(cidr net.IP) net.IP {
return cidr
}
// CidrStringFirstIp returns the first IP of the provided subnet string. Returns an error
// CidrStringFirstIP returns the first IP of the provided subnet string. Returns an error
// if the string cannot be parsed.
func CidrStringFirstIp(ip string) (net.IP, error) {
func CidrStringFirstIP(ip string) (net.IP, error) {
cidr, _, err := net.ParseCIDR(ip)
if err != nil {
return nil, err
}
return CidrFirstIp(cidr), nil
return CidrFirstIP(cidr), nil
}
// Ip4BroadcastAddress returns the broadcast address for the given IP subnet.
func Ip4BroadcastAddress(n *net.IPNet) net.IP {
// IP4BroadcastAddress returns the broadcast address for the given IP subnet.
func IP4BroadcastAddress(n *net.IPNet) net.IP {
// see https://groups.google.com/d/msg/golang-nuts/IrfXFTUavXE/8YwzIOBwJf0J
ip4 := n.IP.To4()
if ip4 == nil {

Просмотреть файл

@ -10,7 +10,7 @@ type test struct {
expected string
}
func Test_CidrFirstIp(t *testing.T) {
func Test_CidrFirstIP(t *testing.T) {
scenarios := []test{
{
cidr: "10.0.0.0/16",
@ -23,13 +23,13 @@ func Test_CidrFirstIp(t *testing.T) {
}
for _, scenario := range scenarios {
if first, _ := CidrStringFirstIp(scenario.cidr); first.String() != scenario.expected {
if first, _ := CidrStringFirstIP(scenario.cidr); first.String() != scenario.expected {
t.Errorf("expected first ip of subnet %v to be %v but was %v", scenario.cidr, scenario.expected, first)
}
}
}
func Test_Ip4BroadcastAddress(t *testing.T) {
func Test_IP4BroadcastAddress(t *testing.T) {
scenarios := []test{
{
cidr: "10.0.0.0/16",
@ -43,7 +43,7 @@ func Test_Ip4BroadcastAddress(t *testing.T) {
for _, scenario := range scenarios {
_, cidr, _ := net.ParseCIDR(scenario.cidr)
if broadcast := Ip4BroadcastAddress(cidr); broadcast.String() != scenario.expected {
if broadcast := IP4BroadcastAddress(cidr); broadcast.String() != scenario.expected {
t.Errorf("expected broadcast ip of subnet %v to be %v but was %v", scenario.cidr, scenario.expected, broadcast)
}
}

Просмотреть файл

@ -10,7 +10,7 @@ import "github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20170831"
// for converting.
///////////////////////////////////////////////////////////
// ConvertContainerServiceToV20170831 converts an unversioned ContainerService to a v20170831 ContainerService
// ConvertContainerServiceToV20170831AgentPoolOnly converts an unversioned ContainerService to a v20170831 ContainerService
func ConvertContainerServiceToV20170831AgentPoolOnly(api *ContainerService) *v20170831.ManagedCluster {
v20170831HCP := &v20170831.ManagedCluster{}
v20170831HCP.ID = api.ID

Просмотреть файл

@ -558,7 +558,7 @@ func convertOrchestratorProfileToVLabs(api *OrchestratorProfile, o *vlabs.Orches
func convertKubernetesConfigToVLabs(api *KubernetesConfig, vlabs *vlabs.KubernetesConfig) {
vlabs.KubernetesImageBase = api.KubernetesImageBase
vlabs.ClusterSubnet = api.ClusterSubnet
vlabs.DnsServiceIP = api.DnsServiceIP
vlabs.DNSServiceIP = api.DNSServiceIP
vlabs.ServiceCidr = api.ServiceCIDR
vlabs.NetworkPolicy = api.NetworkPolicy
vlabs.MaxPods = api.MaxPods

Просмотреть файл

@ -70,7 +70,7 @@ func convertV20170831AgentPoolOnlyProperties(obj *v20170831.Properties) *Propert
return properties
}
// ConvertVLabsContainerService converts a vlabs ContainerService to an unversioned ContainerService
// ConvertVLabsAgentPoolOnly converts a vlabs ContainerService to an unversioned ContainerService
func ConvertVLabsAgentPoolOnly(vlabs *vlabs.ManagedCluster) *ContainerService {
c := &ContainerService{}
c.ID = vlabs.ID

Просмотреть файл

@ -567,7 +567,7 @@ func convertVLabsOrchestratorProfile(vlabscs *vlabs.OrchestratorProfile, api *Or
func convertVLabsKubernetesConfig(vlabs *vlabs.KubernetesConfig, api *KubernetesConfig) {
api.KubernetesImageBase = vlabs.KubernetesImageBase
api.ClusterSubnet = vlabs.ClusterSubnet
api.DnsServiceIP = vlabs.DnsServiceIP
api.DNSServiceIP = vlabs.DNSServiceIP
api.ServiceCIDR = vlabs.ServiceCidr
api.NetworkPolicy = vlabs.NetworkPolicy
api.MaxPods = vlabs.MaxPods

Просмотреть файл

@ -147,7 +147,7 @@ type KubernetesConfig struct {
NetworkPolicy string `json:"networkPolicy,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DnsServiceIP string `json:"dnsServiceIP,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
@ -266,6 +266,7 @@ type KeyVaultCertificate struct {
// OSType represents OS types of agents
type OSType string
// HostedMasterProfile defines properties for a hosted master
type HostedMasterProfile struct {
// Master public endpoint/FQDN with port
// The format will be FQDN:2376

Просмотреть файл

@ -60,6 +60,7 @@ type ServicePrincipalProfile struct {
KeyvaultSecretRef *KeyvaultSecretRef `json:"keyvaultSecretRef,omitempty"`
}
// KeyvaultSecretRef is a reference to a secret in a keyvault.
type KeyvaultSecretRef struct {
VaultID string `json:"vaultID" validate:"required"`
SecretName string `json:"secretName" validate:"required"`

Просмотреть файл

@ -12,12 +12,12 @@ import (
var (
validate *validator.Validate
keyvaultIdRegex *regexp.Regexp
keyvaultIDRegex *regexp.Regexp
)
func init() {
validate = validator.New()
keyvaultIdRegex = regexp.MustCompile(`^/subscriptions/\S+/resourceGroups/\S+/providers/Microsoft.KeyVault/vaults/[^/\s]+$`)
keyvaultIDRegex = regexp.MustCompile(`^/subscriptions/\S+/resourceGroups/\S+/providers/Microsoft.KeyVault/vaults/[^/\s]+$`)
}
// Validate implements APIObject
@ -151,7 +151,7 @@ func (a *Properties) Validate() error {
if e := validate.Var(a.ServicePrincipalProfile.KeyvaultSecretRef.SecretName, "required"); e != nil {
return fmt.Errorf("the Keyvault Secret must be specified for the Service Principle with Orchestrator %s", a.OrchestratorProfile.OrchestratorType)
}
if !keyvaultIdRegex.MatchString(a.ServicePrincipalProfile.KeyvaultSecretRef.VaultID) {
if !keyvaultIDRegex.MatchString(a.ServicePrincipalProfile.KeyvaultSecretRef.VaultID) {
return fmt.Errorf("service principal client keyvault secret reference is of incorrect format")
}
}

Просмотреть файл

@ -51,7 +51,7 @@ type ServicePrincipalProfile struct {
KeyvaultSecretRef *KeyvaultSecretRef `json:"keyvaultSecretRef,omitempty"`
}
// The 'KeyvaultSecretRef' parameter is a reference to a secret in a keyvault.
// KeyvaultSecretRef is a reference to a secret in a keyvault.
// The format of 'VaultID' value should be
// "/subscriptions/<SUB_ID>/resourceGroups/<RG_NAME>/providers/Microsoft.KeyVault/vaults/<KV_NAME>"
// where:
@ -175,7 +175,7 @@ func (o *OrchestratorProfile) UnmarshalJSON(b []byte) error {
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
DnsServiceIP string `json:"dnsServiceIP,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCidr string `json:"serviceCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
MaxPods int `json:"maxPods,omitempty"`

Просмотреть файл

@ -15,12 +15,12 @@ import (
var (
validate *validator.Validate
keyvaultIdRegex *regexp.Regexp
keyvaultIDRegex *regexp.Regexp
)
func init() {
validate = validator.New()
keyvaultIdRegex = regexp.MustCompile(`^/subscriptions/\S+/resourceGroups/\S+/providers/Microsoft.KeyVault/vaults/[^/\s]+$`)
keyvaultIDRegex = regexp.MustCompile(`^/subscriptions/\S+/resourceGroups/\S+/providers/Microsoft.KeyVault/vaults/[^/\s]+$`)
}
// Validate implements APIObject
@ -229,7 +229,7 @@ func (a *Properties) Validate() error {
if e := validate.Var(a.ServicePrincipalProfile.KeyvaultSecretRef.SecretName, "required"); e != nil {
return fmt.Errorf("the Keyvault Secret must be specified for the Service Principle with Orchestrator %s", a.OrchestratorProfile.OrchestratorType)
}
if !keyvaultIdRegex.MatchString(a.ServicePrincipalProfile.KeyvaultSecretRef.VaultID) {
if !keyvaultIDRegex.MatchString(a.ServicePrincipalProfile.KeyvaultSecretRef.VaultID) {
return fmt.Errorf("service principal client keyvault secret reference is of incorrect format")
}
}
@ -407,17 +407,17 @@ func (a *KubernetesConfig) Validate(k8sRelease string) error {
}
}
if a.DnsServiceIP != "" || a.ServiceCidr != "" {
if a.DnsServiceIP == "" {
return errors.New("OrchestratorProfile.KubernetesConfig.ServiceCidr must be specified when DnsServiceIP is")
if a.DNSServiceIP != "" || a.ServiceCidr != "" {
if a.DNSServiceIP == "" {
return errors.New("OrchestratorProfile.KubernetesConfig.ServiceCidr must be specified when DNSServiceIP is")
}
if a.ServiceCidr == "" {
return errors.New("OrchestratorProfile.KubernetesConfig.DnsServiceIP must be specified when ServiceCidr is")
return errors.New("OrchestratorProfile.KubernetesConfig.DNSServiceIP must be specified when ServiceCidr is")
}
dnsIp := net.ParseIP(a.DnsServiceIP)
if dnsIp == nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DnsServiceIP '%s' is an invalid IP address", a.DnsServiceIP)
dnsIP := net.ParseIP(a.DNSServiceIP)
if dnsIP == nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DNSServiceIP '%s' is an invalid IP address", a.DNSServiceIP)
}
_, serviceCidr, err := net.ParseCIDR(a.ServiceCidr)
@ -426,20 +426,20 @@ func (a *KubernetesConfig) Validate(k8sRelease string) error {
}
// Finally validate that the DNS ip is within the subnet
if !serviceCidr.Contains(dnsIp) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DnsServiceIP '%s' is not within the ServiceCidr '%s'", a.DnsServiceIP, a.ServiceCidr)
if !serviceCidr.Contains(dnsIP) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DNSServiceIP '%s' is not within the ServiceCidr '%s'", a.DNSServiceIP, a.ServiceCidr)
}
// and that the DNS IP is _not_ the subnet broadcast address
broadcast := common.Ip4BroadcastAddress(serviceCidr)
if dnsIp.Equal(broadcast) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DnsServiceIP '%s' cannot be the broadcast address of ServiceCidr '%s'", a.DnsServiceIP, a.ServiceCidr)
broadcast := common.IP4BroadcastAddress(serviceCidr)
if dnsIP.Equal(broadcast) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DNSServiceIP '%s' cannot be the broadcast address of ServiceCidr '%s'", a.DNSServiceIP, a.ServiceCidr)
}
// and that the DNS IP is _not_ the first IP in the service subnet
firstServiceIp := common.CidrFirstIp(serviceCidr.IP)
if firstServiceIp.Equal(dnsIp) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DnsServiceIP '%s' cannot be the first IP of ServiceCidr '%s'", a.DnsServiceIP, a.ServiceCidr)
firstServiceIP := common.CidrFirstIP(serviceCidr.IP)
if firstServiceIP.Equal(dnsIP) {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.DNSServiceIP '%s' cannot be the first IP of ServiceCidr '%s'", a.DNSServiceIP, a.ServiceCidr)
}
}

Просмотреть файл

@ -124,29 +124,29 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
}
c = KubernetesConfig{
DnsServiceIP: "192.168.0.10",
DNSServiceIP: "192.168.0.10",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when DnsServiceIP but not ServiceCidr")
t.Error("should error when DNSServiceIP but not ServiceCidr")
}
c = KubernetesConfig{
ServiceCidr: "192.168.0.10/24",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when ServiceCidr but not DnsServiceIP")
t.Error("should error when ServiceCidr but not DNSServiceIP")
}
c = KubernetesConfig{
DnsServiceIP: "invalid",
DNSServiceIP: "invalid",
ServiceCidr: "192.168.0.0/24",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when DnsServiceIP is invalid")
t.Error("should error when DNSServiceIP is invalid")
}
c = KubernetesConfig{
DnsServiceIP: "192.168.1.10",
DNSServiceIP: "192.168.1.10",
ServiceCidr: "192.168.0.0/not-a-len",
}
if err := c.Validate(k8sRelease); err == nil {
@ -154,35 +154,35 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
}
c = KubernetesConfig{
DnsServiceIP: "192.168.1.10",
DNSServiceIP: "192.168.1.10",
ServiceCidr: "192.168.0.0/24",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when DnsServiceIP is outside of ServiceCidr")
t.Error("should error when DNSServiceIP is outside of ServiceCidr")
}
c = KubernetesConfig{
DnsServiceIP: "172.99.255.255",
DNSServiceIP: "172.99.255.255",
ServiceCidr: "172.99.0.1/16",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when DnsServiceIP is broadcast address of ServiceCidr")
t.Error("should error when DNSServiceIP is broadcast address of ServiceCidr")
}
c = KubernetesConfig{
DnsServiceIP: "172.99.0.1",
DNSServiceIP: "172.99.0.1",
ServiceCidr: "172.99.0.1/16",
}
if err := c.Validate(k8sRelease); err == nil {
t.Error("should error when DnsServiceIP is first IP of ServiceCidr")
t.Error("should error when DNSServiceIP is first IP of ServiceCidr")
}
c = KubernetesConfig{
DnsServiceIP: "172.99.255.10",
DNSServiceIP: "172.99.255.10",
ServiceCidr: "172.99.0.1/16",
}
if err := c.Validate(k8sRelease); err != nil {
t.Error("should not error when DnsServiceIP and ServiceCidr are valid")
t.Error("should not error when DNSServiceIP and ServiceCidr are valid")
}
}

Просмотреть файл

@ -54,6 +54,6 @@ gometalinter \
--deadline 60s \
--exclude pkg/i18n/translations.go \
--exclude pkg/acsengine/templates.go \
./... || : # TODO: clean up lint errors and then return 1 on errors
./... || exit_code=1
exit $exit_code