Skip to content

Commit

Permalink
Upgrade go lang (#877)
Browse files Browse the repository at this point in the history
Move to the latest version. Bunch of small changes, but now it is
possible to iterate over custom types:
https://go.dev/blog/range-functions
  • Loading branch information
jakozaur authored Oct 12, 2024
1 parent db5624c commit 32d84ae
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-quesma-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Log in to Docker Hub
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Download images
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-notice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Install go-licence-detector
working-directory: ${{ matrix.module }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Download images
uses: actions/download-artifact@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: gofmt
working-directory: ${{ matrix.module }}
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:

- uses: dominikh/[email protected]
with:
version: "2023.1.6"
version: "2024.1.1"
install-go: false
working-directory: ${{ matrix.module }}

Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Build and export
uses: docker/build-push-action@v6
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Download images
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Login to GCR (only for build running on `main` branch)
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p align="center">
<a href="https://github.com/QuesmaOrg/quesma/actions/workflows/pipeline.yml"><img src="https://github.com/QuesmaOrg/quesma/actions/workflows/pipeline.yml/badge.svg"></a>
<a href="https://img.shields.io/github/v/release/QuesmaOrg/quesma"><img src="https://img.shields.io/github/v/release/QuesmaOrg/quesma"></a>
<a href=""><img src="https://img.shields.io/badge/golang-1.22.5-blue" /></a>
<a href=""><img src="https://img.shields.io/badge/golang-1.23.2-blue" /></a>
<a href=""><img src="https://img.shields.io/badge/License-Elastic_License_2.0-lightgrey" /></a>
<a href="https://goreportcard.com/report/github.com/QuesmaOrg/quesma"><img src="https://goreportcard.com/badge/github.com/QuesmaOrg/quesma" /></a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion ci/e2e-data-generator/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module quesma/e2e-data-generator

go 1.22.2
go 1.23.2
2 changes: 1 addition & 1 deletion quesma/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module quesma

go 1.22.5
go 1.23.2

require (
github.com/ClickHouse/clickhouse-go/v2 v2.29.0
Expand Down
2 changes: 1 addition & 1 deletion quesma/optimize/cache_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *cacheQueries) Transform(queries []*model.Query, properties map[string]s

visitor.OverrideVisitSelectCommand = func(v *model.BaseExprVisitor, query model.SelectCommand) interface{} {

if query.GroupBy != nil && len(query.GroupBy) > 0 {
if len(query.GroupBy) > 0 {
hasGroupBy = true
}

Expand Down
2 changes: 1 addition & 1 deletion quesma/queryparser/pancake_sql_query_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (p *pancakeSqlQueryGenerator) generateBucketSqlParts(query *pancakeModel, b
countAliasedColumn := model.NewAliasedExpr(countColumn, bucketAggregation.InternalNameForCount())
addSelectColumns = append(addSelectColumns, countAliasedColumn)

if bucketAggregation.orderBy != nil && len(bucketAggregation.orderBy) > 0 {
if len(bucketAggregation.orderBy) > 0 {
rankOrderBy := make([]model.OrderByExpr, 0)

for i, orderBy := range bucketAggregation.orderBy {
Expand Down
2 changes: 1 addition & 1 deletion quesma/queryparser/pancake_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (a *pancakeTransformer) createTopHitAndTopMetricsPancakes(pancake *pancakeM
}

func (a *pancakeTransformer) aggregationTreeToPancakes(topLevel pancakeAggregationTree) (pancakeResults []*pancakeModel, err error) {
if topLevel.children == nil || len(topLevel.children) == 0 {
if len(topLevel.children) == 0 {
return nil, fmt.Errorf("no top level aggregations found")
}

Expand Down
4 changes: 2 additions & 2 deletions quesma/quesma/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (c *QuesmaConfiguration) optimizersConfigAsString(s string, cfg map[string]
status = "enabled"
}
lines = append(lines, fmt.Sprintf(" %s: %s", k, status))
if v.Properties != nil && len(v.Properties) > 0 {
if len(v.Properties) > 0 {
lines = append(lines, fmt.Sprintf(" properties: %v", v.Properties))
}
}
Expand All @@ -239,7 +239,7 @@ func (c *QuesmaConfiguration) OptimizersConfigAsString() string {
lines = append(lines, "\n")

for indexName, indexConfig := range c.IndexConfig {
if indexConfig.Optimizers != nil && len(indexConfig.Optimizers) > 0 {
if len(indexConfig.Optimizers) > 0 {
lines = append(lines, c.optimizersConfigAsString(indexName, indexConfig.Optimizers))
}
}
Expand Down
36 changes: 18 additions & 18 deletions quesma/quesma/config/config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
}
proc := c.getProcessorByName(c.Pipelines[0].Processors[0])
if proc == nil {
return fmt.Errorf(fmt.Sprintf("processor named [%s] not found in configuration", c.Pipelines[0].Processors[0]))
return fmt.Errorf("processor named [%s] not found in configuration", c.Pipelines[0].Processors[0])
}
declaredBackendConnectors := c.Pipelines[0].BackendConnectors
if proc.Type == QuesmaV1ProcessorNoOp {
Expand All @@ -214,7 +214,7 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
for _, con := range declaredBackendConnectors {
connector := c.getBackendConnectorByName(con)
if connector == nil {
return fmt.Errorf(fmt.Sprintf("backend connector named [%s] not found in configuration", con))
return fmt.Errorf("backend connector named [%s] not found in configuration", con)
}
backendConnectorTypes = append(backendConnectorTypes, connector.Type)
}
Expand All @@ -234,16 +234,16 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
}

} else {
return fmt.Errorf(fmt.Sprintf("frontend connector named [%s] referred in pipeline [%s] not found in configuration", fcName, c.Pipelines[0].Name))
return fmt.Errorf("frontend connector named [%s] referred in pipeline [%s] not found in configuration", fcName, c.Pipelines[0].Name)
}
}
if isDualPipeline {
fc1, fc2 := c.getFrontendConnectorByName(c.Pipelines[0].FrontendConnectors[0]), c.getFrontendConnectorByName(c.Pipelines[1].FrontendConnectors[0])
if fc1 == nil {
return fmt.Errorf(fmt.Sprintf("frontend connector named [%s] not found in configuration", c.Pipelines[0].FrontendConnectors[0]))
return fmt.Errorf("frontend connector named [%s] not found in configuration", c.Pipelines[0].FrontendConnectors[0])
}
if fc2 == nil {
return fmt.Errorf(fmt.Sprintf("frontend connector named [%s] not found in configuration", c.Pipelines[1].FrontendConnectors[0]))
return fmt.Errorf("frontend connector named [%s] not found in configuration", c.Pipelines[1].FrontendConnectors[0])
}
if !((fc1.Type == ElasticsearchFrontendQueryConnectorName && fc2.Type == ElasticsearchFrontendIngestConnectorName) ||
(fc2.Type == ElasticsearchFrontendQueryConnectorName && fc1.Type == ElasticsearchFrontendIngestConnectorName)) {
Expand All @@ -257,7 +257,7 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
}
ingestProcessor := c.getProcessorByName(ingestPipeline.Processors[0])
if ingestProcessor == nil {
return fmt.Errorf(fmt.Sprintf("ingest processor named [%s] not found in configuration", ingestPipeline.Processors[0]))
return fmt.Errorf("ingest processor named [%s] not found in configuration", ingestPipeline.Processors[0])
}
if ingestProcessor.Type != QuesmaV1ProcessorIngest && ingestProcessor.Type != QuesmaV1ProcessorNoOp {
return fmt.Errorf("ingest pipeline must have ingest-type or noop processor")
Expand All @@ -269,7 +269,7 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
}
queryProcessor := c.getProcessorByName(queryPipeline.Processors[0])
if queryProcessor == nil {
return fmt.Errorf(fmt.Sprintf("query processor named [%s] not found in configuration", ingestPipeline.Processors[0]))
return fmt.Errorf("query processor named [%s] not found in configuration", ingestPipeline.Processors[0])
}
if (queryProcessor.Type == QuesmaV1ProcessorNoOp && ingestProcessor.Type != QuesmaV1ProcessorNoOp) ||
(ingestProcessor.Type == QuesmaV1ProcessorNoOp && queryProcessor.Type != QuesmaV1ProcessorNoOp) {
Expand Down Expand Up @@ -318,7 +318,7 @@ func (c *QuesmaNewConfiguration) validateFrontendConnector(fc FrontendConnector)
return fmt.Errorf("frontend connector must have a non-empty name")
}
if fc.Type != ElasticsearchFrontendIngestConnectorName && fc.Type != ElasticsearchFrontendQueryConnectorName {
return fmt.Errorf(fmt.Sprintf("frontend connector's [%s] type not recognized, only `%s` and `%s` are supported at this moment", fc.Name, ElasticsearchFrontendIngestConnectorName, ElasticsearchFrontendQueryConnectorName))
return fmt.Errorf("frontend connector's [%s] type not recognized, only `%s` and `%s` are supported at this moment", fc.Name, ElasticsearchFrontendIngestConnectorName, ElasticsearchFrontendQueryConnectorName)
}
return nil
}
Expand Down Expand Up @@ -390,49 +390,49 @@ func (c *QuesmaNewConfiguration) validatePipeline(pipeline Pipeline) error {
return multierror.Append(errAcc, fmt.Errorf("pipeline must have exactly one frontend connector, none defined"))
}
if !slices.Contains(c.definedFrontedConnectorNames(), pipeline.FrontendConnectors[0]) {
errAcc = multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("frontend connector named %s referenced in %s not found in configuration", pipeline.FrontendConnectors[0], pipeline.Name)))
errAcc = multierror.Append(errAcc, fmt.Errorf("frontend connector named %s referenced in %s not found in configuration", pipeline.FrontendConnectors[0], pipeline.Name))
}

if len(pipeline.BackendConnectors) == 0 || len(pipeline.BackendConnectors) > 2 {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("pipeline must define exactly one or two backend connectors, %d defined", len(pipeline.BackendConnectors))))
return multierror.Append(errAcc, fmt.Errorf("pipeline must define exactly one or two backend connectors, %d defined", len(pipeline.BackendConnectors)))
}
if !slices.Contains(c.definedBackendConnectorNames(), pipeline.BackendConnectors[0]) {
errAcc = multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("backend connector named %s referenced in %s not found in configuration", pipeline.BackendConnectors[0], pipeline.Name)))
errAcc = multierror.Append(errAcc, fmt.Errorf("backend connector named %s referenced in %s not found in configuration", pipeline.BackendConnectors[0], pipeline.Name))
}
if len(pipeline.BackendConnectors) == 2 {
if !slices.Contains(c.definedBackendConnectorNames(), pipeline.BackendConnectors[1]) {
errAcc = multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("backend connector named %s referenced in %s not found in configuration", pipeline.BackendConnectors[1], pipeline.Name)))
errAcc = multierror.Append(errAcc, fmt.Errorf("backend connector named %s referenced in %s not found in configuration", pipeline.BackendConnectors[1], pipeline.Name))
}
}

if len(pipeline.Processors) != 1 {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("pipeline must have exactly one processor, [%s] has %d defined", pipeline.Name, len(pipeline.Processors))))
return multierror.Append(errAcc, fmt.Errorf("pipeline must have exactly one processor, [%s] has %d defined", pipeline.Name, len(pipeline.Processors)))
}
if !slices.Contains(c.definedProcessorNames(), pipeline.Processors[0]) {
errAcc = multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("processor named %s referenced in %s not found in configuration", pipeline.Processors[0], pipeline.Name)))
errAcc = multierror.Append(errAcc, fmt.Errorf("processor named %s referenced in %s not found in configuration", pipeline.Processors[0], pipeline.Name))
} else {
onlyProcessorInPipeline := c.getProcessorByName(pipeline.Processors[0])
if onlyProcessorInPipeline.Type == QuesmaV1ProcessorNoOp {
if len(pipeline.BackendConnectors) != 1 {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("pipeline %s has a noop processor supports only one backend connector", pipeline.Name)))
return multierror.Append(errAcc, fmt.Errorf("pipeline %s has a noop processor supports only one backend connector", pipeline.Name))
}
if conn := c.getBackendConnectorByName(pipeline.BackendConnectors[0]); conn.Type != ElasticsearchBackendConnectorName {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("pipeline %s has a noop processor which can be connected only to elasticsearch backend connector", pipeline.Name)))
return multierror.Append(errAcc, fmt.Errorf("pipeline %s has a noop processor which can be connected only to elasticsearch backend connector", pipeline.Name))
}
}
if onlyProcessorInPipeline.Type == QuesmaV1ProcessorQuery || onlyProcessorInPipeline.Type == QuesmaV1ProcessorIngest {
foundElasticBackendConnector := false
for _, backendConnectorName := range pipeline.BackendConnectors {
backendConnector := c.getBackendConnectorByName(backendConnectorName)
if backendConnector == nil {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("backend connector named %s referenced in %s not found in configuration", backendConnectorName, pipeline.Name)))
return multierror.Append(errAcc, fmt.Errorf("backend connector named %s referenced in %s not found in configuration", backendConnectorName, pipeline.Name))
}
if backendConnector.Type == ElasticsearchBackendConnectorName {
foundElasticBackendConnector = true
}
}
if !foundElasticBackendConnector {
return multierror.Append(errAcc, fmt.Errorf(fmt.Sprintf("pipeline %s has a processor of type %s which requires having one elasticsearch backend connector", pipeline.Name, onlyProcessorInPipeline.Type)))
return multierror.Append(errAcc, fmt.Errorf("pipeline %s has a processor of type %s which requires having one elasticsearch backend connector", pipeline.Name, onlyProcessorInPipeline.Type))
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion quesma/quesma/functionality/terms_enum/terms_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package terms_enum
import (
"context"
"encoding/json"
"errors"
"fmt"
"quesma/clickhouse"
"quesma/end_user_errors"
Expand All @@ -24,7 +25,7 @@ func HandleTermsEnum(ctx context.Context, index string, body types.JSON, lm *cli
if indices, err := lm.ResolveIndexPattern(ctx, index); err != nil || len(indices) != 1 { // multi index terms enum is not yet supported
errorMsg := fmt.Sprintf("terms enum failed - could not resolve table name for index: %s", index)
logger.Error().Msg(errorMsg)
return nil, fmt.Errorf(errorMsg)
return nil, errors.New(errorMsg)
} else {
resolvedTableName := indices[0]
resolvedSchema, ok := schemaRegistry.FindSchema(schema.TableName(resolvedTableName))
Expand Down
2 changes: 1 addition & 1 deletion smoke-test/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module mitmproxy/quesma

go 1.22.5
go 1.23.2

require (
github.com/mailru/go-clickhouse/v2 v2.3.0
Expand Down

0 comments on commit 32d84ae

Please sign in to comment.