diff --git a/go.mod b/go.mod index 00b3386c4..389b83f1b 100644 --- a/go.mod +++ b/go.mod @@ -245,7 +245,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0 // indirect - github.com/siderolabs/protoenc v0.1.2 // indirect + github.com/siderolabs/protoenc v0.1.3 // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cast v1.4.1 // indirect diff --git a/go.sum b/go.sum index 0a3e30077..167522df1 100644 --- a/go.sum +++ b/go.sum @@ -1037,8 +1037,8 @@ github.com/siderolabs/go-pcidb v0.1.0 h1:6cJPBBmHlIF4GouYR/1g3JXS/niAON+6lIOfKl/ github.com/siderolabs/go-pcidb v0.1.0/go.mod h1:wT/tUxNZFlKSuGBniVwXL53vlGQq2/CVu16y6sMGIao= github.com/siderolabs/go-pointer v1.0.0 h1:6TshPKep2doDQJAAtHUuHWXbca8ZfyRySjSBT/4GsMU= github.com/siderolabs/go-pointer v1.0.0/go.mod h1:HTRFUNYa3R+k0FFKNv11zgkaCLzEkWVzoYZ433P3kHc= -github.com/siderolabs/protoenc v0.1.2 h1:u7tkBcOwByr763I95YY+km9nOFhoIBzHX9XijntDXk8= -github.com/siderolabs/protoenc v0.1.2/go.mod h1:mu4gc6pJxhdJYpuloacKE4jsJojj87qDXwn8LUvs2bY= +github.com/siderolabs/protoenc v0.1.3 h1:MtKTRogutD28T2UeVS5h4dyQ9iKfCT5Q+46M8Ms2oGU= +github.com/siderolabs/protoenc v0.1.3/go.mod h1:mu4gc6pJxhdJYpuloacKE4jsJojj87qDXwn8LUvs2bY= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= diff --git a/go.work.sum b/go.work.sum index 69a5e51c7..c91d0dec7 100644 --- a/go.work.sum +++ b/go.work.sum @@ -197,6 +197,7 @@ github.com/sclevine/spec v1.2.0 h1:1Jwdf9jSfDl9NVmt8ndHqbTZ7XCCPbh1jI3hkDBHVYA= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921 h1:58EBmR2dMNL2n/FnbQewK3D14nXr0V9CObDSvMJLq+Y= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/siderolabs/protoenc v0.1.3/go.mod h1:mu4gc6pJxhdJYpuloacKE4jsJojj87qDXwn8LUvs2bY= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= diff --git a/pkg/machinery/go.mod b/pkg/machinery/go.mod index 41ca04053..3a3330f47 100644 --- a/pkg/machinery/go.mod +++ b/pkg/machinery/go.mod @@ -17,7 +17,7 @@ require ( github.com/mdlayher/ethtool v0.0.0-20220213132912-856bd6cb8a38 github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d github.com/siderolabs/go-pointer v1.0.0 - github.com/siderolabs/protoenc v0.1.2 + github.com/siderolabs/protoenc v0.1.3 github.com/stretchr/testify v1.8.0 github.com/talos-systems/crypto v0.3.6-0.20220622130438-e9df1b8ca74c github.com/talos-systems/go-blockdevice v0.3.4 diff --git a/pkg/machinery/go.sum b/pkg/machinery/go.sum index 52d78b213..34f8515f9 100644 --- a/pkg/machinery/go.sum +++ b/pkg/machinery/go.sum @@ -131,8 +131,8 @@ github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkB github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/siderolabs/go-pointer v1.0.0 h1:6TshPKep2doDQJAAtHUuHWXbca8ZfyRySjSBT/4GsMU= github.com/siderolabs/go-pointer v1.0.0/go.mod h1:HTRFUNYa3R+k0FFKNv11zgkaCLzEkWVzoYZ433P3kHc= -github.com/siderolabs/protoenc v0.1.2 h1:u7tkBcOwByr763I95YY+km9nOFhoIBzHX9XijntDXk8= -github.com/siderolabs/protoenc v0.1.2/go.mod h1:mu4gc6pJxhdJYpuloacKE4jsJojj87qDXwn8LUvs2bY= +github.com/siderolabs/protoenc v0.1.3 h1:MtKTRogutD28T2UeVS5h4dyQ9iKfCT5Q+46M8Ms2oGU= +github.com/siderolabs/protoenc v0.1.3/go.mod h1:mu4gc6pJxhdJYpuloacKE4jsJojj87qDXwn8LUvs2bY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/machinery/proto/proto.go b/pkg/machinery/proto/proto.go index 4ffb29745..3a2940d37 100644 --- a/pkg/machinery/proto/proto.go +++ b/pkg/machinery/proto/proto.go @@ -89,16 +89,15 @@ func RegisterDefaultTypes() { protoenc.RegisterEncoderDecoder( // TODO(DmitriyMV): use generated proto representation of this - // TODO(DmitriyMV): use ptr version - func(v x509.PEMEncodedCertificateAndKey) ([]byte, error) { + func(v *x509.PEMEncodedCertificateAndKey) ([]byte, error) { return json.Marshal(v) }, - func(slc []byte) (x509.PEMEncodedCertificateAndKey, error) { - result := x509.PEMEncodedCertificateAndKey{} + func(slc []byte) (*x509.PEMEncodedCertificateAndKey, error) { + var result *x509.PEMEncodedCertificateAndKey err := json.Unmarshal(slc, &result) if err != nil { - return x509.PEMEncodedCertificateAndKey{}, err + return &x509.PEMEncodedCertificateAndKey{}, err } return result, nil @@ -106,15 +105,31 @@ func RegisterDefaultTypes() { ) protoenc.RegisterEncoderDecoder( - // TODO(DmitriyMV): use ptr version - func(v url.URL) ([]byte, error) { return []byte(v.String()), nil }, - func(slc []byte) (url.URL, error) { - parse, err := url.Parse(string(slc)) + // TODO(DmitriyMV): use generated proto representation of this + func(v *x509.PEMEncodedKey) ([]byte, error) { + return json.Marshal(v) + }, + func(slc []byte) (*x509.PEMEncodedKey, error) { + var result *x509.PEMEncodedKey + + err := json.Unmarshal(slc, &result) if err != nil { - return url.URL{}, err + return &x509.PEMEncodedKey{}, err } - return *parse, nil + return result, nil + }, + ) + + protoenc.RegisterEncoderDecoder( + func(v *url.URL) ([]byte, error) { return []byte(v.String()), nil }, + func(slc []byte) (*url.URL, error) { + parse, err := url.Parse(string(slc)) + if err != nil { + return &url.URL{}, err + } + + return parse, nil }, ) diff --git a/pkg/machinery/resources/k8s/admissioncontrol_config.go b/pkg/machinery/resources/k8s/admissioncontrol_config.go index cab2e906a..bfccac7e8 100644 --- a/pkg/machinery/resources/k8s/admissioncontrol_config.go +++ b/pkg/machinery/resources/k8s/admissioncontrol_config.go @@ -36,9 +36,11 @@ type AdmissionControlConfigSpec struct { } // AdmissionPluginSpec is a single admission plugin configuration Admission Control plugins. +// +//gotagsrewrite:gen type AdmissionPluginSpec struct { - Name string `yaml:"name"` - Configuration map[string]interface{} `yaml:"configuration"` + Name string `yaml:"name" protobuf:"1"` + Configuration map[string]interface{} `yaml:"configuration" protobuf:"2"` } // NewAdmissionControlConfig returns new AdmissionControlConfig resource. diff --git a/pkg/machinery/resources/network/link_status.go b/pkg/machinery/resources/network/link_status.go index 5428f70b7..8a76889b6 100644 --- a/pkg/machinery/resources/network/link_status.go +++ b/pkg/machinery/resources/network/link_status.go @@ -7,9 +7,11 @@ package network import ( "github.com/cosi-project/runtime/pkg/resource" "github.com/cosi-project/runtime/pkg/resource/meta" + "github.com/cosi-project/runtime/pkg/resource/protobuf" "github.com/cosi-project/runtime/pkg/resource/typed" "github.com/talos-systems/talos/pkg/machinery/nethelpers" + "github.com/talos-systems/talos/pkg/machinery/proto" ) // LinkStatusType is type of LinkStatus resource. @@ -103,3 +105,12 @@ func (LinkStatusRD) ResourceDefinition(resource.Metadata, LinkStatusSpec) meta.R Sensitivity: meta.NonSensitive, } } + +func init() { + proto.RegisterDefaultTypes() + + err := protobuf.RegisterDynamic[LinkStatusSpec](LinkStatusType, &LinkStatus{}) + if err != nil { + panic(err) + } +}