Skip to content

Commit

Permalink
Allow providing metal-stack release version. (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Jul 8, 2024
1 parent c51ed5f commit d0c28f4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion cmd/metal-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

"github.com/metal-stack/metal-lib/jwt/grp"
"github.com/metal-stack/metal-lib/jwt/sec"
"github.com/metal-stack/metal-lib/pkg/pointer"

"connectrpc.com/connect"
restfulspec "github.com/emicklei/go-restful-openapi/v2"
Expand Down Expand Up @@ -296,6 +297,7 @@ func init() {
rootCmd.Flags().String("headscale-api-key", "", "initial api key to connect to headscale server")

rootCmd.Flags().StringP("minimum-client-version", "", "v0.0.1", "the minimum metalctl version required to talk to this version of metal-api")
rootCmd.Flags().String("release-version", "", "the metal-stack release version")

must(viper.BindPFlags(rootCmd.Flags()))
must(viper.BindPFlags(rootCmd.PersistentFlags()))
Expand Down Expand Up @@ -749,6 +751,11 @@ func initRestServices(audit auditing.Auditing, withauth bool, ipmiSuperUser meta
log.Fatalf("given minimum client version is not semver parsable: %s", err)
}

var releaseVersion *string
if viper.IsSet("release-version") {
releaseVersion = pointer.Pointer(viper.GetString("release-version"))
}

restful.DefaultContainer.Add(service.NewAudit(logger.WithGroup("audit-service"), audit))
restful.DefaultContainer.Add(service.NewPartition(logger.WithGroup("partition-service"), ds, nsqer))
restful.DefaultContainer.Add(service.NewImage(logger.WithGroup("image-service"), ds))
Expand All @@ -766,7 +773,11 @@ func initRestServices(audit auditing.Auditing, withauth bool, ipmiSuperUser meta
restful.DefaultContainer.Add(service.NewSwitch(logger.WithGroup("switch-service"), ds))
restful.DefaultContainer.Add(healthService)
restful.DefaultContainer.Add(service.NewVPN(logger.WithGroup("vpn-service"), headscaleClient))
restful.DefaultContainer.Add(rest.NewVersion(moduleName, service.BasePath, minClientVersion.Original()))
restful.DefaultContainer.Add(rest.NewVersion(moduleName, &rest.VersionOpts{
BasePath: service.BasePath,
MinClientVersion: minClientVersion.Original(),
ReleaseVersion: releaseVersion,
}))
restful.DefaultContainer.Filter(rest.RequestLoggerFilter(logger)) // FIXME
restful.DefaultContainer.Filter(metrics.RestfulMetrics)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/looplab/fsm v1.0.2
github.com/metal-stack/go-ipam v1.14.1
github.com/metal-stack/masterdata-api v0.11.4
github.com/metal-stack/metal-lib v0.17.0
github.com/metal-stack/metal-lib v0.17.1
github.com/metal-stack/security v0.8.0
github.com/metal-stack/v v1.0.3
github.com/nsqio/go-nsq v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ github.com/metal-stack/go-ipam v1.14.1 h1:kTe4GUvLTNd27sad2uzxZUS5jD7pZfgfr077xo
github.com/metal-stack/go-ipam v1.14.1/go.mod h1:0KqCwF1nTB3SZGED+Z+bxdZwXQjP7CiLPcjGDLMKn3s=
github.com/metal-stack/masterdata-api v0.11.4 h1:bgRk7PbD5BjYbmAReaV7gTKKKrW5x/ZzCwj98VSWoJk=
github.com/metal-stack/masterdata-api v0.11.4/go.mod h1:fD0AtsoNNaOLqRMBeZzDFljiQW9RlrOnxeZ20Pqhxas=
github.com/metal-stack/metal-lib v0.17.0 h1:0fCRUtYweJ5wbUwiEalFGiHkEz0mZwTWQUIIo3Npzkw=
github.com/metal-stack/metal-lib v0.17.0/go.mod h1:nyNGI4DZFOcWbSoq2Y6V3SHpFxuXBIqYBZHTb6cy//s=
github.com/metal-stack/metal-lib v0.17.1 h1:JLa4wJ62dgxtY9UOLF+QDk10/i/W5vhzrv8RsundDUY=
github.com/metal-stack/metal-lib v0.17.1/go.mod h1:nyNGI4DZFOcWbSoq2Y6V3SHpFxuXBIqYBZHTb6cy//s=
github.com/metal-stack/security v0.8.0 h1:tVaSDB9m5clwYrnLyaXfPy7mQlJTnmeoHscG+RUy/xo=
github.com/metal-stack/security v0.8.0/go.mod h1:7GAcQb+pOgflW30ohJygxpqc3i0dQ2ahGJK1CU5tqa0=
github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs=
Expand Down
3 changes: 3 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@
"name": {
"type": "string"
},
"release_version": {
"type": "string"
},
"revision": {
"type": "string"
},
Expand Down

0 comments on commit d0c28f4

Please sign in to comment.