Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Atom feed config from atom-generator #8

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ godebug default=go1.23
require (
github.com/onsi/ginkgo/v2 v2.21.0
github.com/onsi/gomega v1.35.1
github.com/pdok/atom-generator v0.6.0
github.com/traefik/traefik/v2 v2.11.20
k8s.io/api v0.32.0
k8s.io/apimachinery v0.32.0
Expand All @@ -24,6 +25,7 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
Expand All @@ -50,6 +52,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -65,12 +68,15 @@ require (
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/traefik/paerser v0.2.1 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
Expand Down
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -74,6 +76,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down Expand Up @@ -103,6 +107,10 @@ github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pdok/atom-generator v0.0.0-20241003082215-84430ecd16d1 h1:FiEShEG+b/UKtBDwid3p1MIjamaHuc++RBYz1+3V1xc=
github.com/pdok/atom-generator v0.0.0-20241003082215-84430ecd16d1/go.mod h1:+tW5rgSjcPZeLkIBeKAkCKMeQNHVl/2moqf3uvv7LTI=
github.com/pdok/atom-generator v0.6.0 h1:7VbGn98Js2kJwhLRqbeX8D+byW5DfovTgJ09bMYg3Ew=
github.com/pdok/atom-generator v0.6.0/go.mod h1:+tW5rgSjcPZeLkIBeKAkCKMeQNHVl/2moqf3uvv7LTI=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -118,6 +126,7 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
Expand All @@ -141,8 +150,12 @@ github.com/traefik/paerser v0.2.1 h1:LFgeak1NmjEHF53c9ENdXdL1UMkF/lD5t+7Evsz4hH4
github.com/traefik/paerser v0.2.1/go.mod h1:7BBDd4FANoVgaTZG+yh26jI6CA2nds7D/4VTEdIsh24=
github.com/traefik/traefik/v2 v2.11.20 h1:22xF9h9/X6V4753ICTNHS6UnkwfHMy8+I9Swb4nEBt4=
github.com/traefik/traefik/v2 v2.11.20/go.mod h1:MnIv8lbvljiRR3NIrF4F/RfkUtHovQ8C9nHhKRFnA6U=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
Expand Down
231 changes: 121 additions & 110 deletions internal/controller/atom_generator/mapping.go
Original file line number Diff line number Diff line change
@@ -1,126 +1,137 @@
package atom_generator

import (
"time"

atom_feed "github.com/pdok/atom-generator/feeds"
pdoknlv3 "github.com/pdok/atom-operator/api/v3"
)

func MapAtomV3ToAtomGeneratorConfig(atom pdoknlv3.Atom) (atomGeneratorConfig AtomGeneratorConfig, err error) {
func MapAtomV3ToAtomGeneratorConfig(atom pdoknlv3.Atom) (atomGeneratorConfig atom_feed.Feeds, err error) {

updatedTime, _ := time.Parse(time.RFC3339, "2023-10-05T08:15:30Z")
lang := "nl"

atomGeneratorConfig = AtomGeneratorConfig{
Feeds: []Feed{
atomGeneratorConfig = atom_feed.Feeds{
Feeds: []atom_feed.Feed{
{
ID: atom.Spec.Service.BaseURL + "/index.xml",
InspireDLS: "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0",
Lang: "nl",
Stylesheet: "example.com/styles/atom.xsl",
Title: "Service Title",
Subtitle: "Service Subtitle",
Link: []Link{
{
Rel: "self",
Href: "example.com/atom/index.xml",
Title: "Service Title",
Type: "application/atom+xml",
},
{
Rel: "describedby",
Href: "example.com/getrecord?id=service1",
Type: "application/xml",
},
{
Rel: "search",
Href: "example.com/opensearch.xml",
Title: "Open Search document voor INSPIRE Download service PDOK",
Type: "application/opensearchdescription+xml",
},
{
Rel: "related",
Href: "example.com/metadata/service1",
Type: "text/html",
Title: "NGR pagina voor deze download service",
},
},
Rights: "All rights reserved",
Updated: &updatedTime,
Author: Author{
Name: "PDOK Beheer",
Email: "[email protected]",
},
Entry: []Entry{
{
ID: "example.com/atom/dataset1.xml",
Title: "Dataset 1 Title",
SpatialDatasetIdentifierCode: "dataset1-id",
SpatialDatasetIdentifierNamespace: "http://www.pdok.nl",
Link: []Link{
{
Rel: "describedby",
Href: "example.com/getrecord?id=dataset1",
Type: "application/xml",
},
{
Rel: "alternate",
Href: "example.com/atom/dataset1.xml",
Type: "application/atom+xml",
Title: "Dataset 1 Title",
},
},
Updated: &updatedTime,
Summary: "Dataset 1 Subtitle",
Polygon: "42.0 12.0 42.0 13.0 43.0 13.0 43.0 12.0 42.0 12.0",
Category: []Category{
{
Term: "urn:ogc:def:crs:EPSG::4326",
Label: "EPSG:4326",
},
},
},
// Adding another entry for completeness
{
ID: "example.com/atom/dataset2.xml",
Title: "Dataset 2 Title",
Link: []Link{
{
Rel: "self",
Href: "example.com/atom/dataset2.xml",
},
{
Rel: "up",
Href: "example.com/atom/index.xml",
Type: "application/atom+xml",
Title: "Top Atom Download Service Feed",
},
{
Rel: "describedby",
Href: "example.com/getrecord?id=service1",
Type: "text/html",
},
{
Rel: "related",
Href: "example.com/metadata/dataset2",
Type: "text/html",
Title: "NGR pagina voor deze dataset",
},
{
Rel: "describedby",
Href: "example.com/link1",
Title: "Link Type 1",
Type: "application/pdf",
Hreflang: "en",
},
// Add more links if needed
},
Rights: "All rights reserved",
Updated: &updatedTime,
},
},
InspireDls: "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0",
Lang: &lang,
// XMLStylesheet: "",
},
},
}

// atomGeneratorConfig = AtomGeneratorConfig{
// Feeds: []Feed{
// {
// ID: atom.Spec.Service.BaseURL + "/index.xml",
// InspireDLS: "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0",
// Lang: "nl",
// Stylesheet: "example.com/styles/atom.xsl",
// Title: "Service Title",
// Subtitle: "Service Subtitle",
// Link: []Link{
// {
// Rel: "self",
// Href: atom.Spec.Service.BaseURL + "/index.xml",
// Title: "Service Title",
// Type: "application/atom+xml",
// },
// {
// Rel: "describedby",
// Href: "example.com/getrecord?id=service1",
// Type: "application/xml",
// },
// {
// Rel: "search",
// Href: "example.com/opensearch.xml",
// Title: "Open Search document voor INSPIRE Download service PDOK",
// Type: "application/opensearchdescription+xml",
// },
// {
// Rel: "related",
// Href: "example.com/metadata/service1",
// Type: "text/html",
// Title: "NGR pagina voor deze download service",
// },
// },
// Rights: "All rights reserved",
// Updated: &updatedTime,
// Author: Author{
// Name: "PDOK Beheer",
// Email: "[email protected]",
// },
// Entry: []Entry{
// {
// ID: "example.com/atom/dataset1.xml",
// Title: "Dataset 1 Title",
// SpatialDatasetIdentifierCode: "dataset1-id",
// SpatialDatasetIdentifierNamespace: "http://www.pdok.nl",
// Link: []Link{
// {
// Rel: "describedby",
// Href: "example.com/getrecord?id=dataset1",
// Type: "application/xml",
// },
// {
// Rel: "alternate",
// Href: "example.com/atom/dataset1.xml",
// Type: "application/atom+xml",
// Title: "Dataset 1 Title",
// },
// },
// Updated: &updatedTime,
// Summary: "Dataset 1 Subtitle",
// Polygon: "42.0 12.0 42.0 13.0 43.0 13.0 43.0 12.0 42.0 12.0",
// Category: []Category{
// {
// Term: "urn:ogc:def:crs:EPSG::4326",
// Label: "EPSG:4326",
// },
// },
// },
// // Adding another entry for completeness
// {
// ID: "example.com/atom/dataset2.xml",
// Title: "Dataset 2 Title",
// Link: []Link{
// {
// Rel: "self",
// Href: "example.com/atom/dataset2.xml",
// },
// {
// Rel: "up",
// Href: "example.com/atom/index.xml",
// Type: "application/atom+xml",
// Title: "Top Atom Download Service Feed",
// },
// {
// Rel: "describedby",
// Href: "example.com/getrecord?id=service1",
// Type: "text/html",
// },
// {
// Rel: "related",
// Href: "example.com/metadata/dataset2",
// Type: "text/html",
// Title: "NGR pagina voor deze dataset",
// },
// {
// Rel: "describedby",
// Href: "example.com/link1",
// Title: "Link Type 1",
// Type: "application/pdf",
// Hreflang: "en",
// },
// // Add more links if needed
// },
// Rights: "All rights reserved",
// Updated: "20-04-2024 huplelepup",
// },
// },
// },
// },
// }

// return
return atomGeneratorConfig, err
}
Loading
Loading