Skip to content

Commit

Permalink
Merge pull request #24 from PDOK/version-attribute
Browse files Browse the repository at this point in the history
Version attribute
  • Loading branch information
Shalucik authored Oct 3, 2024
2 parents 5f552c9 + ccee147 commit 84430ec
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.vscode
/output
/output
/.idea/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine3.16 AS build-env
FROM golang:1.23-alpine3.20 AS build-env

RUN apk update && apk upgrade && \
apk add --no-cache bash git pkgconfig gcc g++ libc-dev ca-certificates
Expand Down
3 changes: 1 addition & 2 deletions atom.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -38,7 +37,7 @@ func main() {
app.Action = func(c *cli.Context) error {

// Read and unmarshal config file
doc, err := ioutil.ReadFile(c.String(FILE))
doc, err := os.ReadFile(c.String(FILE))
if err != nil {
log.Fatalf("error: %v, with file: %v", err, `no file`)
}
Expand Down
5 changes: 3 additions & 2 deletions feeds/feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (f *Feed) GenerateATOM() []byte {
// WriteATOM function writes the ATOM feed to file
func (f *Feed) WriteATOM(filename string) {
b := f.GenerateATOM()
err := ioutil.WriteFile(filename, b, 0777)
err := os.WriteFile(filename, b, 0777)
if err != nil {
log.Fatalf("Could not write to file %s : %v ", filename, err)
}
Expand Down Expand Up @@ -249,6 +249,7 @@ type Link struct {
Hreflang *string `xml:"hreflang,attr,omitempty" yaml:"hreflang"`
Length string `xml:"length,attr,omitempty" yaml:"length"`
Title string `xml:"title,attr,omitempty" yaml:"title"`
Version *string `xml:"version,attr,omitempty" yaml:"version"`
Time *string `xml:"time,attr,omitempty" yaml:"time"`
Bbox *string `xml:"bbox,attr,omitempty" yaml:"bbox"`
}
Expand Down
43 changes: 43 additions & 0 deletions feeds/feeds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,38 @@ func TestGenerateATOM(t *testing.T) {
},
},
},
{
ID: "https://foo.bar/version.xml",
Rights: "foo",
Updated: &recentupdated,
Polygon: "50.6 3.1 50.6 7.3 53.7 7.3 53.7 3.1 50.6 3.1",
Title: "test met version attribute",
Content: "links zijn gesplists op version",
Link: []Link{
{
Href: "https://foo.bar/version.zip",
Rel: "section",
Type: "application/zip",
Length: "0",
},
{
Href: "https://foo.bar/v1/version.zip",
Rel: "section",
Type: "application/zip",
Length: "1",
Version: sp("v1"),
},
{
Href: "https://foo.bar/v2/version.zip",
Rel: "section",
Type: "application/zip",
Length: "2",
Version: sp("v2"),
Bbox: sp("2 -2 2 -2"),
Time: sp("2002-02-02T02:02:02Z"),
},
},
},
},
},
}},
Expand Down Expand Up @@ -283,6 +315,17 @@ func TestGenerateATOM(t *testing.T) {
<updated>2021-10-01T00:00:00Z</updated>
<georss:polygon>50.6 3.1 50.6 7.3 53.7 7.3 53.7 3.1 50.6 3.1</georss:polygon>
</entry>
<entry>
<id>https://foo.bar/version.xml</id>
<title>test met version attribute</title>
<content>links zijn gesplists op version</content>
<link href="https://foo.bar/version.zip" rel="section" type="application/zip" hreflang="nl" length="0"></link>
<link href="https://foo.bar/v1/version.zip" rel="section" type="application/zip" hreflang="nl" length="1" version="v1"></link>
<link href="https://foo.bar/v2/version.zip" rel="section" type="application/zip" hreflang="nl" length="2" version="v2" time="2002-02-02T02:02:02Z" bbox="2 -2 2 -2"></link>
<rights>foo</rights>
<updated>2021-10-01T00:00:00Z</updated>
<georss:polygon>50.6 3.1 50.6 7.3 53.7 7.3 53.7 3.1 50.6 3.1</georss:polygon>
</entry>
</feed>`},
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pdok/atom-generator

go 1.18
go 1.23

require (
github.com/imdario/mergo v0.3.13
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
Expand All @@ -8,8 +10,12 @@ github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4=
github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 84430ec

Please sign in to comment.