Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit a2e74e0

Browse files
authored
Merge pull request #62 from PDOK/fix-partioning
remove hard-coded index name from partition + add 'optimize' flag + bump deps
2 parents fc7afaf + dd62e14 commit a2e74e0

33 files changed

+659
-573
lines changed

.github/workflows/lint-go.yml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/setup-go@v4
1616
with:
17-
go-version: '1.23'
17+
go-version: '1.25'
1818
cache: false
1919

2020
- uses: actions/checkout@v3
@@ -30,26 +30,6 @@ jobs:
3030
govulncheck ./...
3131
3232
- name: Golangci-lint
33-
uses: golangci/golangci-lint-action@v3
33+
uses: golangci/golangci-lint-action@v8
3434
with:
35-
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
36-
version: latest
37-
38-
# Optional: working directory, useful for monorepos
39-
# working-directory: somedir
40-
41-
# Optional: golangci-lint command line arguments.
42-
# args: --issues-exit-code=0
43-
44-
# Optional: show only new issues if it's a pull request. The default value is `false`.
45-
# only-new-issues: true
46-
47-
# Optional: if set to true then the all caching functionality will be complete disabled,
48-
# takes precedence over all other caching options.
49-
# skip-cache: true
50-
51-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
52-
# skip-pkg-cache: true
53-
54-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
55-
# skip-build-cache: true
35+
version: v2.5.0

.github/workflows/test-go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v4
2121
with:
22-
go-version: '1.23'
22+
go-version: '1.25'
2323

2424
- name: Download
2525
run: go mod download all

.golangci.yaml

Lines changed: 194 additions & 93 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
####### Go build
2-
FROM docker.io/golang:1.23-bookworm AS build-env
2+
FROM docker.io/golang:1.25-bookworm AS build-env
33
WORKDIR /go/src/service
44
ADD . /go/src/service
55

cmd/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
featureTableFidFlag = "fid"
4545
featureTableGeomFlag = "geom"
4646
pageSizeFlag = "page-size"
47+
skipOptimizeFlag = "skip-optimize"
4748
rewritesFileFlag = "rewrites-file"
4849
synonymsFileFlag = "synonyms-file"
4950
languageFlag = "lang"
@@ -162,7 +163,7 @@ var (
162163
}
163164
)
164165

165-
//nolint:funlen
166+
//nolint:funlen,maintidx
166167
func main() {
167168
app := cli.NewApp()
168169
app.Name = appName
@@ -385,6 +386,13 @@ func main() {
385386
Required: false,
386387
Value: 10000,
387388
},
389+
&cli.BoolFlag{
390+
Name: skipOptimizeFlag,
391+
EnvVars: []string{strcase.ToScreamingSnake(skipOptimizeFlag)},
392+
Usage: "Skip running VACUUM ANALYZE on the search index after import",
393+
Required: false,
394+
Value: false,
395+
},
388396
},
389397
Action: func(c *cli.Context) error {
390398
dbConn := flagsToDBConnStr(c)
@@ -403,7 +411,7 @@ func main() {
403411
return fmt.Errorf("no configured collection found with id: %s", collectionID)
404412
}
405413
return etl.ImportFile(*collection, c.String(searchIndexFlag), c.Path(fileFlag), featureTable,
406-
c.Int(pageSizeFlag), dbConn)
414+
c.Int(pageSizeFlag), c.Bool(skipOptimizeFlag), dbConn)
407415
},
408416
},
409417
}

