Skip to content

Commit

Permalink
Reformat source and test files
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis committed Mar 23, 2020
1 parent 27f37fb commit a1db063
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 87 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ tmp/_output
tmp/_test
_output
pf.log
LICENSE

# GoLand
.idea
Expand Down
2 changes: 1 addition & 1 deletion pkg/indexmanagement/validations_mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = Describe("Index Management", func() {
Spec: esapi.ElasticsearchSpec{
IndexManagement: &esapi.IndexManagementSpec{
Policies: []esapi.IndexManagementPolicySpec{
esapi.IndexManagementPolicySpec{
{
Name: "my-policy",
PollInterval: "10s",
Phases: esapi.IndexManagementPhasesSpec{
Expand Down
4 changes: 2 additions & 2 deletions pkg/indexmanagement/validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = Describe("Index Management", func() {
Spec: esapi.ElasticsearchSpec{
IndexManagement: &esapi.IndexManagementSpec{
Policies: []esapi.IndexManagementPolicySpec{
esapi.IndexManagementPolicySpec{
{
Name: "my-policy",
PollInterval: "10s",
Phases: esapi.IndexManagementPhasesSpec{
Expand All @@ -45,7 +45,7 @@ var _ = Describe("Index Management", func() {
},
},
Mappings: []esapi.IndexManagementPolicyMappingSpec{
esapi.IndexManagementPolicyMappingSpec{
{
Name: "foo",
PolicyRef: "my-policy",
Aliases: []string{"somevalue"},
Expand Down
56 changes: 28 additions & 28 deletions pkg/k8shandler/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ func newElasticsearchContainer(imageName string, envVars []v1.EnvVar, resourceRe
ImagePullPolicy: "IfNotPresent",
Env: envVars,
Ports: []v1.ContainerPort{
v1.ContainerPort{
{
Name: "cluster",
ContainerPort: 9300,
Protocol: v1.ProtocolTCP,
},
v1.ContainerPort{
{
ContainerPort: 9200,
Protocol: v1.ProtocolTCP,
},
Expand All @@ -192,15 +192,15 @@ func newElasticsearchContainer(imageName string, envVars []v1.EnvVar, resourceRe
},
},
VolumeMounts: []v1.VolumeMount{
v1.VolumeMount{
{
Name: "elasticsearch-storage",
MountPath: "/elasticsearch/persistent",
},
v1.VolumeMount{
{
Name: "elasticsearch-config",
MountPath: elasticsearchConfigPath,
},
v1.VolumeMount{
{
Name: "certificates",
MountPath: elasticsearchCertsPath,
},
Expand All @@ -225,18 +225,18 @@ func newProxyContainer(imageName, clusterName string) (v1.Container, error) {
Image: imageName,
ImagePullPolicy: "IfNotPresent",
Ports: []v1.ContainerPort{
v1.ContainerPort{
{
Name: "restapi",
ContainerPort: 60000,
Protocol: v1.ProtocolTCP,
},
},
VolumeMounts: []v1.VolumeMount{
v1.VolumeMount{
{
Name: fmt.Sprintf("%s-%s", clusterName, "metrics"),
MountPath: "/etc/proxy/secrets",
},
v1.VolumeMount{
{
Name: "certificates",
MountPath: "/etc/proxy/elasticsearch",
},
Expand Down Expand Up @@ -277,67 +277,67 @@ func newProxyContainer(imageName, clusterName string) (v1.Container, error) {
func newEnvVars(nodeName, clusterName, instanceRam string, roleMap map[api.ElasticsearchNodeRole]bool) []v1.EnvVar {

return []v1.EnvVar{
v1.EnvVar{
{
Name: "DC_NAME",
Value: nodeName,
},
v1.EnvVar{
{
Name: "NAMESPACE",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
},
v1.EnvVar{
{
Name: "POD_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "status.podIP",
},
},
},
v1.EnvVar{
{
Name: "KUBERNETES_MASTER",
Value: "https://kubernetes.default.svc",
},
v1.EnvVar{
{
Name: "KUBERNETES_TRUST_CERT",
Value: "true",
},
v1.EnvVar{
{
Name: "SERVICE_DNS",
Value: fmt.Sprintf("%s-cluster", clusterName),
},
v1.EnvVar{
{
Name: "CLUSTER_NAME",
Value: clusterName,
},
v1.EnvVar{
{
Name: "INSTANCE_RAM",
Value: instanceRam,
},
v1.EnvVar{
{
Name: "HEAP_DUMP_LOCATION",
Value: heapDumpLocation,
},
v1.EnvVar{
{
Name: "RECOVER_AFTER_TIME",
Value: "5m",
},
v1.EnvVar{
{
Name: "READINESS_PROBE_TIMEOUT",
Value: "30",
},
v1.EnvVar{
{
Name: "POD_LABEL",
Value: fmt.Sprintf("cluster=%s", clusterName),
},
v1.EnvVar{
{
Name: "IS_MASTER",
Value: strconv.FormatBool(roleMap[api.ElasticsearchRoleMaster]),
},
v1.EnvVar{
{
Name: "HAS_DATA",
Value: strconv.FormatBool(roleMap[api.ElasticsearchRoleData]),
},
Expand Down Expand Up @@ -382,7 +382,7 @@ func newPodTemplateSpec(nodeName, clusterName, namespace string, node api.Elasti

tolerations := appendTolerations(node.Tolerations, commonSpec.Tolerations)
tolerations = appendTolerations(tolerations, []v1.Toleration{
v1.Toleration{
{
Key: "node.kubernetes.io/disk-pressure",
Operator: v1.TolerationOpExists,
Effect: v1.TaintEffectNoSchedule,
Expand Down Expand Up @@ -561,7 +561,7 @@ func newResourceRequirements(nodeResRequirements, commonResRequirements v1.Resou

func newVolumes(clusterName, nodeName, namespace string, node api.ElasticsearchNode, client client.Client) []v1.Volume {
return []v1.Volume{
v1.Volume{
{
Name: "elasticsearch-config",
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
Expand All @@ -571,19 +571,19 @@ func newVolumes(clusterName, nodeName, namespace string, node api.ElasticsearchN
},
},
},
v1.Volume{
{
Name: "elasticsearch-storage",
VolumeSource: newVolumeSource(clusterName, nodeName, namespace, node, client),
},
v1.Volume{
{
Name: "certificates",
VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{
SecretName: clusterName,
},
},
},
v1.Volume{
{
Name: fmt.Sprintf("%s-%s", clusterName, "metrics"),
VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{
Expand Down Expand Up @@ -637,7 +637,7 @@ func newVolumeSource(clusterName, nodeName, namespace string, node api.Elasticse

func sortDataHashKeys(dataHash map[string][32]byte) []string {
keys := []string{}
for key, _ := range dataHash {
for key := range dataHash {
keys = append(keys, key)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/k8shandler/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ func TestProxyContainerMetricsTLSDefined(t *testing.T) {
func TestPodSpecHasTaintTolerations(t *testing.T) {

expectedTolerations := []v1.Toleration{
v1.Toleration{
{
Key: "node.kubernetes.io/disk-pressure",
Operator: v1.TolerationOpExists,
Effect: v1.TaintEffectNoSchedule,
Expand Down Expand Up @@ -535,7 +535,7 @@ func TestPodNodeSelectors(t *testing.T) {
func TestPodDiskToleration(t *testing.T) {

expectedToleration := []v1.Toleration{
v1.Toleration{
{
Key: "node.kubernetes.io/disk-pressure",
Operator: v1.TolerationOpExists,
Effect: v1.TaintEffectNoSchedule,
Expand Down
10 changes: 5 additions & 5 deletions pkg/k8shandler/elasticsearch_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func updateAllIndexTemplateReplicas(clusterName, namespace string, client client
// get the index template and then update the replica and put it
indexTemplates, _ := GetIndexTemplates(clusterName, namespace, client)

for templateName, _ := range indexTemplates {
for templateName := range indexTemplates {

if template, ok := indexTemplates[templateName].(map[string]interface{}); ok {
if settings, ok := template["settings"].(map[string]interface{}); ok {
Expand Down Expand Up @@ -267,7 +267,7 @@ func curlESService(clusterName, namespace string, payload *esCurlStruct, client
if payload.RequestBody != "" {
// add to the request
request.Header = map[string][]string{
"Content-Type": []string{
"Content-Type": {
"application/json",
},
}
Expand All @@ -278,7 +278,7 @@ func curlESService(clusterName, namespace string, payload *esCurlStruct, client
if payload.RequestBody != "" {
// add to the request
request.Header = map[string][]string{
"Content-Type": []string{
"Content-Type": {
"application/json",
},
}
Expand Down Expand Up @@ -339,7 +339,7 @@ func curlESServiceOldClient(clusterName, namespace string, payload *esCurlStruct
if payload.RequestBody != "" {
// add to the request
request.Header = map[string][]string{
"Content-Type": []string{
"Content-Type": {
"application/json",
},
}
Expand All @@ -350,7 +350,7 @@ func curlESServiceOldClient(clusterName, namespace string, payload *esCurlStruct
if payload.RequestBody != "" {
// add to the request
request.Header = map[string][]string{
"Content-Type": []string{
"Content-Type": {
"application/json",
},
}
Expand Down

0 comments on commit a1db063

Please sign in to comment.