Skip to content

Commit bfb29a4

Browse files
committed
Update api
1 parent 8ee83de commit bfb29a4

File tree

7 files changed

+78
-60
lines changed

7 files changed

+78
-60
lines changed

api/api.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package api
22

33
// MetalConfig is consumed by metal-hammer to get all options to open a grpc connection to the metal-api
44
type MetalConfig struct {
5-
Debug bool `json:"debug"`
6-
MetalAPIServerUrl string `json:"metal_apiserver_url,omitempty"`
7-
MetalAPIServerToken string `json:"metal_apiserver_token,omitempty"`
8-
MetalAPIUrl string `json:"metal_api_url,omitempty"`
9-
PixieAPIURL string `json:"pixie_api_url"`
10-
NTPServers []string `json:"ntp_servers,omitempty"`
11-
Partition string `json:"partition"`
5+
Debug bool `json:"debug"`
6+
MetalAPIServerUrl string `json:"metal_apiserver_url,omitempty"`
7+
MetalAPIServerToken string `json:"metal_apiserver_token,omitempty"`
8+
MetalAPIServerTokenForHammer string `json:"metal_apiserver_token_for_hammer,omitempty"`
9+
MetalAPIUrl string `json:"metal_api_url,omitempty"`
10+
PixieAPIUrl string `json:"pixie_api_url"`
11+
NTPServers []string `json:"ntp_servers,omitempty"`
12+
Partition string `json:"partition"`
1213
// Logging contains logging configurations passed to metal-hammer
1314
Logging *Logging `json:"logging,omitempty"`
1415
}

go.mod

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ module github.com/metal-stack/pixie
33
go 1.25
44

55
require (
6-
github.com/metal-stack/api v0.0.36-0.20251207083526-910208386a09
6+
github.com/metal-stack/api v0.0.45
77
github.com/metal-stack/v v1.0.3
88
github.com/pin/tftp/v3 v3.1.0
99
github.com/prometheus/client_golang v1.23.2
1010
github.com/spf13/cobra v1.10.2
1111
github.com/spf13/viper v1.21.0
1212
github.com/stretchr/testify v1.11.1
13-
golang.org/x/crypto v0.45.0
14-
golang.org/x/net v0.47.0
13+
golang.org/x/crypto v0.47.0
14+
golang.org/x/net v0.49.0
1515
)
1616

