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

add navigation cache #41

Merged
merged 1 commit into from
Feb 8, 2023
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
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,27 @@ test-component:
convey:
goconvey ./...

.PHONY: fetch-renderer-lib
fetch-renderer-lib:
ifeq ($(LOCAL_DP_RENDERER_IN_USE), 1)
$(eval CORE_ASSETS_PATH = $(shell grep -w "\"github.com/ONSdigital/dp-renderer\" =>" go.mod | awk -F '=> ' '{print $$2}' | tr -d '"'))
else
$(eval APP_RENDERER_VERSION=$(shell grep "github.com/ONSdigital/dp-renderer" go.mod | cut -d ' ' -f2 ))
$(eval CORE_ASSETS_PATH = $(shell go get github.com/ONSdigital/dp-renderer@$(APP_RENDERER_VERSION) && go list -f '{{.Dir}}' -m github.com/ONSdigital/dp-renderer))
endif

.PHONY: generate-debug
generate-debug: fetch-renderer-lib
cd assets; go run github.com/kevinburke/go-bindata/go-bindata -prefix $(CORE_ASSETS_PATH)/assets -debug -o data.go -pkg assets locales/... templates/... $(CORE_ASSETS_PATH)/assets/locales/... $(CORE_ASSETS_PATH)/assets/templates/...
go get -u github.com/go-bindata/go-bindata/...
go install github.com/go-bindata/go-bindata/...
cd assets; go run github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs -prefix $(CORE_ASSETS_PATH)/assets -o data.go -pkg assets locales/... templates/... $(CORE_ASSETS_PATH)/assets/locales/... $(CORE_ASSETS_PATH)/assets/templates/...
{ echo "// +build debug\n"; cat assets/data.go; } > assets/debug.go.new
mv assets/debug.go.new assets/data.go

.PHONY: generate-prod
generate-prod: fetch-renderer-lib
cd assets; go run github.com/kevinburke/go-bindata/go-bindata -prefix $(CORE_ASSETS_PATH)/assets -o data.go -pkg assets locales/... templates/... $(CORE_ASSETS_PATH)/assets/locales/... $(CORE_ASSETS_PATH)/assets/templates/...
generate-prod: fetch-renderer-lib
go get -u github.com/go-bindata/go-bindata/...
go install github.com/go-bindata/go-bindata/...
cd assets; go run github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs -prefix $(CORE_ASSETS_PATH)/assets -o data.go -pkg assets locales/... templates/... $(CORE_ASSETS_PATH)/assets/locales/... $(CORE_ASSETS_PATH)/assets/templates/...
{ echo "// +build production\n"; cat assets/data.go; } > assets/data.go.new
mv assets/data.go.new assets/data.go

