Skip to content

Commit d126845

Browse files
authored
Merge pull request #401 from nais/domene_url
Domene url
2 parents 57c45af + 2b501c4 commit d126845

File tree

8 files changed

+103
-43
lines changed

8 files changed

+103
-43
lines changed

cmd/naisdevice-agent/main.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func run(ctx context.Context, log *logrus.Entry, cfg *config.Config, notifier no
166166
pb.RegisterDeviceAgentServer(grpcServer, das)
167167

168168
newVersionChannel := make(chan bool, 1)
169-
go versionChecker(ctx, newVersionChannel, notifier, log)
169+
go versionChecker(ctx, newVersionChannel, notifier, log, rc)
170170

171171
go func() {
172172
// This routine forwards status updates from the state machine to the device agent server
@@ -199,7 +199,7 @@ func run(ctx context.Context, log *logrus.Entry, cfg *config.Config, notifier no
199199
return nil
200200
}
201201

202-
func versionChecker(ctx context.Context, newVersionChannel chan<- bool, notifier notify.Notifier, log logrus.FieldLogger) {
202+
func versionChecker(ctx context.Context, newVersionChannel chan<- bool, notifier notify.Notifier, log logrus.FieldLogger, rc runtimeconfig.RuntimeConfig) {
203203
versionCheckTimer := time.NewTimer(versionCheckInterval)
204204
for ctx.Err() == nil {
205205
select {
@@ -214,7 +214,12 @@ func versionChecker(ctx context.Context, newVersionChannel chan<- bool, notifier
214214

215215
newVersionChannel <- newVersionAvailable
216216
if newVersionAvailable {
217-
notifier.Infof("New version of device agent available: https://doc.nais.io/how-to-guides/naisdevice/update")
217+
url := "https://docs.nais.io/how-to-guides/naisdevice/update"
218+
domain := rc.GetDomainFromToken()
219+
if domain != "default" { // if parsing fail we get default
220+
url = fmt.Sprintf("https://docs.%s.cloud.nais.io/how-to-guides/naisdevice/update", domain)
221+
}
222+
notifier.Infof("New version of device agent available: " + url)
218223
versionCheckTimer.Stop()
219224
} else {
220225
versionCheckTimer.Reset(versionCheckInterval)

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/sqlc-dev/sqlc v1.26.0
2626
github.com/stretchr/testify v1.9.0
2727
github.com/urfave/cli/v2 v2.25.7
28-
github.com/vektra/mockery/v2 v2.43.2
28+
github.com/vektra/mockery/v2 v2.46.3
2929
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
3030
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
3131
go.opentelemetry.io/otel v1.24.0
@@ -36,7 +36,7 @@ require (
3636
go.opentelemetry.io/otel/sdk/metric v1.23.1
3737
go.opentelemetry.io/otel/trace v1.24.0
3838
golang.org/x/crypto v0.28.0
39-
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
39+
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
4040
golang.org/x/oauth2 v0.21.0
4141
golang.org/x/sync v0.8.0
4242
golang.org/x/sys v0.26.0
@@ -203,7 +203,7 @@ require (
203203
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
204204
github.com/nunnatsa/ginkgolinter v0.16.2 // indirect
205205
github.com/olekukonko/tablewriter v0.0.5 // indirect
206-
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
206+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
207207
github.com/pganalyze/pg_query_go/v5 v5.1.0 // indirect
208208
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect
209209
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
@@ -241,7 +241,7 @@ require (
241241
github.com/sourcegraph/conc v0.3.0 // indirect
242242
github.com/sourcegraph/go-diff v0.7.0 // indirect
243243
github.com/spf13/afero v1.11.0 // indirect
244-
github.com/spf13/cast v1.6.0 // indirect
244+
github.com/spf13/cast v1.7.0 // indirect
245245
github.com/spf13/cobra v1.8.1 // indirect
246246
github.com/spf13/viper v1.19.0 // indirect
247247
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect

go.sum

+9
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,11 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ
434434
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
435435
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
436436
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
437+
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
437438
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
438439
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
440+
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
441+
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
439442
github.com/pganalyze/pg_query_go/v5 v5.1.0 h1:MlxQqHZnvA3cbRQYyIrjxEjzo560P6MyTgtlaf3pmXg=
440443
github.com/pganalyze/pg_query_go/v5 v5.1.0/go.mod h1:FsglvxidZsVN+Ltw3Ai6nTgPVcK2BPukH3jCDEqc1Ug=
441444
github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
@@ -528,6 +531,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
528531
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
529532
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
530533
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
534+
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
535+
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
531536
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
532537
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
533538
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -590,6 +595,8 @@ github.com/uudashr/gocognit v1.1.2 h1:l6BAEKJqQH2UpKAPKdMfZf5kE4W/2xk8pfU1OVLvni
590595
github.com/uudashr/gocognit v1.1.2/go.mod h1:aAVdLURqcanke8h3vg35BC++eseDm66Z7KmchI5et4k=
591596
github.com/vektra/mockery/v2 v2.43.2 h1:OdivAsQL/uoQ55UnTt25tliRI8kaj5j6caHk9xaAUD0=
592597
github.com/vektra/mockery/v2 v2.43.2/go.mod h1:XNTE9RIu3deGAGQRVjP1VZxGpQNm0YedZx4oDs3prr8=
598+
github.com/vektra/mockery/v2 v2.46.3 h1:Aia4iShZeNTy6CZJcvweK4X97XOzXcqb+k9jm8IqBS0=
599+
github.com/vektra/mockery/v2 v2.46.3/go.mod h1:dDivqi0ShM8A29mLgZn13yZ14MdXlTM4V360u8JDWCQ=
593600
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
594601
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
595602
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
@@ -681,6 +688,8 @@ golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7
681688
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
682689
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
683690
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
691+
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
692+
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
684693
golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
685694
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
686695
golang.org/x/exp/typeparams v0.0.0-20240707233637-46b078467d37 h1:sLjLh33O815/196VSJe2X7Mmaud/GGjSubpzkgfRroY=

internal/device-agent/runtimeconfig/mock_runtime_config.go

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/device-agent/runtimeconfig/runtimeconfig.go

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type RuntimeConfig interface {
5555

5656
GetTenantSession() (*pb.Session, error)
5757

58+
GetDomainFromToken() string
5859
GetToken(context.Context) (string, error)
5960
SetToken(*auth.Tokens)
6061
SetTenantSession(*pb.Session) error

internal/notify/mock_notifier.go

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/pb/mock_api_server_get_device_configuration_client.go

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)