1717
require (
18-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 // indirect
18+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 // indirect
1919
connectrpc.com/connect v1.19.1 // indirect
2020
github.com/beorn7/perks v1.0.1 // indirect
2121
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2222
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2323
github.com/fsnotify/fsnotify v1.9.0 // indirect
24-
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
25-
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
24+
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
25+
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
2626
github.com/inconshreveable/mousetrap v1.1.0 // indirect
27-
github.com/klauspost/compress v1.18.2 // indirect
28-
github.com/klauspost/connect-compress/v2 v2.1.0 // indirect
27+
github.com/klauspost/compress v1.18.3 // indirect
28+
github.com/klauspost/connect-compress/v2 v2.1.1 // indirect
2929
github.com/minio/minlz v1.0.1 // indirect
3030
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3131
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
3232
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3333
github.com/prometheus/client_model v0.6.2 // indirect
34-
github.com/prometheus/common v0.67.4 // indirect
34+
github.com/prometheus/common v0.67.5 // indirect
3535
github.com/prometheus/procfs v0.19.2 // indirect
3636
github.com/sagikazarmark/locafero v0.12.0 // indirect
3737
github.com/spf13/afero v1.15.0 // indirect
@@ -40,8 +40,8 @@ require (
4040
github.com/subosito/gotenv v1.6.0 // indirect
4141
go.yaml.in/yaml/v2 v2.4.3 // indirect
4242
go.yaml.in/yaml/v3 v3.0.4 // indirect
43-
golang.org/x/sys v0.38.0 // indirect
44-
golang.org/x/text v0.31.0 // indirect
45-
google.golang.org/protobuf v1.36.10 // indirect
43+
golang.org/x/sys v0.40.0 // indirect
44+
golang.org/x/text v0.33.0 // indirect
45+
google.golang.org/protobuf v1.36.11 // indirect
4646
gopkg.in/yaml.v3 v3.0.1 // indirect
4747
)

go.sum

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc=
2-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4=
1+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 h1:j9yeqTWEFrtimt8Nng2MIeRrpoCvQzM9/g25XTvqUGg=
2+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
33
connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14=
44
connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w=
55
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -13,26 +13,26 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
1313
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
1414
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
1515
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
16-
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
17-
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
18-
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
19-
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
16+
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
17+
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
18+
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
19+
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
2020
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2121
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
2222
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
2323
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
24-
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
25-
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
26-
github.com/klauspost/connect-compress/v2 v2.1.0 h1:8fM8QrVeHT69e5VVSh4yjDaQASYIvOp2uMZq7nVLj2U=
27-
github.com/klauspost/connect-compress/v2 v2.1.0/go.mod h1:Ayurh2wscMMx3AwdGGVL+ylSR5316WfApREDgsqHyH8=
24+
github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=
25+
github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
26+
github.com/klauspost/connect-compress/v2 v2.1.1 h1:ycZNp4rWOZBodVE2Ls5AzK4aHkyK+GteEfzRZgKNs+c=
27+
github.com/klauspost/connect-compress/v2 v2.1.1/go.mod h1:9oilsPHJMzGKkjafSBk9J7iVo4mO+dw0G0KSdVpnlVE=
2828
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
2929
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3030
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3131
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3232
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
3333
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
34-
github.com/metal-stack/api v0.0.36-0.20251207083526-910208386a09 h1:HZgsBY/SfjcDcCQX351eI2F9rczRKPrwLdfxS41aat8=
35-
github.com/metal-stack/api v0.0.36-0.20251207083526-910208386a09/go.mod h1:7TPVio+EbES1O34iuCjfTe0Hjo8fzwpcbH0wdBtZr2s=
34+
github.com/metal-stack/api v0.0.45 h1:Jein21w+8jEuPt98arB/lbUXzPc+RXEGZPc1HlM1KFw=
35+
github.com/metal-stack/api v0.0.45/go.mod h1:kqAqRS5/5pKOKw4yTbqF/u3h2WCrtvYhKp/Bt2ExZJM=
3636
github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs=
3737
github.com/metal-stack/v v1.0.3/go.mod h1:YTahEu7/ishwpYKnp/VaW/7nf8+PInogkfGwLcGPdXg=
3838
github.com/minio/minlz v1.0.1 h1:OUZUzXcib8diiX+JYxyRLIdomyZYzHct6EShOKtQY2A=
@@ -49,10 +49,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
4949
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
5050
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
5151
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
52-
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
53-
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
54-
github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc=
55-
github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
52+
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
53+
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
5654
github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
5755
github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
5856
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
@@ -64,8 +62,6 @@ github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
6462
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
6563
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
6664
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
67-
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
68-
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
6965
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
7066
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
7167
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
@@ -84,25 +80,19 @@ go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
8480
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
8581
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
8682
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
87-
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
88-
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
89-
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
90-
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
83+
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
84+
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
9185
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
92-
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
93-
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
94-
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
95-
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
86+
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
87+
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
9688
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
97-
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
98-
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
99-
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
100-
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
89+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
90+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
10191
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
102-
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
103-
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
104-
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
105-
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
92+
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
93+
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
94+
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
95+
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
10696
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10797
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
10898
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

pixiecore/booters.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ func (g *grpcbooter) BootSpec(m Machine) (*Spec, error) {
101101
}
102102
r = rawSpec{}
103103
} else {
104-
// machine asks for a dhcp answer, ask metal-api for a proper response in this partition
105-
// TODO maybe simple fetch the partition and remove this endpoint from the api
104+
// machine asks for a dhcp answer, ask metal-apiserver for a proper response in this partition
106105
req := &infrav2.BootServiceBootRequest{
107106
Mac: m.MAC.String(),
108107
Partition: g.partition,
@@ -115,7 +114,14 @@ func (g *grpcbooter) BootSpec(m Machine) (*Spec, error) {
115114
}
116115
g.log.Info("boot", "resp", resp)
117116

118-
cmdline := []string{*resp.Cmdline, fmt.Sprintf("PIXIE_API_URL=%s", g.config.PixieAPIURL)}
117+
var cmdline []string
118+
119+
if resp.Cmdline != nil {
120+
cmdline = append(cmdline, *resp.Cmdline)
121+
}
122+
123+
cmdline = append(cmdline, fmt.Sprintf("PIXIE_API_URL=%s", g.config.PixieAPIUrl))
124+
119125
if g.config.Debug {
120126
cmdline = append(cmdline, "DEBUG=1")
121127
}

pixiecore/cli/grpccmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func getMetalAPIConfig(cmd *cobra.Command) (*api.MetalConfig, error) {
202202
MetalAPIServerUrl: metalApiServerUrl,
203203
MetalAPIServerToken: metalApiServerToken,
204204
MetalAPIUrl: metalAPIUrl,
205-
PixieAPIURL: pixieAPIUrl,
205+
PixieAPIUrl: pixieAPIUrl,
206206
NTPServers: ntpServers,
207207
Logging: logging,
208208
Partition: partition,

pixiecore/http.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import (
2626
"strconv"
2727
"text/template"
2828
"time"
29+
30+
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
31+
"google.golang.org/protobuf/types/known/durationpb"
2932
)
3033

3134
func serveHTTP(l net.Listener, handlers ...func(*http.ServeMux)) error {
@@ -225,9 +228,24 @@ func ipxeScript(mach Machine, spec *Spec, serverHost string) ([]byte, error) {
225228
}
226229

227230
func (s *Server) handleCerts(w http.ResponseWriter, r *http.Request) {
228-
229-
// TODO: Create a token for the metal-hammer which contains the metalRoles and > 2 days of validity,
230-
// requires adoption of this call to contain the machine-uuid from the metal-hammer
231+
// TODO check if we can restrict to the machine uuid only, request must therefor contain the uuid.
232+
// 3 days max lifetime because hammer reboots every 2 days max.
233+
resp, err := s.ApiClient.Apiv2().Token().Create(r.Context(), &apiv2.TokenServiceCreateRequest{
234+
Description: "token for metal-hammer",
235+
MachineRoles: map[string]apiv2.MachineRole{
236+
"*": apiv2.MachineRole_MACHINE_ROLE_EDITOR,
237+
},
238+
Expires: durationpb.New(3 * 24 * time.Hour),
239+
})
240+
if err != nil {
241+
s.Log.Error("unable to create a token for the metal-hammer", "error", err)
242+
http.Error(w, err.Error(), http.StatusInternalServerError)
243+
return
244+
}
245+
// store to created secret to be shipped to metal-hammer
246+
s.MetalConfig.MetalAPIServerTokenForHammer = resp.Secret
247+
// remove token of pixiecore
248+
s.MetalConfig.MetalAPIServerToken = ""
231249

232250
js, err := json.MarshalIndent(s.MetalConfig, "", " ")
233251
if err != nil {

pixiecore/pixiecore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"sync"
2727
"text/template"
2828

29+
"github.com/metal-stack/api/go/client"
2930
"github.com/metal-stack/pixie/api"
3031
"github.com/metal-stack/pixie/dhcp4"
3132
"github.com/metal-stack/v"
@@ -206,6 +207,8 @@ type Server struct {
206207
events map[string][]machineEvent
207208

208209
MetalConfig *api.MetalConfig
210+
// ApiClient to talk to the metal-apiserver
211+
ApiClient client.Client
209212
}
210213

211214
// Serve listens for machines attempting to boot, and uses Booter to

0 commit comments

Comments
 (0)