cmd/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func Test_newRouter(t *testing.T) {
8989
log.Print(recorder.Body.String()) // to ease debugging
9090
switch {
9191
case strings.HasSuffix(tt.apiCall, "json"):
92-
assert.JSONEq(t, recorder.Body.String(), string(expectedBody))
92+
assert.JSONEq(t, string(expectedBody), recorder.Body.String())
9393
case strings.HasSuffix(tt.apiCall, "html") || strings.HasSuffix(tt.apiCall, "xml"):
9494
assert.Contains(t, normalize(recorder.Body.String()), normalize(string(expectedBody)))
9595
default:

config/config.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,6 @@ const (
1616
CookieMaxAge = 60 * 60 * 24
1717
)
1818

19-
// NewConfig read YAML config file, required to start Gomagpie
20-
func NewConfig(configFile string) (*Config, error) {
21-
yamlData, err := os.ReadFile(configFile)
22-
if err != nil {
23-
return nil, fmt.Errorf("failed to read config file %w", err)
24-
}
25-
26-
// expand environment variables
27-
yamlData = []byte(os.ExpandEnv(string(yamlData)))
28-
29-
var config *Config
30-
err = yaml.Unmarshal(yamlData, &config)
31-
if err != nil {
32-
return nil, fmt.Errorf("failed to unmarshal config file, error: %w", err)
33-
}
34-
err = validateLocalPaths(config)
35-
if err != nil {
36-
return nil, fmt.Errorf("validation error in config file, error: %w", err)
37-
}
38-
return config, nil
39-
}
40-
41-
// UnmarshalYAML hooks into unmarshalling to set defaults and validate config
42-
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
43-
type cfg Config
44-
if err := unmarshal((*cfg)(c)); err != nil {
45-
return err
46-
}
47-
48-
// init config
49-
if err := setDefaults(c); err != nil {
50-
return err
51-
}
52-
if err := validate(c); err != nil {
53-
return err
54-
}
55-
return nil
56-
}
57-
5819
type Config struct {
5920
// Version of the API. When releasing a new version which contains backwards-incompatible changes, a new major version must be released.
6021
Version string `yaml:"version" json:"version" validate:"required,semver" default:"1.0.0"`
@@ -102,6 +63,45 @@ type Config struct {
10263
Collections GeoSpatialCollections `yaml:"collections,omitempty" json:"collections,omitempty" validate:"required,dive"`
10364
}
10465

66+
// NewConfig read YAML config file, required to start Gomagpie
67+
func NewConfig(configFile string) (*Config, error) {
68+
yamlData, err := os.ReadFile(configFile)
69+
if err != nil {
70+
return nil, fmt.Errorf("failed to read config file %w", err)
71+
}
72+
73+
// expand environment variables
74+
yamlData = []byte(os.ExpandEnv(string(yamlData)))
75+
76+
var config *Config
77+
err = yaml.Unmarshal(yamlData, &config)
78+
if err != nil {
79+
return nil, fmt.Errorf("failed to unmarshal config file, error: %w", err)
80+
}
81+
err = validateLocalPaths(config)
82+
if err != nil {
83+
return nil, fmt.Errorf("validation error in config file, error: %w", err)
84+
}
85+
return config, nil
86+
}
87+
88+
// UnmarshalYAML hooks into unmarshalling to set defaults and validate config
89+
func (c *Config) UnmarshalYAML(unmarshal func(any) error) error {
90+
type cfg Config
91+
if err := unmarshal((*cfg)(c)); err != nil {
92+
return err
93+
}
94+
95+
// init config
96+
if err := setDefaults(c); err != nil {
97+
return err
98+
}
99+
if err := validate(c); err != nil {
100+
return err
101+
}
102+
return nil
103+
}
104+
105105
type License struct {
106106
// Name of the license, e.g. MIT, CC0, etc
107107
Name string `yaml:"name" json:"name" validate:"required" default:"CC0"`

config/config_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
func init() {
@@ -51,7 +52,7 @@ func TestNewConfig(t *testing.T) {
5152
t.Run(tt.name, func(t *testing.T) {
5253
_, err := NewConfig(tt.args.configFile)
5354
if tt.wantErr {
54-
assert.Error(t, err)
55+
require.Error(t, err)
5556
assert.ErrorContains(t, err, tt.wantErrMsg)
5657
} else {
5758
assert.NoError(t, err)
@@ -88,7 +89,7 @@ func TestGeoSpatialCollections_Ordering(t *testing.T) {
8889
for _, tt := range tests {
8990
t.Run(tt.name, func(t *testing.T) {
9091
config, err := NewConfig(tt.args.configFile)
91-
assert.NoError(t, err)
92+
require.NoError(t, err)
9293
var actual []string
9394
if tt.args.expectedTitles {
9495
actual = Map(config.AllCollections(), func(item GeoSpatialCollection) string { return *item.Metadata.Title })
@@ -148,7 +149,7 @@ func TestGeoSpatialCollections_ContainsID(t *testing.T) {
148149
}
149150

150151
type TestEmbeddedGeoSpatialCollection struct {
151-
C GeoSpatialCollection `json:"C"`
152+
C GeoSpatialCollection `json:"C"` //nolint:tagliatelle
152153
}
153154

154155
func TestGeoSpatialCollection_Unmarshalling_JSON(t *testing.T) {
@@ -184,7 +185,7 @@ func TestGeoSpatialCollection_Unmarshalling_JSON(t *testing.T) {
184185
if !tt.wantErr(t, err, errors.New("json.Unmarshal")) {
185186
return
186187
}
187-
assert.EqualValuesf(t, &TestEmbeddedGeoSpatialCollection{C: *tt.want}, unmarshalledEmbedded, "json.Unmarshal")
188+
assert.Equalf(t, &TestEmbeddedGeoSpatialCollection{C: *tt.want}, unmarshalledEmbedded, "json.Unmarshal")
188189
})
189190
}
190191
}

config/language.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Language struct {
1515
// MarshalJSON turn language tag into JSON
1616
// Value instead of pointer receiver because only that way it can be used for both.
1717
func (l Language) MarshalJSON() ([]byte, error) {
18-
return json.Marshal(l.Tag.String())
18+
return json.Marshal(l.String())
1919
}
2020

2121
// UnmarshalJSON turn JSON into Language

config/language_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
type TestEmbeddedLanguage struct {
14-
L Language `json:"L" yaml:"L"`
14+
L Language `json:"L" yaml:"L"` //nolint:tagliatelle
1515
}
1616

1717
func TestLanguage_DeepCopy(t *testing.T) {
@@ -82,7 +82,7 @@ func TestLanguage_Marshalling_JSON(t *testing.T) {
8282
if !tt.wantErr(t, err, errors.New("yaml.Unmarshal")) {
8383
return
8484
}
85-
assert.EqualValuesf(t, &TestEmbeddedLanguage{L: *tt.lang}, unmarshalledEmbedded, "yaml.Unmarshal")
85+
assert.Equalf(t, &TestEmbeddedLanguage{L: *tt.lang}, unmarshalledEmbedded, "yaml.Unmarshal")
8686
})
8787
}
8888
}

0 commit comments

Comments
 (0)