diff --git a/api/api.go b/api/api.go index d7ccc95..e5042d9 100644 --- a/api/api.go +++ b/api/api.go @@ -2,16 +2,13 @@ package api // MetalConfig is consumed by metal-hammer to get all options to open a grpc connection to the metal-api type MetalConfig struct { - Debug bool `json:"debug"` - GRPCAddress string `json:"address,omitempty"` - MetalAPIUrl string `json:"metal_api_url,omitempty"` - PixieAPIURL string `json:"pixie_api_url"` - CACert string `json:"ca_cert,omitempty"` - Cert string `json:"cert,omitempty"` - Key string `json:"key,omitempty"` - HMAC string `json:"hmac,omitempty"` - NTPServers []string `json:"ntp_servers,omitempty"` - Partition string `json:"partition"` + Debug bool `json:"debug"` + MetalAPIServerUrl string `json:"metal_apiserver_url,omitempty"` + MetalAPIServerToken string `json:"metal_apiserver_token,omitempty"` + MetalAPIUrl string `json:"metal_api_url,omitempty"` + PixieAPIURL string `json:"pixie_api_url"` + NTPServers []string `json:"ntp_servers,omitempty"` + Partition string `json:"partition"` // Logging contains logging configurations passed to metal-hammer Logging *Logging `json:"logging,omitempty"` } diff --git a/go.mod b/go.mod index 5d6e029..81611b7 100644 --- a/go.mod +++ b/go.mod @@ -3,31 +3,36 @@ module github.com/metal-stack/pixie go 1.25 require ( - github.com/metal-stack/metal-api v0.42.4 + github.com/metal-stack/api v0.0.37-0.20260104175152-d31839deaefb github.com/metal-stack/v v1.0.3 github.com/pin/tftp/v3 v3.1.0 github.com/prometheus/client_golang v1.23.2 - github.com/spf13/cobra v1.10.1 + github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 - golang.org/x/crypto v0.43.0 - golang.org/x/net v0.46.0 - google.golang.org/grpc v1.76.0 + golang.org/x/crypto v0.46.0 + golang.org/x/net v0.48.0 ) require ( + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 // indirect + connectrpc.com/connect v1.19.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/klauspost/compress v1.18.2 // indirect + github.com/klauspost/connect-compress/v2 v2.1.0 // indirect + github.com/minio/minlz v1.0.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.2 // indirect - github.com/prometheus/procfs v0.19.1 // indirect + github.com/prometheus/common v0.67.4 // indirect + github.com/prometheus/procfs v0.19.2 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect @@ -35,9 +40,8 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/sys v0.37.0 // indirect - golang.org/x/text v0.30.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect - google.golang.org/protobuf v1.36.10 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/text v0.32.0 // indirect + google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index d09cf22..17acbd6 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 h1:j9yeqTWEFrtimt8Nng2MIeRrpoCvQzM9/g25XTvqUGg= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM= +connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= +connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -9,32 +13,30 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= +github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= +github.com/klauspost/connect-compress/v2 v2.1.0 h1:8fM8QrVeHT69e5VVSh4yjDaQASYIvOp2uMZq7nVLj2U= +github.com/klauspost/connect-compress/v2 v2.1.0/go.mod h1:Ayurh2wscMMx3AwdGGVL+ylSR5316WfApREDgsqHyH8= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/metal-stack/metal-api v0.42.4 h1:4DVa8INyW2AFV5ryQSD9rtwLiyPa3bAGttJlFXtldMg= -github.com/metal-stack/metal-api v0.42.4/go.mod h1:fzetGND6XWSZyVM/BeryIL5JDC+M6ADIWtBvBJbXKNo= +github.com/metal-stack/api v0.0.37-0.20260104175152-d31839deaefb h1:1258YAQeXOyYDSoWO70qYE2GjCQzmjeIT8meCox45Hc= +github.com/metal-stack/api v0.0.37-0.20260104175152-d31839deaefb/go.mod h1:YwClPWPKdVnPbOO41cqdt0WSsJ/HOd3lkuE1qAXoxSk= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= github.com/metal-stack/v v1.0.3/go.mod h1:YTahEu7/ishwpYKnp/VaW/7nf8+PInogkfGwLcGPdXg= +github.com/minio/minlz v1.0.1 h1:OUZUzXcib8diiX+JYxyRLIdomyZYzHct6EShOKtQY2A= +github.com/minio/minlz v1.0.1/go.mod h1:qT0aEB35q79LLornSzeDH75LBf3aH1MV+jB5w9Wasec= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= @@ -47,10 +49,10 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8= -github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko= -github.com/prometheus/procfs v0.19.1 h1:QVtROpTkphuXuNlnCv3m1ut3JytkXHtQ3xvck/YmzMM= -github.com/prometheus/procfs v0.19.1/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= +github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= +github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= +github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= +github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -60,8 +62,8 @@ github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= -github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= -github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -71,18 +73,6 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= -go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= -go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= -go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= -go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= @@ -90,25 +80,19 @@ go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= -golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= -golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= -golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= -golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/pixiecore/booters.go b/pixiecore/booters.go index 9064b63..04d0e3f 100644 --- a/pixiecore/booters.go +++ b/pixiecore/booters.go @@ -29,7 +29,9 @@ import ( "text/template" "time" - v1 "github.com/metal-stack/metal-api/pkg/api/v1" + "github.com/metal-stack/api/go/client" + infrav2 "github.com/metal-stack/api/go/metalstack/infra/v2" + "github.com/metal-stack/pixie/api" ) @@ -50,9 +52,9 @@ func APIBooter(url string, timeout time.Duration) (Booter, error) { return ret, nil } -func GRPCBooter(log *slog.Logger, client *GrpcClient, partition string, metalAPIConfig *api.MetalConfig) (Booter, error) { +func GRPCBooter(log *slog.Logger, apiclient client.Client, partition string, metalAPIConfig *api.MetalConfig) (Booter, error) { ret := &grpcbooter{ - grpc: client, + apiclient: apiclient, partition: partition, log: log, config: metalAPIConfig, @@ -72,7 +74,7 @@ type apibooter struct { type grpcbooter struct { apibooter - grpc *GrpcClient + apiclient client.Client config *api.MetalConfig partition string log *slog.Logger @@ -87,11 +89,12 @@ func (g *grpcbooter) BootSpec(m Machine) (*Spec, error) { var r rawSpec if m.GUID != "" { // Very first dhcp call which contains Machine UUID, tell metal-api this uuid - req := &v1.BootServiceDhcpRequest{ - Uuid: string(m.GUID), + req := &infrav2.BootServiceDhcpRequest{ + Uuid: string(m.GUID), + Partition: g.partition, } g.log.Info("dhcp", "req", req) - _, err := g.grpc.BootService().Dhcp(ctx, req) + _, err := g.apiclient.Infrav2().Boot().Dhcp(ctx, req) if err != nil { g.log.Error("boot", "error", err) return nil, err @@ -99,26 +102,27 @@ func (g *grpcbooter) BootSpec(m Machine) (*Spec, error) { r = rawSpec{} } else { // machine asks for a dhcp answer, ask metal-api for a proper response in this partition - req := &v1.BootServiceBootRequest{ - Mac: m.MAC.String(), - PartitionId: g.partition, + // TODO maybe simple fetch the partition and remove this endpoint from the api + req := &infrav2.BootServiceBootRequest{ + Mac: m.MAC.String(), + Partition: g.partition, } g.log.Info("boot", "req", req) - resp, err := g.grpc.BootService().Boot(ctx, req) + resp, err := g.apiclient.Infrav2().Boot().Boot(ctx, req) if err != nil { g.log.Error("boot", "error", err) return nil, err } g.log.Info("boot", "resp", resp) - cmdline := []string{resp.GetCmdline(), fmt.Sprintf("PIXIE_API_URL=%s", g.config.PixieAPIURL)} + cmdline := []string{*resp.Cmdline, fmt.Sprintf("PIXIE_API_URL=%s", g.config.PixieAPIURL)} if g.config.Debug { cmdline = append(cmdline, "DEBUG=1") } r = rawSpec{ - Kernel: resp.GetKernel(), - Initrd: resp.GetInitRamDisks(), + Kernel: resp.Kernel, + Initrd: resp.InitRamDisks, Cmdline: strings.Join(cmdline, " "), } } diff --git a/pixiecore/cli/grpccmd.go b/pixiecore/cli/grpccmd.go index 8d36001..e2fe74b 100644 --- a/pixiecore/cli/grpccmd.go +++ b/pixiecore/cli/grpccmd.go @@ -20,6 +20,8 @@ import ( "os" "strings" + "github.com/metal-stack/api/go/client" + "github.com/metal-stack/pixie/api" "github.com/metal-stack/pixie/pixiecore" "github.com/spf13/cobra" @@ -42,15 +44,19 @@ the Pixiecore boot API. The specification can be found at .`, if err != nil { fatalf("unable to create metal-api config: %s", err) } - client, err := pixiecore.NewGrpcClient(s.Log, metalAPIConfig) + apiclient, err := client.New(&client.DialConfig{ + BaseURL: metalAPIConfig.MetalAPIServerUrl, + Token: metalAPIConfig.MetalAPIServerToken, + }) if err != nil { - fatalf("unable to create grpc client: %s", err) + fatalf("error creating metal-apiserver client: %s", err) } + partition, err := cmd.Flags().GetString("partition") if err != nil { - fatalf("Error reading flag: %s", err) + fatalf("error reading flag: %s", err) } - booter, err := pixiecore.GRPCBooter(s.Log, client, partition, metalAPIConfig) + booter, err := pixiecore.GRPCBooter(s.Log, apiclient, partition, metalAPIConfig) if err != nil { fatalf("unable to create grpc booter: %s", err) } @@ -68,10 +74,8 @@ func init() { grpcCmd.Flags().String("pixie-api-url", "", "base url of pixie itself") - grpcCmd.Flags().String("grpc-ca-cert", "", "Path to the grpc ca cert file") - grpcCmd.Flags().String("grpc-cert", "", "Path to the grpc client cert file") - grpcCmd.Flags().String("grpc-key", "", "Path to the grpc client key file") - grpcCmd.Flags().String("grpc-address", "", "address of the grpc server") + grpcCmd.Flags().String("metal-apiserver-url", "", "url of the metal-apiserver") + grpcCmd.Flags().String("metal-apiserver-token", "", "token to access the metal-apiserver") grpcCmd.Flags().String("metal-api-view-hmac", "", "hmac with metal-api view access") grpcCmd.Flags().String("metal-api-url", "", "url to access metal-api") grpcCmd.Flags().StringSlice("ntp-servers", nil, "custom ntp-servers") @@ -88,41 +92,15 @@ func init() { } func getMetalAPIConfig(cmd *cobra.Command) (*api.MetalConfig, error) { - grpcCACertFile, err := cmd.Flags().GetString("grpc-ca-cert") + metalApiServerUrl, err := cmd.Flags().GetString("metal-apiserver-url") if err != nil { return nil, fmt.Errorf("error reading flag: %w", err) } - caCert, err := os.ReadFile(grpcCACertFile) - if err != nil { - return nil, fmt.Errorf("unable to read ca-cert %w", err) - } - - grpcClientCertFile, err := cmd.Flags().GetString("grpc-cert") - if err != nil { - return nil, fmt.Errorf("error reading flag: %w", err) - } - clientCert, err := os.ReadFile(grpcClientCertFile) - if err != nil { - return nil, fmt.Errorf("unable to read cert %w", err) - } - - grpcClientKeyFile, err := cmd.Flags().GetString("grpc-key") - if err != nil { - return nil, fmt.Errorf("unable to read key %w", err) - } - clientKey, err := os.ReadFile(grpcClientKeyFile) - if err != nil { - return nil, err - } - grpcAddress, err := cmd.Flags().GetString("grpc-address") + metalApiServerToken, err := cmd.Flags().GetString("metal-apiserver-token") if err != nil { return nil, fmt.Errorf("error reading flag: %w", err) } - hmac, err := cmd.Flags().GetString("metal-api-view-hmac") - if err != nil { - return nil, fmt.Errorf("error reading flag: %w", err) - } metalAPIUrl, err := cmd.Flags().GetString("metal-api-url") if err != nil { return nil, fmt.Errorf("error reading flag: %w", err) @@ -220,16 +198,13 @@ func getMetalAPIConfig(cmd *cobra.Command) (*api.MetalConfig, error) { } return &api.MetalConfig{ - Debug: metalHammerDebug, - GRPCAddress: grpcAddress, - MetalAPIUrl: metalAPIUrl, - PixieAPIURL: pixieAPIUrl, - CACert: string(caCert), - Cert: string(clientCert), - Key: string(clientKey), - HMAC: hmac, - NTPServers: ntpServers, - Logging: logging, - Partition: partition, + Debug: metalHammerDebug, + MetalAPIServerUrl: metalApiServerUrl, + MetalAPIServerToken: metalApiServerToken, + MetalAPIUrl: metalAPIUrl, + PixieAPIURL: pixieAPIUrl, + NTPServers: ntpServers, + Logging: logging, + Partition: partition, }, nil } diff --git a/pixiecore/grpc.go b/pixiecore/grpc.go deleted file mode 100644 index 23d7ad7..0000000 --- a/pixiecore/grpc.go +++ /dev/null @@ -1,66 +0,0 @@ -package pixiecore - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "log/slog" - "time" - - v1 "github.com/metal-stack/metal-api/pkg/api/v1" - "github.com/metal-stack/pixie/api" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/keepalive" -) - -type GrpcClient struct { - log *slog.Logger - conn grpc.ClientConnInterface -} - -// NewGrpcClient fetches the address and certificates from metal-core needed to communicate with metal-api via grpc, -// and returns a new grpc client that can be used to invoke all provided grpc endpoints. -func NewGrpcClient(log *slog.Logger, config *api.MetalConfig) (*GrpcClient, error) { - clientCert, err := tls.X509KeyPair([]byte(config.Cert), []byte(config.Key)) - if err != nil { - return nil, err - } - - caCertPool := x509.NewCertPool() - ok := caCertPool.AppendCertsFromPEM([]byte(config.CACert)) - if !ok { - return nil, errors.New("bad certificate") - } - - kacp := keepalive.ClientParameters{ - Time: 10 * time.Second, // send pings every 10 seconds if there is no activity - Timeout: time.Second, // wait 1 second for ping ack before considering the connection dead - PermitWithoutStream: true, // send pings even without active streams - } - - tlsConfig := &tls.Config{ - RootCAs: caCertPool, - Certificates: []tls.Certificate{clientCert}, - MinVersion: tls.VersionTLS12, - } - - grpcOpts := []grpc.DialOption{ - grpc.WithKeepaliveParams(kacp), - grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)), - } - - conn, err := grpc.NewClient(config.GRPCAddress, grpcOpts...) - if err != nil { - return nil, err - } - - return &GrpcClient{ - log: log, - conn: conn, - }, nil -} - -func (c *GrpcClient) BootService() v1.BootServiceClient { - return v1.NewBootServiceClient(c.conn) -} diff --git a/pixiecore/http.go b/pixiecore/http.go index f809fc2..bdcbfc7 100644 --- a/pixiecore/http.go +++ b/pixiecore/http.go @@ -225,6 +225,10 @@ func ipxeScript(mach Machine, spec *Spec, serverHost string) ([]byte, error) { } func (s *Server) handleCerts(w http.ResponseWriter, r *http.Request) { + + // TODO: Create a token for the metal-hammer which contains the metalRoles and > 2 days of validity, + // requires adoption of this call to contain the machine-uuid from the metal-hammer + js, err := json.MarshalIndent(s.MetalConfig, "", " ") if err != nil { s.Log.Error("handleCerts unable to marshal grpc config", "error", err)