.PHONY: fetch-dp-renderer
fetch-renderer-lib:
ifeq ($(LOCAL_DP_RENDERER_IN_USE), 1)
$(eval CORE_ASSETS_PATH = $(shell grep -w "\"github.com/ONSdigital/dp-renderer\" =>" go.mod | awk -F '=> ' '{print $$2}' | tr -d '"'))
else
$(eval APP_RENDERER_VERSION=$(shell grep "github.com/ONSdigital/dp-renderer" go.mod | cut -d ' ' -f2 ))
$(eval CORE_ASSETS_PATH = $(shell go get github.com/ONSdigital/dp-renderer@$(APP_RENDERER_VERSION) && go list -f '{{.Dir}}' -m github.com/ONSdigital/dp-renderer))
endif
68 changes: 41 additions & 27 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ import (

// Config represents service configuration for dp-frontend-feedback-controller
type Config struct {
BindAddr string `envconfig:"BIND_ADDR"`
GracefulShutdownTimeout time.Duration `envconfig:"GRACEFUL_SHUTDOWN_TIMEOUT"`
HealthCheckInterval time.Duration `envconfig:"HEALTHCHECK_INTERVAL"`
HealthCheckCriticalTimeout time.Duration `envconfig:"HEALTHCHECK_CRITICAL_TIMEOUT"`
MailHost string `envconfig:"MAIL_HOST"`
MailUser string `envconfig:"MAIL_USER"`
MailPassword string `envconfig:"MAIL_PASSWORD" json:"-"`
MailPort string `envconfig:"MAIL_PORT"`
FeedbackTo string `envconfig:"FEEDBACK_TO"`
FeedbackFrom string `envconfig:"FEEDBACK_FROM"`
PatternLibraryAssetsPath string `envconfig:"PATTERN_LIBRARY_ASSETS_PATH"`
SiteDomain string `envconfig:"SITE_DOMAIN"`
Debug bool `envconfig:"DEBUG"`
SupportedLanguages []string `envconfig:"SUPPORTED_LANGUAGES"`
APIRouterURL string `envconfig:"API_ROUTER_URL"`
BindAddr string `envconfig:"BIND_ADDR"`
CacheUpdateInterval *time.Duration `envconfig:"CACHE_UPDATE_INTERVAL"`
CensusTopicID string `envconfig:"CENSUS_TOPIC_ID"`
Debug bool `envconfig:"DEBUG"`
EnableCensusTopicSubsection bool `envconfig:"ENABLE_CENSUS_TOPIC_SUBSECTION"`
EnableNewNavBar bool `envconfig:"ENABLE_NEW_NAVBAR"`
GracefulShutdownTimeout time.Duration `envconfig:"GRACEFUL_SHUTDOWN_TIMEOUT"`
HealthCheckInterval time.Duration `envconfig:"HEALTHCHECK_INTERVAL"`
HealthCheckCriticalTimeout time.Duration `envconfig:"HEALTHCHECK_CRITICAL_TIMEOUT"`
MailHost string `envconfig:"MAIL_HOST"`
MailUser string `envconfig:"MAIL_USER"`
MailPassword string `envconfig:"MAIL_PASSWORD" json:"-"`
MailPort string `envconfig:"MAIL_PORT"`
FeedbackTo string `envconfig:"FEEDBACK_TO"`
FeedbackFrom string `envconfig:"FEEDBACK_FROM"`
IsPublishingMode bool `envconfig:"IS_PUBLISHING_MODE"`
Languages string `envconfig:"LANGUAGES"`
PatternLibraryAssetsPath string `envconfig:"PATTERN_LIBRARY_ASSETS_PATH"`
ServiceAuthToken string `envconfig:"SERVICE_AUTH_TOKEN" json:"-"`
SiteDomain string `envconfig:"SITE_DOMAIN"`
SupportedLanguages []string `envconfig:"SUPPORTED_LANGUAGES"`
}

var cfg *Config
Expand All @@ -48,19 +56,25 @@ func get() (*Config, error) {
}

cfg := &Config{
BindAddr: "localhost:25200",
GracefulShutdownTimeout: 5 * time.Second,
HealthCheckInterval: 30 * time.Second,
HealthCheckCriticalTimeout: 90 * time.Second,
MailHost: "localhost",
MailPort: "1025",
MailUser: "",
MailPassword: "",
FeedbackTo: "[email protected]",
FeedbackFrom: "[email protected]",
SiteDomain: "localhost",
Debug: false,
SupportedLanguages: []string{"en", "cy"},
APIRouterURL: "http://localhost:23200/v1",
BindAddr: "localhost:25200",
CensusTopicID: "4445",
Debug: false,
EnableCensusTopicSubsection: false,
EnableNewNavBar: false,
GracefulShutdownTimeout: 5 * time.Second,
HealthCheckInterval: 30 * time.Second,
HealthCheckCriticalTimeout: 90 * time.Second,
MailHost: "localhost",
MailPort: "1025",
MailUser: "",
MailPassword: "",
FeedbackTo: "[email protected]",
FeedbackFrom: "[email protected]",
IsPublishingMode: false,
ServiceAuthToken: "",
SiteDomain: "localhost",
SupportedLanguages: []string{"en", "cy"},
}

return cfg, envconfig.Process("", cfg)
Expand Down
3 changes: 3 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestConfig(t *testing.T) {
So(err, ShouldBeNil)
})
Convey("Then the values should be set to the expected defaults", func() {
So(cfg.EnableNewNavBar, ShouldEqual, false)
So(cfg.GracefulShutdownTimeout, ShouldEqual, 5*time.Second)
So(cfg.HealthCheckInterval, ShouldEqual, 30*time.Second)
So(cfg.HealthCheckCriticalTimeout, ShouldEqual, 90*time.Second)
Expand All @@ -27,6 +28,8 @@ func TestConfig(t *testing.T) {
So(cfg.SiteDomain, ShouldEqual, "localhost")
So(cfg.Debug, ShouldEqual, false)
So(cfg.SupportedLanguages, ShouldResemble, []string{"en", "cy"})
So(cfg.IsPublishingMode, ShouldEqual, false)
So(cfg.EnableCensusTopicSubsection, ShouldEqual, false)
})

Convey("Then a second call to config should return the same config", func() {
Expand Down
23 changes: 12 additions & 11 deletions email/emailtest/sender.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module github.com/ONSdigital/dp-frontend-feedback-controller
go 1.19

require (
github.com/ONSdigital/dp-frontend-cache-helper v0.2.0
github.com/ONSdigital/dp-frontend-models v1.10.1
github.com/ONSdigital/dp-healthcheck v1.5.0
github.com/ONSdigital/dp-net v1.5.0
github.com/ONSdigital/dp-renderer v1.49.0
github.com/ONSdigital/go-ns v0.0.0-20210831102424-ebdecc20fe9e
github.com/ONSdigital/dp-net/v2 v2.6.0
github.com/ONSdigital/dp-renderer v1.58.0
github.com/ONSdigital/dp-topic-api v0.16.0
github.com/ONSdigital/go-ns v0.0.0-20210916104633-ac1c1c52327e
github.com/ONSdigital/log.go/v2 v2.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.2.0
Expand All @@ -19,18 +21,20 @@ require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/ONSdigital/dp-api-clients-go v1.43.0 // indirect
github.com/ONSdigital/dp-api-clients-go/v2 v2.187.0 // indirect
github.com/ONSdigital/dp-net/v2 v2.6.0 // indirect
github.com/ONSdigital/dp-cache v0.3.0 // indirect
github.com/ONSdigital/dp-net v1.5.0 // indirect
github.com/aws/aws-sdk-go v1.44.76 // indirect
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2 // indirect
github.com/elazarl/go-bindata-assetfs v1.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/gosimple/slug v1.9.0 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/justinas/alice v1.2.0 // indirect
github.com/kevinburke/go-bindata v3.24.0+incompatible // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/nicksnyder/go-i18n/v2 v2.1.2 // indirect
Expand Down
Loading