From a6e436582377203a6b55794e05510df8492c43c6 Mon Sep 17 00:00:00 2001 From: Dmitriy Matrenichev Date: Thu, 12 May 2022 22:50:39 +0800 Subject: [PATCH] feat: implement DeepCopy using code generation Refactor every typed.Resource except KubeletConfigSpec to use deep-copy tool for generating DeepCopy method. KubeletConfigSpec is excluded because its DeepCopy method is not trivial. Signed-off-by: Dmitriy Matrenichev --- Dockerfile | 3 + Makefile | 2 + pkg/machinery/extensions/config.go | 8 +- .../extensions/deep_copy.generated.go | 13 + pkg/machinery/resources/cluster/affiliate.go | 23 +- pkg/machinery/resources/cluster/config.go | 11 - .../resources/cluster/deep_copy.generated.go | 55 ++++ pkg/machinery/resources/cluster/identity.go | 5 - pkg/machinery/resources/cluster/member.go | 11 - .../resources/files/deep_copy.generated.go | 23 ++ pkg/machinery/resources/files/etcfile_spec.go | 10 +- .../resources/files/etcfile_status.go | 5 - .../resources/k8s/admissioncontrol_config.go | 10 +- .../resources/k8s/apiserver_config.go | 7 - pkg/machinery/resources/k8s/config_status.go | 3 - .../resources/k8s/controllermanager_config.go | 7 - .../resources/k8s/deep_copy.generated.go | 280 ++++++++++++++++++ pkg/machinery/resources/k8s/endpoint.go | 9 +- .../resources/k8s/extramanifests_config.go | 7 - .../resources/k8s/kubelet_lifecycle.go | 3 - pkg/machinery/resources/k8s/kubelet_spec.go | 16 - pkg/machinery/resources/k8s/manifest.go | 7 - .../resources/k8s/manifest_status.go | 3 - .../resources/k8s/manifests_config.go | 7 - pkg/machinery/resources/k8s/nodeip.go | 7 - pkg/machinery/resources/k8s/nodeip_config.go | 8 - pkg/machinery/resources/k8s/nodename.go | 3 - .../resources/k8s/scheduler_config.go | 7 - pkg/machinery/resources/k8s/secrets_status.go | 3 - pkg/machinery/resources/k8s/static_pod.go | 16 - .../resources/k8s/static_pod_status.go | 7 - pkg/machinery/resources/kubespan/config.go | 6 +- .../resources/kubespan/deep_copy.generated.go | 49 +++ pkg/machinery/resources/kubespan/endpoint.go | 3 - pkg/machinery/resources/kubespan/identity.go | 3 - pkg/machinery/resources/kubespan/peer_spec.go | 10 - .../resources/kubespan/peer_status.go | 3 - .../resources/network/address_spec.go | 8 +- .../resources/network/address_status.go | 5 - .../resources/network/deep_copy.generated.go | 179 +++++++++++ .../resources/network/hardrware_addr.go | 11 - .../resources/network/hostname_spec.go | 5 - .../resources/network/hostname_status.go | 5 - .../resources/network/link_refresh.go | 3 - pkg/machinery/resources/network/link_spec.go | 19 -- .../resources/network/link_status.go | 29 -- .../resources/network/node_address.go | 7 - .../resources/network/node_address_filter.go | 16 - .../resources/network/operator_spec.go | 5 - .../resources/network/resolver_spec.go | 11 - .../resources/network/resolver_status.go | 11 - pkg/machinery/resources/network/route_spec.go | 5 - .../resources/network/route_status.go | 5 - pkg/machinery/resources/network/status.go | 5 - .../resources/network/timeserver_spec.go | 11 - .../resources/network/timeserver_status.go | 11 - pkg/machinery/resources/perf/cpu.go | 8 +- .../resources/perf/deep_copy.generated.go | 23 ++ pkg/machinery/resources/perf/mem.go | 5 - .../resources/runtime/deep_copy.generated.go | 35 +++ .../resources/runtime/extension_status.go | 3 + .../resources/runtime/kernel_module_spec.go | 5 - .../resources/runtime/kernel_params_spec.go | 5 - .../resources/runtime/kernel_params_status.go | 5 - .../resources/runtime/mount_status.go | 5 - pkg/machinery/resources/secrets/api.go | 8 +- pkg/machinery/resources/secrets/cert_sans.go | 9 - .../resources/secrets/deep_copy.generated.go | 155 ++++++++++ pkg/machinery/resources/secrets/etcd.go | 5 - pkg/machinery/resources/secrets/etcd_root.go | 5 - pkg/machinery/resources/secrets/kubelet.go | 5 - pkg/machinery/resources/secrets/kubernetes.go | 5 - .../resources/secrets/kubernetes_root.go | 5 - pkg/machinery/resources/secrets/os_root.go | 5 - .../resources/time/deep_copy.generated.go | 13 + pkg/machinery/resources/time/status.go | 8 +- .../resources/v1alpha1/deep_copy.generated.go | 13 + pkg/machinery/resources/v1alpha1/service.go | 8 +- 78 files changed, 875 insertions(+), 467 deletions(-) create mode 100644 pkg/machinery/extensions/deep_copy.generated.go create mode 100644 pkg/machinery/resources/cluster/deep_copy.generated.go create mode 100644 pkg/machinery/resources/files/deep_copy.generated.go create mode 100644 pkg/machinery/resources/k8s/deep_copy.generated.go create mode 100644 pkg/machinery/resources/kubespan/deep_copy.generated.go create mode 100644 pkg/machinery/resources/network/deep_copy.generated.go create mode 100644 pkg/machinery/resources/perf/deep_copy.generated.go create mode 100644 pkg/machinery/resources/runtime/deep_copy.generated.go create mode 100644 pkg/machinery/resources/secrets/deep_copy.generated.go create mode 100644 pkg/machinery/resources/time/deep_copy.generated.go create mode 100644 pkg/machinery/resources/v1alpha1/deep_copy.generated.go diff --git a/Dockerfile b/Dockerfile index c1eeb2385..a43a61f7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,6 +102,9 @@ RUN go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \ ARG GOFUMPT_VERSION RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \ && mv /go/bin/gofumpt /toolchain/go/bin/gofumpt +ARG DEEPCOPY_VERSION +RUN go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \ + && mv /go/bin/deep-copy /toolchain/go/bin/deep-copy ARG STRINGER_VERSION RUN go install golang.org/x/tools/cmd/stringer@${STRINGER_VERSION} \ && mv /go/bin/stringer /toolchain/go/bin/stringer diff --git a/Makefile b/Makefile index 87d0d10ae..5d7594d0a 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ STRINGER_VERSION ?= v0.1.10 ENUMER_VERSION ?= v1.1.2 DEEPCOPY_GEN_VERSION ?= v0.21.3 VTPROTOBUF_VERSION ?= v0.2.0 +DEEPCOPY_VERSION ?= v0.5.5 IMPORTVET ?= ghcr.io/siderolabs/importvet:1549a5c OPERATING_SYSTEM := $(shell uname -s | tr "[:upper:]" "[:lower:]") TALOSCTL_DEFAULT_TARGET := talosctl-$(OPERATING_SYSTEM) @@ -82,6 +83,7 @@ COMMON_ARGS += --build-arg=ENUMER_VERSION=$(ENUMER_VERSION) COMMON_ARGS += --build-arg=DEEPCOPY_GEN_VERSION=$(DEEPCOPY_GEN_VERSION) COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION=$(VTPROTOBUF_VERSION) COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION=$(GOLANGCILINT_VERSION) +COMMON_ARGS += --build-arg=DEEPCOPY_VERSION=$(DEEPCOPY_VERSION) COMMON_ARGS += --build-arg=TAG=$(TAG) COMMON_ARGS += --build-arg=SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) COMMON_ARGS += --build-arg=ARTIFACTS=$(ARTIFACTS) diff --git a/pkg/machinery/extensions/config.go b/pkg/machinery/extensions/config.go index ea87a4d9f..bd0215dd3 100644 --- a/pkg/machinery/extensions/config.go +++ b/pkg/machinery/extensions/config.go @@ -10,6 +10,9 @@ import ( "gopkg.in/yaml.v3" ) +//nolint:lll +//go:generate deep-copy -type Layer -header-file ../../../hack/boilerplate.txt -o deep_copy.generated.go . + // Config specifies Talos installer extensions configuration. type Config struct { Layers []*Layer `yaml:"layers"` @@ -44,8 +47,3 @@ func (cfg *Config) Write(path string) error { return yaml.NewEncoder(f).Encode(cfg) } - -// DeepCopy implements DeepCopyable. -func (layer Layer) DeepCopy() Layer { - return layer -} diff --git a/pkg/machinery/extensions/deep_copy.generated.go b/pkg/machinery/extensions/deep_copy.generated.go new file mode 100644 index 000000000..d051d9e86 --- /dev/null +++ b/pkg/machinery/extensions/deep_copy.generated.go @@ -0,0 +1,13 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type Layer -header-file ../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package extensions + +// DeepCopy generates a deep copy of Layer. +func (o Layer) DeepCopy() Layer { + var cp Layer = o + return cp +} diff --git a/pkg/machinery/resources/cluster/affiliate.go b/pkg/machinery/resources/cluster/affiliate.go index 8003992fe..66dda708b 100644 --- a/pkg/machinery/resources/cluster/affiliate.go +++ b/pkg/machinery/resources/cluster/affiliate.go @@ -13,6 +13,8 @@ import ( "github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/machine" ) +//go:generate deep-copy -type AffiliateSpec -type IdentitySpec -type MemberSpec -type ConfigSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // AffiliateType is type of Affiliate resource. const AffiliateType = resource.Type("Affiliates.cluster.talos.dev") @@ -74,27 +76,6 @@ type AffiliateSpec struct { KubeSpan KubeSpanAffiliateSpec `yaml:"kubespan,omitempty"` } -// DeepCopy generates a deep copy of AffiliateSpec. -func (spec AffiliateSpec) DeepCopy() AffiliateSpec { - cp := spec - if spec.Addresses != nil { - cp.Addresses = make([]netaddr.IP, len(spec.Addresses)) - copy(cp.Addresses, spec.Addresses) - } - - if spec.KubeSpan.AdditionalAddresses != nil { - cp.KubeSpan.AdditionalAddresses = make([]netaddr.IPPrefix, len(spec.KubeSpan.AdditionalAddresses)) - copy(cp.KubeSpan.AdditionalAddresses, spec.KubeSpan.AdditionalAddresses) - } - - if spec.KubeSpan.Endpoints != nil { - cp.KubeSpan.Endpoints = make([]netaddr.IPPort, len(spec.KubeSpan.Endpoints)) - copy(cp.KubeSpan.Endpoints, spec.KubeSpan.Endpoints) - } - - return cp -} - // Merge two AffiliateSpecs. // //nolint:gocyclo diff --git a/pkg/machinery/resources/cluster/config.go b/pkg/machinery/resources/cluster/config.go index 1dd66ffcc..0002c2a7f 100644 --- a/pkg/machinery/resources/cluster/config.go +++ b/pkg/machinery/resources/cluster/config.go @@ -32,17 +32,6 @@ type ConfigSpec struct { ServiceClusterID string `yaml:"serviceClusterID"` } -// DeepCopy generates a deep copy of ConfigSpec. -func (cs ConfigSpec) DeepCopy() ConfigSpec { - cp := cs - if cs.ServiceEncryptionKey != nil { - cp.ServiceEncryptionKey = make([]byte, len(cs.ServiceEncryptionKey)) - copy(cp.ServiceEncryptionKey, cs.ServiceEncryptionKey) - } - - return cp -} - // NewConfig initializes a Config resource. func NewConfig(namespace resource.Namespace, id resource.ID) *Config { return typed.NewResource[ConfigSpec, ConfigRD]( diff --git a/pkg/machinery/resources/cluster/deep_copy.generated.go b/pkg/machinery/resources/cluster/deep_copy.generated.go new file mode 100644 index 000000000..ec719c19c --- /dev/null +++ b/pkg/machinery/resources/cluster/deep_copy.generated.go @@ -0,0 +1,55 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type AffiliateSpec -type IdentitySpec -type MemberSpec -type ConfigSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package cluster + +import ( + "inet.af/netaddr" +) + +// DeepCopy generates a deep copy of AffiliateSpec. +func (o AffiliateSpec) DeepCopy() AffiliateSpec { + var cp AffiliateSpec = o + if o.Addresses != nil { + cp.Addresses = make([]netaddr.IP, len(o.Addresses)) + copy(cp.Addresses, o.Addresses) + } + if o.KubeSpan.AdditionalAddresses != nil { + cp.KubeSpan.AdditionalAddresses = make([]netaddr.IPPrefix, len(o.KubeSpan.AdditionalAddresses)) + copy(cp.KubeSpan.AdditionalAddresses, o.KubeSpan.AdditionalAddresses) + } + if o.KubeSpan.Endpoints != nil { + cp.KubeSpan.Endpoints = make([]netaddr.IPPort, len(o.KubeSpan.Endpoints)) + copy(cp.KubeSpan.Endpoints, o.KubeSpan.Endpoints) + } + return cp +} + +// DeepCopy generates a deep copy of IdentitySpec. +func (o IdentitySpec) DeepCopy() IdentitySpec { + var cp IdentitySpec = o + return cp +} + +// DeepCopy generates a deep copy of MemberSpec. +func (o MemberSpec) DeepCopy() MemberSpec { + var cp MemberSpec = o + if o.Addresses != nil { + cp.Addresses = make([]netaddr.IP, len(o.Addresses)) + copy(cp.Addresses, o.Addresses) + } + return cp +} + +// DeepCopy generates a deep copy of ConfigSpec. +func (o ConfigSpec) DeepCopy() ConfigSpec { + var cp ConfigSpec = o + if o.ServiceEncryptionKey != nil { + cp.ServiceEncryptionKey = make([]byte, len(o.ServiceEncryptionKey)) + copy(cp.ServiceEncryptionKey, o.ServiceEncryptionKey) + } + return cp +} diff --git a/pkg/machinery/resources/cluster/identity.go b/pkg/machinery/resources/cluster/identity.go index a2301d31d..7cab50153 100644 --- a/pkg/machinery/resources/cluster/identity.go +++ b/pkg/machinery/resources/cluster/identity.go @@ -29,11 +29,6 @@ type IdentitySpec struct { NodeID string `yaml:"nodeId"` } -// DeepCopy generates a deep copy of IdentitySpec. -func (spec IdentitySpec) DeepCopy() IdentitySpec { - return spec -} - // NewIdentity initializes a Identity resource. func NewIdentity(namespace resource.Namespace, id resource.ID) *Identity { return typed.NewResource[IdentitySpec, IdentityRD]( diff --git a/pkg/machinery/resources/cluster/member.go b/pkg/machinery/resources/cluster/member.go index 3f0ae3de1..631bf5450 100644 --- a/pkg/machinery/resources/cluster/member.go +++ b/pkg/machinery/resources/cluster/member.go @@ -30,17 +30,6 @@ type MemberSpec struct { OperatingSystem string `yaml:"operatingSystem"` } -// DeepCopy generates a deep copy of MemberSpec. -func (spec MemberSpec) DeepCopy() MemberSpec { - cp := spec - if spec.Addresses != nil { - cp.Addresses = make([]netaddr.IP, len(spec.Addresses)) - copy(cp.Addresses, spec.Addresses) - } - - return cp -} - // NewMember initializes a Member resource. func NewMember(namespace resource.Namespace, id resource.ID) *Member { return typed.NewResource[MemberSpec, MemberRD]( diff --git a/pkg/machinery/resources/files/deep_copy.generated.go b/pkg/machinery/resources/files/deep_copy.generated.go new file mode 100644 index 000000000..cd5b23e54 --- /dev/null +++ b/pkg/machinery/resources/files/deep_copy.generated.go @@ -0,0 +1,23 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type EtcFileSpecSpec -type EtcFileStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package files + +// DeepCopy generates a deep copy of EtcFileSpecSpec. +func (o EtcFileSpecSpec) DeepCopy() EtcFileSpecSpec { + var cp EtcFileSpecSpec = o + if o.Contents != nil { + cp.Contents = make([]byte, len(o.Contents)) + copy(cp.Contents, o.Contents) + } + return cp +} + +// DeepCopy generates a deep copy of EtcFileStatusSpec. +func (o EtcFileStatusSpec) DeepCopy() EtcFileStatusSpec { + var cp EtcFileStatusSpec = o + return cp +} diff --git a/pkg/machinery/resources/files/etcfile_spec.go b/pkg/machinery/resources/files/etcfile_spec.go index 702a2efec..1229aa569 100644 --- a/pkg/machinery/resources/files/etcfile_spec.go +++ b/pkg/machinery/resources/files/etcfile_spec.go @@ -12,6 +12,8 @@ import ( "github.com/cosi-project/runtime/pkg/resource/typed" ) +//go:generate deep-copy -type EtcFileSpecSpec -type EtcFileStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // EtcFileSpecType is type of EtcFile resource. const EtcFileSpecType = resource.Type("EtcFileSpecs.files.talos.dev") @@ -24,14 +26,6 @@ type EtcFileSpecSpec struct { Mode fs.FileMode `yaml:"mode"` } -// DeepCopy implements typed.DeepCopyable interface. -func (e EtcFileSpecSpec) DeepCopy() EtcFileSpecSpec { - return EtcFileSpecSpec{ - Contents: append([]byte(nil), e.Contents...), - Mode: e.Mode, - } -} - // NewEtcFileSpec initializes a EtcFileSpec resource. func NewEtcFileSpec(namespace resource.Namespace, id resource.ID) *EtcFileSpec { return typed.NewResource[EtcFileSpecSpec, EtcFileSpecMD]( diff --git a/pkg/machinery/resources/files/etcfile_status.go b/pkg/machinery/resources/files/etcfile_status.go index a3a1341b5..8373da46f 100644 --- a/pkg/machinery/resources/files/etcfile_status.go +++ b/pkg/machinery/resources/files/etcfile_status.go @@ -21,11 +21,6 @@ type EtcFileStatusSpec struct { SpecVersion string `yaml:"specVersion"` } -// DeepCopy implements typed.DeepCopyable interface. -func (e EtcFileStatusSpec) DeepCopy() EtcFileStatusSpec { - return e -} - // NewEtcFileStatus initializes a EtcFileStatus resource. func NewEtcFileStatus(namespace resource.Namespace, id resource.ID) *EtcFileStatus { return typed.NewResource[EtcFileStatusSpec, EtcFileStatusMD]( diff --git a/pkg/machinery/resources/k8s/admissioncontrol_config.go b/pkg/machinery/resources/k8s/admissioncontrol_config.go index 4249f6f60..74c3ca5b9 100644 --- a/pkg/machinery/resources/k8s/admissioncontrol_config.go +++ b/pkg/machinery/resources/k8s/admissioncontrol_config.go @@ -13,6 +13,9 @@ import ( "github.com/cosi-project/runtime/pkg/resource/typed" ) +//nolint:lll +//go:generate deep-copy -type AdmissionControlConfigSpec -type APIServerConfigSpec -type ConfigStatusSpec -type ControllerManagerConfigSpec -type EndpointSpec -type ExtraManifestsConfigSpec -type KubeletLifecycleSpec -type KubeletSpecSpec -type ManifestSpec -type ManifestStatusSpec -type BootstrapManifestsConfigSpec -type NodeIPSpec -type NodeIPConfigSpec -type NodenameSpec -type SchedulerConfigSpec -type SecretsStatusSpec -type StaticPodSpec -type StaticPodStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // AdmissionControlConfigType is type of AdmissionControlConfig resource. const AdmissionControlConfigType = resource.Type("AdmissionControlConfigs.kubernetes.talos.dev") @@ -33,13 +36,6 @@ type AdmissionPluginSpec struct { Configuration map[string]interface{} `yaml:"configuration"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec AdmissionControlConfigSpec) DeepCopy() AdmissionControlConfigSpec { - return spec -} - // NewAdmissionControlConfig returns new AdmissionControlConfig resource. func NewAdmissionControlConfig() *AdmissionControlConfig { return typed.NewResource[AdmissionControlConfigSpec, AdmissionControlConfigRD]( diff --git a/pkg/machinery/resources/k8s/apiserver_config.go b/pkg/machinery/resources/k8s/apiserver_config.go index 61899ba96..986973000 100644 --- a/pkg/machinery/resources/k8s/apiserver_config.go +++ b/pkg/machinery/resources/k8s/apiserver_config.go @@ -44,13 +44,6 @@ type APIServerConfigSpec struct { PodSecurityPolicyEnabled bool `yaml:"podSecurityPolicyEnabled"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec APIServerConfigSpec) DeepCopy() APIServerConfigSpec { - return spec -} - // NewAPIServerConfig returns new APIServerConfig resource. func NewAPIServerConfig() *APIServerConfig { return typed.NewResource[APIServerConfigSpec, APIServerConfigRD]( diff --git a/pkg/machinery/resources/k8s/config_status.go b/pkg/machinery/resources/k8s/config_status.go index cc98e31c5..603500fbc 100644 --- a/pkg/machinery/resources/k8s/config_status.go +++ b/pkg/machinery/resources/k8s/config_status.go @@ -28,9 +28,6 @@ type ConfigStatusSpec struct { Version string `yaml:"version"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec ConfigStatusSpec) DeepCopy() ConfigStatusSpec { return spec } - // NewConfigStatus initializes a ConfigStatus resource. func NewConfigStatus(namespace resource.Namespace, id resource.ID) *ConfigStatus { return typed.NewResource[ConfigStatusSpec, ConfigStatusRD]( diff --git a/pkg/machinery/resources/k8s/controllermanager_config.go b/pkg/machinery/resources/k8s/controllermanager_config.go index c325a6fda..79ee29e1f 100644 --- a/pkg/machinery/resources/k8s/controllermanager_config.go +++ b/pkg/machinery/resources/k8s/controllermanager_config.go @@ -34,13 +34,6 @@ type ControllerManagerConfigSpec struct { EnvironmentVariables map[string]string `yaml:"environmentVariables"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec ControllerManagerConfigSpec) DeepCopy() ControllerManagerConfigSpec { - return spec -} - // NewControllerManagerConfig returns new ControllerManagerConfig resource. func NewControllerManagerConfig() *ControllerManagerConfig { return typed.NewResource[ControllerManagerConfigSpec, ControllerManagerConfigRD]( diff --git a/pkg/machinery/resources/k8s/deep_copy.generated.go b/pkg/machinery/resources/k8s/deep_copy.generated.go new file mode 100644 index 000000000..1a424cf9e --- /dev/null +++ b/pkg/machinery/resources/k8s/deep_copy.generated.go @@ -0,0 +1,280 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type AdmissionControlConfigSpec -type APIServerConfigSpec -type ConfigStatusSpec -type ControllerManagerConfigSpec -type EndpointSpec -type ExtraManifestsConfigSpec -type KubeletLifecycleSpec -type KubeletSpecSpec -type ManifestSpec -type ManifestStatusSpec -type BootstrapManifestsConfigSpec -type NodeIPSpec -type NodeIPConfigSpec -type NodenameSpec -type SchedulerConfigSpec -type SecretsStatusSpec -type StaticPodSpec -type StaticPodStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package k8s + +import ( + specs "github.com/opencontainers/runtime-spec/specs-go" + "inet.af/netaddr" +) + +// DeepCopy generates a deep copy of AdmissionControlConfigSpec. +func (o AdmissionControlConfigSpec) DeepCopy() AdmissionControlConfigSpec { + var cp AdmissionControlConfigSpec = o + if o.Config != nil { + cp.Config = make([]AdmissionPluginSpec, len(o.Config)) + copy(cp.Config, o.Config) + for i2 := range o.Config { + if o.Config[i2].Configuration != nil { + cp.Config[i2].Configuration = make(map[string]interface{}, len(o.Config[i2].Configuration)) + for k4, v4 := range o.Config[i2].Configuration { + cp.Config[i2].Configuration[k4] = v4 + } + } + } + } + return cp +} + +// DeepCopy generates a deep copy of APIServerConfigSpec. +func (o APIServerConfigSpec) DeepCopy() APIServerConfigSpec { + var cp APIServerConfigSpec = o + if o.EtcdServers != nil { + cp.EtcdServers = make([]string, len(o.EtcdServers)) + copy(cp.EtcdServers, o.EtcdServers) + } + if o.ServiceCIDRs != nil { + cp.ServiceCIDRs = make([]string, len(o.ServiceCIDRs)) + copy(cp.ServiceCIDRs, o.ServiceCIDRs) + } + if o.ExtraArgs != nil { + cp.ExtraArgs = make(map[string]string, len(o.ExtraArgs)) + for k2, v2 := range o.ExtraArgs { + cp.ExtraArgs[k2] = v2 + } + } + if o.ExtraVolumes != nil { + cp.ExtraVolumes = make([]ExtraVolume, len(o.ExtraVolumes)) + copy(cp.ExtraVolumes, o.ExtraVolumes) + } + if o.EnvironmentVariables != nil { + cp.EnvironmentVariables = make(map[string]string, len(o.EnvironmentVariables)) + for k2, v2 := range o.EnvironmentVariables { + cp.EnvironmentVariables[k2] = v2 + } + } + return cp +} + +// DeepCopy generates a deep copy of ConfigStatusSpec. +func (o ConfigStatusSpec) DeepCopy() ConfigStatusSpec { + var cp ConfigStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of ControllerManagerConfigSpec. +func (o ControllerManagerConfigSpec) DeepCopy() ControllerManagerConfigSpec { + var cp ControllerManagerConfigSpec = o + if o.PodCIDRs != nil { + cp.PodCIDRs = make([]string, len(o.PodCIDRs)) + copy(cp.PodCIDRs, o.PodCIDRs) + } + if o.ServiceCIDRs != nil { + cp.ServiceCIDRs = make([]string, len(o.ServiceCIDRs)) + copy(cp.ServiceCIDRs, o.ServiceCIDRs) + } + if o.ExtraArgs != nil { + cp.ExtraArgs = make(map[string]string, len(o.ExtraArgs)) + for k2, v2 := range o.ExtraArgs { + cp.ExtraArgs[k2] = v2 + } + } + if o.ExtraVolumes != nil { + cp.ExtraVolumes = make([]ExtraVolume, len(o.ExtraVolumes)) + copy(cp.ExtraVolumes, o.ExtraVolumes) + } + if o.EnvironmentVariables != nil { + cp.EnvironmentVariables = make(map[string]string, len(o.EnvironmentVariables)) + for k2, v2 := range o.EnvironmentVariables { + cp.EnvironmentVariables[k2] = v2 + } + } + return cp +} + +// DeepCopy generates a deep copy of EndpointSpec. +func (o EndpointSpec) DeepCopy() EndpointSpec { + var cp EndpointSpec = o + if o.Addresses != nil { + cp.Addresses = make([]netaddr.IP, len(o.Addresses)) + copy(cp.Addresses, o.Addresses) + } + return cp +} + +// DeepCopy generates a deep copy of ExtraManifestsConfigSpec. +func (o ExtraManifestsConfigSpec) DeepCopy() ExtraManifestsConfigSpec { + var cp ExtraManifestsConfigSpec = o + if o.ExtraManifests != nil { + cp.ExtraManifests = make([]ExtraManifest, len(o.ExtraManifests)) + copy(cp.ExtraManifests, o.ExtraManifests) + for i2 := range o.ExtraManifests { + if o.ExtraManifests[i2].ExtraHeaders != nil { + cp.ExtraManifests[i2].ExtraHeaders = make(map[string]string, len(o.ExtraManifests[i2].ExtraHeaders)) + for k4, v4 := range o.ExtraManifests[i2].ExtraHeaders { + cp.ExtraManifests[i2].ExtraHeaders[k4] = v4 + } + } + } + } + return cp +} + +// DeepCopy generates a deep copy of KubeletLifecycleSpec. +func (o KubeletLifecycleSpec) DeepCopy() KubeletLifecycleSpec { + var cp KubeletLifecycleSpec = o + return cp +} + +// DeepCopy generates a deep copy of KubeletSpecSpec. +func (o KubeletSpecSpec) DeepCopy() KubeletSpecSpec { + var cp KubeletSpecSpec = o + if o.Args != nil { + cp.Args = make([]string, len(o.Args)) + copy(cp.Args, o.Args) + } + if o.ExtraMounts != nil { + cp.ExtraMounts = make([]specs.Mount, len(o.ExtraMounts)) + copy(cp.ExtraMounts, o.ExtraMounts) + for i2 := range o.ExtraMounts { + if o.ExtraMounts[i2].Options != nil { + cp.ExtraMounts[i2].Options = make([]string, len(o.ExtraMounts[i2].Options)) + copy(cp.ExtraMounts[i2].Options, o.ExtraMounts[i2].Options) + } + } + } + if o.Config != nil { + cp.Config = make(map[string]interface{}, len(o.Config)) + for k2, v2 := range o.Config { + cp.Config[k2] = v2 + } + } + return cp +} + +// DeepCopy generates a deep copy of ManifestSpec. +func (o ManifestSpec) DeepCopy() ManifestSpec { + var cp ManifestSpec = o + if o.Items != nil { + cp.Items = make([]map[string]interface{}, len(o.Items)) + copy(cp.Items, o.Items) + for i2 := range o.Items { + if o.Items[i2] != nil { + cp.Items[i2] = make(map[string]interface{}, len(o.Items[i2])) + for k3, v3 := range o.Items[i2] { + cp.Items[i2][k3] = v3 + } + } + } + } + return cp +} + +// DeepCopy generates a deep copy of ManifestStatusSpec. +func (o ManifestStatusSpec) DeepCopy() ManifestStatusSpec { + var cp ManifestStatusSpec = o + if o.ManifestsApplied != nil { + cp.ManifestsApplied = make([]string, len(o.ManifestsApplied)) + copy(cp.ManifestsApplied, o.ManifestsApplied) + } + return cp +} + +// DeepCopy generates a deep copy of BootstrapManifestsConfigSpec. +func (o BootstrapManifestsConfigSpec) DeepCopy() BootstrapManifestsConfigSpec { + var cp BootstrapManifestsConfigSpec = o + if o.PodCIDRs != nil { + cp.PodCIDRs = make([]string, len(o.PodCIDRs)) + copy(cp.PodCIDRs, o.PodCIDRs) + } + if o.ProxyArgs != nil { + cp.ProxyArgs = make([]string, len(o.ProxyArgs)) + copy(cp.ProxyArgs, o.ProxyArgs) + } + return cp +} + +// DeepCopy generates a deep copy of NodeIPSpec. +func (o NodeIPSpec) DeepCopy() NodeIPSpec { + var cp NodeIPSpec = o + if o.Addresses != nil { + cp.Addresses = make([]netaddr.IP, len(o.Addresses)) + copy(cp.Addresses, o.Addresses) + } + return cp +} + +// DeepCopy generates a deep copy of NodeIPConfigSpec. +func (o NodeIPConfigSpec) DeepCopy() NodeIPConfigSpec { + var cp NodeIPConfigSpec = o + if o.ValidSubnets != nil { + cp.ValidSubnets = make([]string, len(o.ValidSubnets)) + copy(cp.ValidSubnets, o.ValidSubnets) + } + if o.ExcludeSubnets != nil { + cp.ExcludeSubnets = make([]string, len(o.ExcludeSubnets)) + copy(cp.ExcludeSubnets, o.ExcludeSubnets) + } + return cp +} + +// DeepCopy generates a deep copy of NodenameSpec. +func (o NodenameSpec) DeepCopy() NodenameSpec { + var cp NodenameSpec = o + return cp +} + +// DeepCopy generates a deep copy of SchedulerConfigSpec. +func (o SchedulerConfigSpec) DeepCopy() SchedulerConfigSpec { + var cp SchedulerConfigSpec = o + if o.ExtraArgs != nil { + cp.ExtraArgs = make(map[string]string, len(o.ExtraArgs)) + for k2, v2 := range o.ExtraArgs { + cp.ExtraArgs[k2] = v2 + } + } + if o.ExtraVolumes != nil { + cp.ExtraVolumes = make([]ExtraVolume, len(o.ExtraVolumes)) + copy(cp.ExtraVolumes, o.ExtraVolumes) + } + if o.EnvironmentVariables != nil { + cp.EnvironmentVariables = make(map[string]string, len(o.EnvironmentVariables)) + for k2, v2 := range o.EnvironmentVariables { + cp.EnvironmentVariables[k2] = v2 + } + } + return cp +} + +// DeepCopy generates a deep copy of SecretsStatusSpec. +func (o SecretsStatusSpec) DeepCopy() SecretsStatusSpec { + var cp SecretsStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of StaticPodSpec. +func (o StaticPodSpec) DeepCopy() StaticPodSpec { + var cp StaticPodSpec = o + if o.Pod != nil { + cp.Pod = make(map[string]interface{}, len(o.Pod)) + for k2, v2 := range o.Pod { + cp.Pod[k2] = v2 + } + } + return cp +} + +// DeepCopy generates a deep copy of StaticPodStatusSpec. +func (o StaticPodStatusSpec) DeepCopy() StaticPodStatusSpec { + var cp StaticPodStatusSpec = o + if o.PodStatus != nil { + cp.PodStatus = make(map[string]interface{}, len(o.PodStatus)) + for k2, v2 := range o.PodStatus { + cp.PodStatus[k2] = v2 + } + } + return cp +} diff --git a/pkg/machinery/resources/k8s/endpoint.go b/pkg/machinery/resources/k8s/endpoint.go index fb4fe0888..e72def931 100644 --- a/pkg/machinery/resources/k8s/endpoint.go +++ b/pkg/machinery/resources/k8s/endpoint.go @@ -30,14 +30,7 @@ type EndpointSpec struct { Addresses []netaddr.IP `yaml:"addresses"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec EndpointSpec) DeepCopy() EndpointSpec { - return EndpointSpec{ - Addresses: append([]netaddr.IP(nil), spec.Addresses...), - } -} - -// NewEndpoint initializes a Endpoint resource. +// NewEndpoint initializes the Endpoint resource. func NewEndpoint(namespace resource.Namespace, id resource.ID) *Endpoint { return typed.NewResource[EndpointSpec, EndpointRD]( resource.NewMetadata(namespace, EndpointType, id, resource.VersionUndefined), diff --git a/pkg/machinery/resources/k8s/extramanifests_config.go b/pkg/machinery/resources/k8s/extramanifests_config.go index 672c9dfb7..cc1db9cf6 100644 --- a/pkg/machinery/resources/k8s/extramanifests_config.go +++ b/pkg/machinery/resources/k8s/extramanifests_config.go @@ -36,13 +36,6 @@ type ExtraManifest struct { InlineManifest string `yaml:"inlineManifest"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec ExtraManifestsConfigSpec) DeepCopy() ExtraManifestsConfigSpec { - return spec -} - // NewExtraManifestsConfig returns new ExtraManifestsConfig resource. func NewExtraManifestsConfig() *ExtraManifestsConfig { return typed.NewResource[ExtraManifestsConfigSpec, ExtraManifestsConfigRD]( diff --git a/pkg/machinery/resources/k8s/kubelet_lifecycle.go b/pkg/machinery/resources/k8s/kubelet_lifecycle.go index 90ca0c348..b764aba6a 100644 --- a/pkg/machinery/resources/k8s/kubelet_lifecycle.go +++ b/pkg/machinery/resources/k8s/kubelet_lifecycle.go @@ -28,9 +28,6 @@ type KubeletLifecycle = typed.Resource[KubeletLifecycleSpec, KubeletLifecycleRD] // KubeletLifecycleSpec is empty. type KubeletLifecycleSpec struct{} -// DeepCopy implements typed.DeepCopyable interface. -func (spec KubeletLifecycleSpec) DeepCopy() KubeletLifecycleSpec { return spec } - // NewKubeletLifecycle initializes an empty KubeletLifecycle resource. func NewKubeletLifecycle(namespace resource.Namespace, id resource.ID) *KubeletLifecycle { return typed.NewResource[KubeletLifecycleSpec, KubeletLifecycleRD]( diff --git a/pkg/machinery/resources/k8s/kubelet_spec.go b/pkg/machinery/resources/k8s/kubelet_spec.go index c2e8508af..b6051180e 100644 --- a/pkg/machinery/resources/k8s/kubelet_spec.go +++ b/pkg/machinery/resources/k8s/kubelet_spec.go @@ -25,22 +25,6 @@ type KubeletSpecSpec struct { Config map[string]interface{} `yaml:"config"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec KubeletSpecSpec) DeepCopy() KubeletSpecSpec { - config := make(map[string]interface{}, len(spec.Config)) - - for k, v := range spec.Config { - config[k] = v - } - - return KubeletSpecSpec{ - Image: spec.Image, - Args: append([]string(nil), spec.Args...), - ExtraMounts: append([]specs.Mount(nil), spec.ExtraMounts...), - Config: config, - } -} - // NewKubeletSpec initializes an empty KubeletSpec resource. func NewKubeletSpec(namespace resource.Namespace, id resource.ID) *KubeletSpec { return typed.NewResource[KubeletSpecSpec, KubeletSpecRD]( diff --git a/pkg/machinery/resources/k8s/manifest.go b/pkg/machinery/resources/k8s/manifest.go index 5c6eb2b15..9efa3da0a 100644 --- a/pkg/machinery/resources/k8s/manifest.go +++ b/pkg/machinery/resources/k8s/manifest.go @@ -21,13 +21,6 @@ type ManifestSpec struct { Items []map[string]interface{} } -// DeepCopy implements typed.DeepCopyable interface. -func (spec ManifestSpec) DeepCopy() ManifestSpec { - return ManifestSpec{ - Items: append([]map[string]interface{}(nil), spec.Items...), - } -} - // MarshalYAML implements yaml.Marshaler. func (spec ManifestSpec) MarshalYAML() (interface{}, error) { return spec.Items, nil diff --git a/pkg/machinery/resources/k8s/manifest_status.go b/pkg/machinery/resources/k8s/manifest_status.go index 860d8d78c..81f581ced 100644 --- a/pkg/machinery/resources/k8s/manifest_status.go +++ b/pkg/machinery/resources/k8s/manifest_status.go @@ -24,9 +24,6 @@ type ManifestStatusSpec struct { ManifestsApplied []string `yaml:"manifestsApplied"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec ManifestStatusSpec) DeepCopy() ManifestStatusSpec { return spec } - // NewManifestStatus initializes an empty ManifestStatus resource. func NewManifestStatus(namespace resource.Namespace) *ManifestStatus { return typed.NewResource[ManifestStatusSpec, ManifestStatusRD]( diff --git a/pkg/machinery/resources/k8s/manifests_config.go b/pkg/machinery/resources/k8s/manifests_config.go index 5c41bf47f..693af1847 100644 --- a/pkg/machinery/resources/k8s/manifests_config.go +++ b/pkg/machinery/resources/k8s/manifests_config.go @@ -46,13 +46,6 @@ type BootstrapManifestsConfigSpec struct { PodSecurityPolicyEnabled bool `yaml:"podSecurityPolicyEnabled"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec BootstrapManifestsConfigSpec) DeepCopy() BootstrapManifestsConfigSpec { - return spec -} - // NewBootstrapManifestsConfig returns new BootstrapManifestsConfig resource. func NewBootstrapManifestsConfig() *BootstrapManifestsConfig { return typed.NewResource[BootstrapManifestsConfigSpec, BootstrapManifestsConfigRD]( diff --git a/pkg/machinery/resources/k8s/nodeip.go b/pkg/machinery/resources/k8s/nodeip.go index e94a6d3b5..8aaec21d1 100644 --- a/pkg/machinery/resources/k8s/nodeip.go +++ b/pkg/machinery/resources/k8s/nodeip.go @@ -22,13 +22,6 @@ type NodeIPSpec struct { Addresses []netaddr.IP `yaml:"addresses"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec NodeIPSpec) DeepCopy() NodeIPSpec { - return NodeIPSpec{ - Addresses: append([]netaddr.IP(nil), spec.Addresses...), - } -} - // NewNodeIP initializes an empty NodeIP resource. func NewNodeIP(namespace resource.Namespace, id resource.ID) *NodeIP { return typed.NewResource[NodeIPSpec, NodeIPRD]( diff --git a/pkg/machinery/resources/k8s/nodeip_config.go b/pkg/machinery/resources/k8s/nodeip_config.go index 2aa122d44..afd2d66ab 100644 --- a/pkg/machinery/resources/k8s/nodeip_config.go +++ b/pkg/machinery/resources/k8s/nodeip_config.go @@ -22,14 +22,6 @@ type NodeIPConfigSpec struct { ExcludeSubnets []string `yaml:"excludeSubnets"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec NodeIPConfigSpec) DeepCopy() NodeIPConfigSpec { - return NodeIPConfigSpec{ - ValidSubnets: append([]string(nil), spec.ValidSubnets...), - ExcludeSubnets: append([]string(nil), spec.ExcludeSubnets...), - } -} - // NewNodeIPConfig initializes an empty NodeIPConfig resource. func NewNodeIPConfig(namespace resource.Namespace, id resource.ID) *NodeIPConfig { return typed.NewResource[NodeIPConfigSpec, NodeIPConfigRD]( diff --git a/pkg/machinery/resources/k8s/nodename.go b/pkg/machinery/resources/k8s/nodename.go index b6b822aaf..ac4c763c0 100644 --- a/pkg/machinery/resources/k8s/nodename.go +++ b/pkg/machinery/resources/k8s/nodename.go @@ -25,9 +25,6 @@ type NodenameSpec struct { HostnameVersion string `yaml:"hostnameVersion"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec NodenameSpec) DeepCopy() NodenameSpec { return spec } - // NewNodename initializes a Nodename resource. func NewNodename(namespace resource.Namespace, id resource.ID) *Nodename { return typed.NewResource[NodenameSpec, NodenameRD]( diff --git a/pkg/machinery/resources/k8s/scheduler_config.go b/pkg/machinery/resources/k8s/scheduler_config.go index 4f1ae35b8..f2bcd6560 100644 --- a/pkg/machinery/resources/k8s/scheduler_config.go +++ b/pkg/machinery/resources/k8s/scheduler_config.go @@ -31,13 +31,6 @@ type SchedulerConfigSpec struct { EnvironmentVariables map[string]string `yaml:"environmentVariables"` } -// DeepCopy implements Deepcopyable. -// -// TODO: should be properly go-generated. -func (spec SchedulerConfigSpec) DeepCopy() SchedulerConfigSpec { - return spec -} - // NewSchedulerConfig returns new SchedulerConfig resource. func NewSchedulerConfig() *SchedulerConfig { return typed.NewResource[SchedulerConfigSpec, SchedulerConfigRD]( diff --git a/pkg/machinery/resources/k8s/secrets_status.go b/pkg/machinery/resources/k8s/secrets_status.go index a60ea3646..c4e301cc5 100644 --- a/pkg/machinery/resources/k8s/secrets_status.go +++ b/pkg/machinery/resources/k8s/secrets_status.go @@ -28,9 +28,6 @@ type SecretsStatusSpec struct { Version string `yaml:"version"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec SecretsStatusSpec) DeepCopy() SecretsStatusSpec { return spec } - // NewSecretsStatus initializes a SecretsStatus resource. func NewSecretsStatus(namespace resource.Namespace, id resource.ID) *SecretsStatus { return typed.NewResource[SecretsStatusSpec, SecretsStatusRD]( diff --git a/pkg/machinery/resources/k8s/static_pod.go b/pkg/machinery/resources/k8s/static_pod.go index 9028e3752..d741907a5 100644 --- a/pkg/machinery/resources/k8s/static_pod.go +++ b/pkg/machinery/resources/k8s/static_pod.go @@ -21,13 +21,6 @@ type StaticPodSpec struct { Pod map[string]interface{} } -// DeepCopy implements typed.DeepCopyable interface. -func (spec StaticPodSpec) DeepCopy() StaticPodSpec { - return StaticPodSpec{ - Pod: copyMap(spec.Pod), - } -} - // MarshalYAML implements yaml.Marshaler. func (spec StaticPodSpec) MarshalYAML() (interface{}, error) { return spec.Pod, nil @@ -52,12 +45,3 @@ func (StaticPodRD) ResourceDefinition(resource.Metadata, StaticPodSpec) meta.Res DefaultNamespace: NamespaceName, } } - -func copyMap[K comparable, V any](m map[K]V) map[K]V { - result := make(map[K]V, len(m)) - for k, v := range m { - result[k] = v - } - - return result -} diff --git a/pkg/machinery/resources/k8s/static_pod_status.go b/pkg/machinery/resources/k8s/static_pod_status.go index b2aed1600..0beea552f 100644 --- a/pkg/machinery/resources/k8s/static_pod_status.go +++ b/pkg/machinery/resources/k8s/static_pod_status.go @@ -21,13 +21,6 @@ type StaticPodStatusSpec struct { PodStatus map[string]interface{} } -// DeepCopy implements typed.DeepCopyable interface. -func (spec StaticPodStatusSpec) DeepCopy() StaticPodStatusSpec { - return StaticPodStatusSpec{ - PodStatus: copyMap(spec.PodStatus), - } -} - // MarshalYAML implements yaml.Marshaler. func (spec StaticPodStatusSpec) MarshalYAML() (interface{}, error) { return spec.PodStatus, nil diff --git a/pkg/machinery/resources/kubespan/config.go b/pkg/machinery/resources/kubespan/config.go index b608c0bb7..4a75a0d5a 100644 --- a/pkg/machinery/resources/kubespan/config.go +++ b/pkg/machinery/resources/kubespan/config.go @@ -12,6 +12,9 @@ import ( "github.com/talos-systems/talos/pkg/machinery/resources/config" ) +//nolint:lll +//go:generate deep-copy -type ConfigSpec -type EndpointSpec -type IdentitySpec -type PeerSpecSpec -type PeerStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // ConfigType is type of Config resource. const ConfigType = resource.Type("KubeSpanConfigs.kubespan.talos.dev") @@ -30,9 +33,6 @@ type ConfigSpec struct { ForceRouting bool `yaml:"forceRouting"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec ConfigSpec) DeepCopy() ConfigSpec { return spec } - // NewConfig initializes a Config resource. func NewConfig(namespace resource.Namespace, id resource.ID) *Config { return typed.NewResource[ConfigSpec, ConfigRD]( diff --git a/pkg/machinery/resources/kubespan/deep_copy.generated.go b/pkg/machinery/resources/kubespan/deep_copy.generated.go new file mode 100644 index 000000000..026717822 --- /dev/null +++ b/pkg/machinery/resources/kubespan/deep_copy.generated.go @@ -0,0 +1,49 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type ConfigSpec -type EndpointSpec -type IdentitySpec -type PeerSpecSpec -type PeerStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package kubespan + +import ( + "inet.af/netaddr" +) + +// DeepCopy generates a deep copy of ConfigSpec. +func (o ConfigSpec) DeepCopy() ConfigSpec { + var cp ConfigSpec = o + return cp +} + +// DeepCopy generates a deep copy of EndpointSpec. +func (o EndpointSpec) DeepCopy() EndpointSpec { + var cp EndpointSpec = o + return cp +} + +// DeepCopy generates a deep copy of IdentitySpec. +func (o IdentitySpec) DeepCopy() IdentitySpec { + var cp IdentitySpec = o + return cp +} + +// DeepCopy generates a deep copy of PeerSpecSpec. +func (o PeerSpecSpec) DeepCopy() PeerSpecSpec { + var cp PeerSpecSpec = o + if o.AllowedIPs != nil { + cp.AllowedIPs = make([]netaddr.IPPrefix, len(o.AllowedIPs)) + copy(cp.AllowedIPs, o.AllowedIPs) + } + if o.Endpoints != nil { + cp.Endpoints = make([]netaddr.IPPort, len(o.Endpoints)) + copy(cp.Endpoints, o.Endpoints) + } + return cp +} + +// DeepCopy generates a deep copy of PeerStatusSpec. +func (o PeerStatusSpec) DeepCopy() PeerStatusSpec { + var cp PeerStatusSpec = o + return cp +} diff --git a/pkg/machinery/resources/kubespan/endpoint.go b/pkg/machinery/resources/kubespan/endpoint.go index 59bd7be54..909ce26fd 100644 --- a/pkg/machinery/resources/kubespan/endpoint.go +++ b/pkg/machinery/resources/kubespan/endpoint.go @@ -25,9 +25,6 @@ type EndpointSpec struct { Endpoint netaddr.IPPort `yaml:"endpoint"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec EndpointSpec) DeepCopy() EndpointSpec { return spec } - // NewEndpoint initializes a Endpoint resource. func NewEndpoint(namespace resource.Namespace, id resource.ID) *Endpoint { return typed.NewResource[EndpointSpec, EndpointRD]( diff --git a/pkg/machinery/resources/kubespan/identity.go b/pkg/machinery/resources/kubespan/identity.go index f9441c610..9ca72c022 100644 --- a/pkg/machinery/resources/kubespan/identity.go +++ b/pkg/machinery/resources/kubespan/identity.go @@ -33,9 +33,6 @@ type IdentitySpec struct { PublicKey string `yaml:"publicKey"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec IdentitySpec) DeepCopy() IdentitySpec { return spec } - // NewIdentity initializes a Identity resource. func NewIdentity(namespace resource.Namespace, id resource.ID) *Identity { return typed.NewResource[IdentitySpec, IdentityRD]( diff --git a/pkg/machinery/resources/kubespan/peer_spec.go b/pkg/machinery/resources/kubespan/peer_spec.go index c55e71ce4..3508bef69 100644 --- a/pkg/machinery/resources/kubespan/peer_spec.go +++ b/pkg/machinery/resources/kubespan/peer_spec.go @@ -27,16 +27,6 @@ type PeerSpecSpec struct { Label string `yaml:"label"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec PeerSpecSpec) DeepCopy() PeerSpecSpec { - return PeerSpecSpec{ - Address: spec.Address, - AllowedIPs: append([]netaddr.IPPrefix(nil), spec.AllowedIPs...), - Endpoints: append([]netaddr.IPPort(nil), spec.Endpoints...), - Label: spec.Label, - } -} - // NewPeerSpec initializes a PeerSpec resource. func NewPeerSpec(namespace resource.Namespace, id resource.ID) *PeerSpec { return typed.NewResource[PeerSpecSpec, PeerSpecRD]( diff --git a/pkg/machinery/resources/kubespan/peer_status.go b/pkg/machinery/resources/kubespan/peer_status.go index d50302183..a92595c45 100644 --- a/pkg/machinery/resources/kubespan/peer_status.go +++ b/pkg/machinery/resources/kubespan/peer_status.go @@ -39,9 +39,6 @@ type PeerStatusSpec struct { LastEndpointChange time.Time `yaml:"lastEndpointChange"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec PeerStatusSpec) DeepCopy() PeerStatusSpec { return spec } - // NewPeerStatus initializes a PeerStatus resource. func NewPeerStatus(namespace resource.Namespace, id resource.ID) *PeerStatus { return typed.NewResource[PeerStatusSpec, PeerStatusRD]( diff --git a/pkg/machinery/resources/network/address_spec.go b/pkg/machinery/resources/network/address_spec.go index 26bdf7dda..7463b0c44 100644 --- a/pkg/machinery/resources/network/address_spec.go +++ b/pkg/machinery/resources/network/address_spec.go @@ -13,6 +13,9 @@ import ( "github.com/talos-systems/talos/pkg/machinery/nethelpers" ) +//nolint:lll +//go:generate deep-copy -type AddressSpecSpec -type AddressStatusSpec -type HardwareAddrSpec -type HostnameSpecSpec -type HostnameStatusSpec -type LinkRefreshSpec -type LinkSpecSpec -type LinkStatusSpec -type NodeAddressSpec -type NodeAddressFilterSpec -type OperatorSpecSpec -type ResolverSpecSpec -type ResolverStatusSpec -type RouteSpecSpec -type RouteStatusSpec -type StatusSpec -type TimeServerSpecSpec -type TimeServerStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // AddressSpecType is type of AddressSpec resource. const AddressSpecType = resource.Type("AddressSpecs.net.talos.dev") @@ -30,11 +33,6 @@ type AddressSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of AddressSpecSpec. -func (spec AddressSpecSpec) DeepCopy() AddressSpecSpec { - return spec -} - // NewAddressSpec initializes a AddressSpec resource. func NewAddressSpec(namespace resource.Namespace, id resource.ID) *AddressSpec { return typed.NewResource[AddressSpecSpec, AddressSpecRD]( diff --git a/pkg/machinery/resources/network/address_status.go b/pkg/machinery/resources/network/address_status.go index dc67c1fe1..524bc46bb 100644 --- a/pkg/machinery/resources/network/address_status.go +++ b/pkg/machinery/resources/network/address_status.go @@ -33,11 +33,6 @@ type AddressStatusSpec struct { Flags nethelpers.AddressFlags `yaml:"flags"` } -// DeepCopy generates a deep copy of AddressStatusSpec. -func (spec AddressStatusSpec) DeepCopy() AddressStatusSpec { - return spec -} - // NewAddressStatus initializes a AddressStatus resource. func NewAddressStatus(namespace resource.Namespace, id resource.ID) *AddressStatus { return typed.NewResource[AddressStatusSpec, AddressStatusRD]( diff --git a/pkg/machinery/resources/network/deep_copy.generated.go b/pkg/machinery/resources/network/deep_copy.generated.go new file mode 100644 index 000000000..992b605d9 --- /dev/null +++ b/pkg/machinery/resources/network/deep_copy.generated.go @@ -0,0 +1,179 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type AddressSpecSpec -type AddressStatusSpec -type HardwareAddrSpec -type HostnameSpecSpec -type HostnameStatusSpec -type LinkRefreshSpec -type LinkSpecSpec -type LinkStatusSpec -type NodeAddressSpec -type NodeAddressFilterSpec -type OperatorSpecSpec -type ResolverSpecSpec -type ResolverStatusSpec -type RouteSpecSpec -type RouteStatusSpec -type StatusSpec -type TimeServerSpecSpec -type TimeServerStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package network + +import ( + "inet.af/netaddr" +) + +// DeepCopy generates a deep copy of AddressSpecSpec. +func (o AddressSpecSpec) DeepCopy() AddressSpecSpec { + var cp AddressSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of AddressStatusSpec. +func (o AddressStatusSpec) DeepCopy() AddressStatusSpec { + var cp AddressStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of HardwareAddrSpec. +func (o HardwareAddrSpec) DeepCopy() HardwareAddrSpec { + var cp HardwareAddrSpec = o + if o.HardwareAddr != nil { + cp.HardwareAddr = make([]byte, len(o.HardwareAddr)) + copy(cp.HardwareAddr, o.HardwareAddr) + } + return cp +} + +// DeepCopy generates a deep copy of HostnameSpecSpec. +func (o HostnameSpecSpec) DeepCopy() HostnameSpecSpec { + var cp HostnameSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of HostnameStatusSpec. +func (o HostnameStatusSpec) DeepCopy() HostnameStatusSpec { + var cp HostnameStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of LinkRefreshSpec. +func (o LinkRefreshSpec) DeepCopy() LinkRefreshSpec { + var cp LinkRefreshSpec = o + return cp +} + +// DeepCopy generates a deep copy of LinkSpecSpec. +func (o LinkSpecSpec) DeepCopy() LinkSpecSpec { + var cp LinkSpecSpec = o + if o.Wireguard.Peers != nil { + cp.Wireguard.Peers = make([]WireguardPeer, len(o.Wireguard.Peers)) + copy(cp.Wireguard.Peers, o.Wireguard.Peers) + for i3 := range o.Wireguard.Peers { + if o.Wireguard.Peers[i3].AllowedIPs != nil { + cp.Wireguard.Peers[i3].AllowedIPs = make([]netaddr.IPPrefix, len(o.Wireguard.Peers[i3].AllowedIPs)) + copy(cp.Wireguard.Peers[i3].AllowedIPs, o.Wireguard.Peers[i3].AllowedIPs) + } + } + } + return cp +} + +// DeepCopy generates a deep copy of LinkStatusSpec. +func (o LinkStatusSpec) DeepCopy() LinkStatusSpec { + var cp LinkStatusSpec = o + if o.HardwareAddr != nil { + cp.HardwareAddr = make([]byte, len(o.HardwareAddr)) + copy(cp.HardwareAddr, o.HardwareAddr) + } + if o.BroadcastAddr != nil { + cp.BroadcastAddr = make([]byte, len(o.BroadcastAddr)) + copy(cp.BroadcastAddr, o.BroadcastAddr) + } + if o.Wireguard.Peers != nil { + cp.Wireguard.Peers = make([]WireguardPeer, len(o.Wireguard.Peers)) + copy(cp.Wireguard.Peers, o.Wireguard.Peers) + for i3 := range o.Wireguard.Peers { + if o.Wireguard.Peers[i3].AllowedIPs != nil { + cp.Wireguard.Peers[i3].AllowedIPs = make([]netaddr.IPPrefix, len(o.Wireguard.Peers[i3].AllowedIPs)) + copy(cp.Wireguard.Peers[i3].AllowedIPs, o.Wireguard.Peers[i3].AllowedIPs) + } + } + } + return cp +} + +// DeepCopy generates a deep copy of NodeAddressSpec. +func (o NodeAddressSpec) DeepCopy() NodeAddressSpec { + var cp NodeAddressSpec = o + if o.Addresses != nil { + cp.Addresses = make([]netaddr.IPPrefix, len(o.Addresses)) + copy(cp.Addresses, o.Addresses) + } + return cp +} + +// DeepCopy generates a deep copy of NodeAddressFilterSpec. +func (o NodeAddressFilterSpec) DeepCopy() NodeAddressFilterSpec { + var cp NodeAddressFilterSpec = o + if o.IncludeSubnets != nil { + cp.IncludeSubnets = make([]netaddr.IPPrefix, len(o.IncludeSubnets)) + copy(cp.IncludeSubnets, o.IncludeSubnets) + } + if o.ExcludeSubnets != nil { + cp.ExcludeSubnets = make([]netaddr.IPPrefix, len(o.ExcludeSubnets)) + copy(cp.ExcludeSubnets, o.ExcludeSubnets) + } + return cp +} + +// DeepCopy generates a deep copy of OperatorSpecSpec. +func (o OperatorSpecSpec) DeepCopy() OperatorSpecSpec { + var cp OperatorSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of ResolverSpecSpec. +func (o ResolverSpecSpec) DeepCopy() ResolverSpecSpec { + var cp ResolverSpecSpec = o + if o.DNSServers != nil { + cp.DNSServers = make([]netaddr.IP, len(o.DNSServers)) + copy(cp.DNSServers, o.DNSServers) + } + return cp +} + +// DeepCopy generates a deep copy of ResolverStatusSpec. +func (o ResolverStatusSpec) DeepCopy() ResolverStatusSpec { + var cp ResolverStatusSpec = o + if o.DNSServers != nil { + cp.DNSServers = make([]netaddr.IP, len(o.DNSServers)) + copy(cp.DNSServers, o.DNSServers) + } + return cp +} + +// DeepCopy generates a deep copy of RouteSpecSpec. +func (o RouteSpecSpec) DeepCopy() RouteSpecSpec { + var cp RouteSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of RouteStatusSpec. +func (o RouteStatusSpec) DeepCopy() RouteStatusSpec { + var cp RouteStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of StatusSpec. +func (o StatusSpec) DeepCopy() StatusSpec { + var cp StatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of TimeServerSpecSpec. +func (o TimeServerSpecSpec) DeepCopy() TimeServerSpecSpec { + var cp TimeServerSpecSpec = o + if o.NTPServers != nil { + cp.NTPServers = make([]string, len(o.NTPServers)) + copy(cp.NTPServers, o.NTPServers) + } + return cp +} + +// DeepCopy generates a deep copy of TimeServerStatusSpec. +func (o TimeServerStatusSpec) DeepCopy() TimeServerStatusSpec { + var cp TimeServerStatusSpec = o + if o.NTPServers != nil { + cp.NTPServers = make([]string, len(o.NTPServers)) + copy(cp.NTPServers, o.NTPServers) + } + return cp +} diff --git a/pkg/machinery/resources/network/hardrware_addr.go b/pkg/machinery/resources/network/hardrware_addr.go index c39225f43..43c8e28f2 100644 --- a/pkg/machinery/resources/network/hardrware_addr.go +++ b/pkg/machinery/resources/network/hardrware_addr.go @@ -30,17 +30,6 @@ type HardwareAddrSpec struct { HardwareAddr nethelpers.HardwareAddr `yaml:"hardwareAddr"` } -// DeepCopy generates a deep copy of HardwareAddrSpec. -func (spec HardwareAddrSpec) DeepCopy() HardwareAddrSpec { - cp := spec - if spec.HardwareAddr != nil { - cp.HardwareAddr = make([]byte, len(spec.HardwareAddr)) - copy(cp.HardwareAddr, spec.HardwareAddr) - } - - return cp -} - // NewHardwareAddr initializes a HardwareAddr resource. func NewHardwareAddr(namespace resource.Namespace, id resource.ID) *HardwareAddr { return typed.NewResource[HardwareAddrSpec, HardwareAddrRD]( diff --git a/pkg/machinery/resources/network/hostname_spec.go b/pkg/machinery/resources/network/hostname_spec.go index 1bf77d795..8f271ca87 100644 --- a/pkg/machinery/resources/network/hostname_spec.go +++ b/pkg/machinery/resources/network/hostname_spec.go @@ -29,11 +29,6 @@ type HostnameSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of HostnameSpecSpec. -func (spec HostnameSpecSpec) DeepCopy() HostnameSpecSpec { - return spec -} - // Validate the hostname. func (spec *HostnameSpecSpec) Validate() error { lenHostname := len(spec.Hostname) diff --git a/pkg/machinery/resources/network/hostname_status.go b/pkg/machinery/resources/network/hostname_status.go index bccd8ee49..2a6caa626 100644 --- a/pkg/machinery/resources/network/hostname_status.go +++ b/pkg/machinery/resources/network/hostname_status.go @@ -22,11 +22,6 @@ type HostnameStatusSpec struct { Domainname string `yaml:"domainname"` } -// DeepCopy generates a deep copy of HostnameSpecSpec. -func (spec HostnameStatusSpec) DeepCopy() HostnameStatusSpec { - return spec -} - // FQDN returns the fully-qualified domain name. func (spec *HostnameStatusSpec) FQDN() string { if spec.Domainname == "" { diff --git a/pkg/machinery/resources/network/link_refresh.go b/pkg/machinery/resources/network/link_refresh.go index a7d41bd00..d82c754d4 100644 --- a/pkg/machinery/resources/network/link_refresh.go +++ b/pkg/machinery/resources/network/link_refresh.go @@ -27,9 +27,6 @@ type LinkRefreshSpec struct { Generation int `yaml:"generation"` } -// DeepCopy implements typed.DeepCopyable interface. -func (s LinkRefreshSpec) DeepCopy() LinkRefreshSpec { return s } - // Bump performs an update. func (s *LinkRefreshSpec) Bump() { s.Generation++ diff --git a/pkg/machinery/resources/network/link_spec.go b/pkg/machinery/resources/network/link_spec.go index 0f1313de2..c700c1ae2 100644 --- a/pkg/machinery/resources/network/link_spec.go +++ b/pkg/machinery/resources/network/link_spec.go @@ -8,7 +8,6 @@ import ( "github.com/cosi-project/runtime/pkg/resource" "github.com/cosi-project/runtime/pkg/resource/meta" "github.com/cosi-project/runtime/pkg/resource/typed" - "inet.af/netaddr" "github.com/talos-systems/talos/pkg/machinery/nethelpers" ) @@ -63,24 +62,6 @@ type BondSlave struct { SlaveIndex int `yaml:"slaveIndex,omitempty"` } -// DeepCopy generates a deep copy of LinkSpecSpec. -func (spec LinkSpecSpec) DeepCopy() LinkSpecSpec { - cp := spec - if spec.Wireguard.Peers != nil { - cp.Wireguard.Peers = make([]WireguardPeer, len(spec.Wireguard.Peers)) - copy(cp.Wireguard.Peers, spec.Wireguard.Peers) - - for i3 := range spec.Wireguard.Peers { - if spec.Wireguard.Peers[i3].AllowedIPs != nil { - cp.Wireguard.Peers[i3].AllowedIPs = make([]netaddr.IPPrefix, len(spec.Wireguard.Peers[i3].AllowedIPs)) - copy(cp.Wireguard.Peers[i3].AllowedIPs, spec.Wireguard.Peers[i3].AllowedIPs) - } - } - } - - return cp -} - // Merge with other, overwriting fields from other if set. // //nolint:gocyclo diff --git a/pkg/machinery/resources/network/link_status.go b/pkg/machinery/resources/network/link_status.go index 644d252b1..0199cc3fb 100644 --- a/pkg/machinery/resources/network/link_status.go +++ b/pkg/machinery/resources/network/link_status.go @@ -8,7 +8,6 @@ import ( "github.com/cosi-project/runtime/pkg/resource" "github.com/cosi-project/runtime/pkg/resource/meta" "github.com/cosi-project/runtime/pkg/resource/typed" - "inet.af/netaddr" "github.com/talos-systems/talos/pkg/machinery/nethelpers" ) @@ -48,34 +47,6 @@ type LinkStatusSpec struct { Wireguard WireguardSpec `yaml:"wireguard,omitempty"` } -// DeepCopy implements typed.DeepCopyable interface. -func (s LinkStatusSpec) DeepCopy() LinkStatusSpec { - cp := s - - if s.HardwareAddr != nil { - cp.HardwareAddr = make([]byte, len(s.HardwareAddr)) - copy(cp.HardwareAddr, s.HardwareAddr) - } - - if s.BroadcastAddr != nil { - cp.BroadcastAddr = make([]byte, len(s.BroadcastAddr)) - copy(cp.BroadcastAddr, s.BroadcastAddr) - } - - if s.Wireguard.Peers != nil { - cp.Wireguard.Peers = append([]WireguardPeer(nil), s.Wireguard.Peers...) - - for i3 := range s.Wireguard.Peers { - if s.Wireguard.Peers[i3].AllowedIPs != nil { - cp.Wireguard.Peers[i3].AllowedIPs = make([]netaddr.IPPrefix, len(s.Wireguard.Peers[i3].AllowedIPs)) - copy(cp.Wireguard.Peers[i3].AllowedIPs, s.Wireguard.Peers[i3].AllowedIPs) - } - } - } - - return cp -} - // Physical checks if the link is physical ethernet. func (s LinkStatusSpec) Physical() bool { return s.Type == nethelpers.LinkEther && s.Kind == "" diff --git a/pkg/machinery/resources/network/node_address.go b/pkg/machinery/resources/network/node_address.go index 64a505b91..4fe3bb8dd 100644 --- a/pkg/machinery/resources/network/node_address.go +++ b/pkg/machinery/resources/network/node_address.go @@ -40,13 +40,6 @@ type NodeAddressSpec struct { Addresses []netaddr.IPPrefix `yaml:"addresses"` } -// DeepCopy generates a deep copy of NodeAddressSpec. -func (spec NodeAddressSpec) DeepCopy() NodeAddressSpec { - return NodeAddressSpec{ - Addresses: append([]netaddr.IPPrefix(nil), spec.Addresses...), - } -} - // NewNodeAddress initializes a NodeAddress resource. func NewNodeAddress(namespace resource.Namespace, id resource.ID) *NodeAddress { return typed.NewResource[NodeAddressSpec, NodeAddressRD]( diff --git a/pkg/machinery/resources/network/node_address_filter.go b/pkg/machinery/resources/network/node_address_filter.go index c137fdc8f..ea8edf6ac 100644 --- a/pkg/machinery/resources/network/node_address_filter.go +++ b/pkg/machinery/resources/network/node_address_filter.go @@ -25,22 +25,6 @@ type NodeAddressFilterSpec struct { ExcludeSubnets []netaddr.IPPrefix `yaml:"excludeSubnets"` } -// DeepCopy generates a deep copy of NodeAddressFilterSpec. -func (spec NodeAddressFilterSpec) DeepCopy() NodeAddressFilterSpec { - cp := spec - if spec.IncludeSubnets != nil { - cp.IncludeSubnets = make([]netaddr.IPPrefix, len(spec.IncludeSubnets)) - copy(cp.IncludeSubnets, spec.IncludeSubnets) - } - - if spec.ExcludeSubnets != nil { - cp.ExcludeSubnets = make([]netaddr.IPPrefix, len(spec.ExcludeSubnets)) - copy(cp.ExcludeSubnets, spec.ExcludeSubnets) - } - - return cp -} - // NewNodeAddressFilter initializes a NodeAddressFilter resource. func NewNodeAddressFilter(namespace resource.Namespace, id resource.ID) *NodeAddressFilter { return typed.NewResource[NodeAddressFilterSpec, NodeAddressFilterRD]( diff --git a/pkg/machinery/resources/network/operator_spec.go b/pkg/machinery/resources/network/operator_spec.go index 2e68d0fb1..12bd00da1 100644 --- a/pkg/machinery/resources/network/operator_spec.go +++ b/pkg/machinery/resources/network/operator_spec.go @@ -30,11 +30,6 @@ type OperatorSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of OperatorSpecSpec. -func (spec OperatorSpecSpec) DeepCopy() OperatorSpecSpec { - return spec -} - // DHCP4OperatorSpec describes DHCP4 operator options. type DHCP4OperatorSpec struct { RouteMetric uint32 `yaml:"routeMetric"` diff --git a/pkg/machinery/resources/network/resolver_spec.go b/pkg/machinery/resources/network/resolver_spec.go index a87f60251..6131fea5a 100644 --- a/pkg/machinery/resources/network/resolver_spec.go +++ b/pkg/machinery/resources/network/resolver_spec.go @@ -26,17 +26,6 @@ type ResolverSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of ResolverSpecSpec. -func (spec ResolverSpecSpec) DeepCopy() ResolverSpecSpec { - cp := spec - if spec.DNSServers != nil { - cp.DNSServers = make([]netaddr.IP, len(spec.DNSServers)) - copy(cp.DNSServers, spec.DNSServers) - } - - return cp -} - // NewResolverSpec initializes a ResolverSpec resource. func NewResolverSpec(namespace resource.Namespace, id resource.ID) *ResolverSpec { return typed.NewResource[ResolverSpecSpec, ResolverSpecRD]( diff --git a/pkg/machinery/resources/network/resolver_status.go b/pkg/machinery/resources/network/resolver_status.go index 95d2b117f..05502ee0e 100644 --- a/pkg/machinery/resources/network/resolver_status.go +++ b/pkg/machinery/resources/network/resolver_status.go @@ -22,17 +22,6 @@ type ResolverStatusSpec struct { DNSServers []netaddr.IP `yaml:"dnsServers"` } -// DeepCopy generates a deep copy of ResolverStatusSpec. -func (spec ResolverStatusSpec) DeepCopy() ResolverStatusSpec { - cp := spec - if spec.DNSServers != nil { - cp.DNSServers = make([]netaddr.IP, len(spec.DNSServers)) - copy(cp.DNSServers, spec.DNSServers) - } - - return cp -} - // NewResolverStatus initializes a ResolverStatus resource. func NewResolverStatus(namespace resource.Namespace, id resource.ID) *ResolverStatus { return typed.NewResource[ResolverStatusSpec, ResolverStatusRD]( diff --git a/pkg/machinery/resources/network/route_spec.go b/pkg/machinery/resources/network/route_spec.go index f8c5cd33e..ddae44e94 100644 --- a/pkg/machinery/resources/network/route_spec.go +++ b/pkg/machinery/resources/network/route_spec.go @@ -35,11 +35,6 @@ type RouteSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of RouteSpecSpec. -func (route RouteSpecSpec) DeepCopy() RouteSpecSpec { - return route -} - var ( zero16 = netaddr.MustParseIP("::") zero4 = netaddr.MustParseIP("0.0.0.0") diff --git a/pkg/machinery/resources/network/route_status.go b/pkg/machinery/resources/network/route_status.go index 526846866..6d2debbf0 100644 --- a/pkg/machinery/resources/network/route_status.go +++ b/pkg/machinery/resources/network/route_status.go @@ -35,11 +35,6 @@ type RouteStatusSpec struct { Protocol nethelpers.RouteProtocol `yaml:"protocol"` } -// DeepCopy generates a deep copy of RouteStatusSpec. -func (spec RouteStatusSpec) DeepCopy() RouteStatusSpec { - return spec -} - // NewRouteStatus initializes a RouteStatus resource. func NewRouteStatus(namespace resource.Namespace, id resource.ID) *RouteStatus { return typed.NewResource[RouteStatusSpec, RouteStatusRD]( diff --git a/pkg/machinery/resources/network/status.go b/pkg/machinery/resources/network/status.go index 265d88f6d..c8767cf54 100644 --- a/pkg/machinery/resources/network/status.go +++ b/pkg/machinery/resources/network/status.go @@ -24,11 +24,6 @@ type StatusSpec struct { EtcFilesReady bool `yaml:"etcFilesReady"` } -// DeepCopy generates a deep copy of StatusSpec. -func (spec StatusSpec) DeepCopy() StatusSpec { - return spec -} - // StatusID is the resource ID of the singleton instance. const StatusID resource.ID = "status" diff --git a/pkg/machinery/resources/network/timeserver_spec.go b/pkg/machinery/resources/network/timeserver_spec.go index 98cd4490b..115302ec7 100644 --- a/pkg/machinery/resources/network/timeserver_spec.go +++ b/pkg/machinery/resources/network/timeserver_spec.go @@ -25,17 +25,6 @@ type TimeServerSpecSpec struct { ConfigLayer ConfigLayer `yaml:"layer"` } -// DeepCopy generates a deep copy of TimeServerSpecSpec. -func (spec TimeServerSpecSpec) DeepCopy() TimeServerSpecSpec { - cp := spec - if spec.NTPServers != nil { - cp.NTPServers = make([]string, len(spec.NTPServers)) - copy(cp.NTPServers, spec.NTPServers) - } - - return cp -} - // NewTimeServerSpec initializes a TimeServerSpec resource. func NewTimeServerSpec(namespace resource.Namespace, id resource.ID) *TimeServerSpec { return typed.NewResource[TimeServerSpecSpec, TimeServerSpecRD]( diff --git a/pkg/machinery/resources/network/timeserver_status.go b/pkg/machinery/resources/network/timeserver_status.go index 04889d1c5..6159f502b 100644 --- a/pkg/machinery/resources/network/timeserver_status.go +++ b/pkg/machinery/resources/network/timeserver_status.go @@ -21,17 +21,6 @@ type TimeServerStatusSpec struct { NTPServers []string `yaml:"timeServers"` } -// DeepCopy generates a deep copy of TimeServerStatusSpec. -func (spec TimeServerStatusSpec) DeepCopy() TimeServerStatusSpec { - cp := spec - if spec.NTPServers != nil { - cp.NTPServers = make([]string, len(spec.NTPServers)) - copy(cp.NTPServers, spec.NTPServers) - } - - return cp -} - // NewTimeServerStatus initializes a TimeServerStatus resource. func NewTimeServerStatus(namespace resource.Namespace, id resource.ID) *TimeServerStatus { return typed.NewResource[TimeServerStatusSpec, TimeServerStatusRD]( diff --git a/pkg/machinery/resources/perf/cpu.go b/pkg/machinery/resources/perf/cpu.go index fe1af3748..bde542e0f 100644 --- a/pkg/machinery/resources/perf/cpu.go +++ b/pkg/machinery/resources/perf/cpu.go @@ -10,6 +10,9 @@ import ( "github.com/cosi-project/runtime/pkg/resource/typed" ) +//nolint:lll +//go:generate deep-copy -type CPUSpec -type MemorySpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // CPUType is type of Etcd resource. const CPUType = resource.Type("CPUStats.perf.talos.dev") @@ -53,11 +56,6 @@ func NewCPU() *CPU { ) } -// DeepCopy implements typed.Deepcopyable interface. -func (spec CPUSpec) DeepCopy() CPUSpec { - return spec -} - // CPURD is an auxiliary type for CPU resource. type CPURD struct{} diff --git a/pkg/machinery/resources/perf/deep_copy.generated.go b/pkg/machinery/resources/perf/deep_copy.generated.go new file mode 100644 index 000000000..36efe29ef --- /dev/null +++ b/pkg/machinery/resources/perf/deep_copy.generated.go @@ -0,0 +1,23 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type CPUSpec -type MemorySpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package perf + +// DeepCopy generates a deep copy of CPUSpec. +func (o CPUSpec) DeepCopy() CPUSpec { + var cp CPUSpec = o + if o.CPU != nil { + cp.CPU = make([]CPUStat, len(o.CPU)) + copy(cp.CPU, o.CPU) + } + return cp +} + +// DeepCopy generates a deep copy of MemorySpec. +func (o MemorySpec) DeepCopy() MemorySpec { + var cp MemorySpec = o + return cp +} diff --git a/pkg/machinery/resources/perf/mem.go b/pkg/machinery/resources/perf/mem.go index a87bbf7fa..404204306 100644 --- a/pkg/machinery/resources/perf/mem.go +++ b/pkg/machinery/resources/perf/mem.go @@ -79,11 +79,6 @@ func NewMemory() *Memory { ) } -// DeepCopy implements typed.Deepcopyable interface. -func (spec MemorySpec) DeepCopy() MemorySpec { - return spec -} - // MemoryRD is an auxiliary type for Memory resource. type MemoryRD struct{} diff --git a/pkg/machinery/resources/runtime/deep_copy.generated.go b/pkg/machinery/resources/runtime/deep_copy.generated.go new file mode 100644 index 000000000..1ee5bf231 --- /dev/null +++ b/pkg/machinery/resources/runtime/deep_copy.generated.go @@ -0,0 +1,35 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type KernelModuleSpecSpec -type KernelParamSpecSpec -type KernelParamStatusSpec -type MountStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package runtime + +// DeepCopy generates a deep copy of KernelModuleSpecSpec. +func (o KernelModuleSpecSpec) DeepCopy() KernelModuleSpecSpec { + var cp KernelModuleSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of KernelParamSpecSpec. +func (o KernelParamSpecSpec) DeepCopy() KernelParamSpecSpec { + var cp KernelParamSpecSpec = o + return cp +} + +// DeepCopy generates a deep copy of KernelParamStatusSpec. +func (o KernelParamStatusSpec) DeepCopy() KernelParamStatusSpec { + var cp KernelParamStatusSpec = o + return cp +} + +// DeepCopy generates a deep copy of MountStatusSpec. +func (o MountStatusSpec) DeepCopy() MountStatusSpec { + var cp MountStatusSpec = o + if o.Options != nil { + cp.Options = make([]string, len(o.Options)) + copy(cp.Options, o.Options) + } + return cp +} diff --git a/pkg/machinery/resources/runtime/extension_status.go b/pkg/machinery/resources/runtime/extension_status.go index 8e3102913..b0e4bf1d2 100644 --- a/pkg/machinery/resources/runtime/extension_status.go +++ b/pkg/machinery/resources/runtime/extension_status.go @@ -12,6 +12,9 @@ import ( "github.com/talos-systems/talos/pkg/machinery/extensions" ) +//nolint:lll +//go:generate deep-copy -type KernelModuleSpecSpec -type KernelParamSpecSpec -type KernelParamStatusSpec -type MountStatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // ExtensionStatusType is type of Extension resource. const ExtensionStatusType = resource.Type("ExtensionStatuses.runtime.talos.dev") diff --git a/pkg/machinery/resources/runtime/kernel_module_spec.go b/pkg/machinery/resources/runtime/kernel_module_spec.go index aebc2c3ac..7dcea30b0 100644 --- a/pkg/machinery/resources/runtime/kernel_module_spec.go +++ b/pkg/machinery/resources/runtime/kernel_module_spec.go @@ -30,11 +30,6 @@ func NewKernelModuleSpec(namespace resource.Namespace, id resource.ID) *KernelMo ) } -// DeepCopy implements typed.DeepCopyable interface. -func (spec KernelModuleSpecSpec) DeepCopy() KernelModuleSpecSpec { - return spec -} - // KernelModuleSpecRD is auxiliary resource data for KernelModuleSpec. type KernelModuleSpecRD struct{} diff --git a/pkg/machinery/resources/runtime/kernel_params_spec.go b/pkg/machinery/resources/runtime/kernel_params_spec.go index 8054ba4c3..490ec19b2 100644 --- a/pkg/machinery/resources/runtime/kernel_params_spec.go +++ b/pkg/machinery/resources/runtime/kernel_params_spec.go @@ -35,11 +35,6 @@ type KernelParamSpecSpec struct { IgnoreErrors bool `yaml:"ignoreErrors"` } -// DeepCopy implements typed.DeepCopyable interface. -func (spec KernelParamSpecSpec) DeepCopy() KernelParamSpecSpec { - return spec -} - // NewKernelParamSpec initializes a KernelParamSpec resource. func NewKernelParamSpec(namespace resource.Namespace, id resource.ID) *KernelParamSpec { return typed.NewResource[KernelParamSpecSpec, KernelParamSpecRD]( diff --git a/pkg/machinery/resources/runtime/kernel_params_status.go b/pkg/machinery/resources/runtime/kernel_params_status.go index 1c2d0cf90..2d1b08a13 100644 --- a/pkg/machinery/resources/runtime/kernel_params_status.go +++ b/pkg/machinery/resources/runtime/kernel_params_status.go @@ -31,11 +31,6 @@ func NewKernelParamStatus(namespace resource.Namespace, id resource.ID) *KernelP ) } -// DeepCopy implements typed.DeepCopyable interface. -func (spec KernelParamStatusSpec) DeepCopy() KernelParamStatusSpec { - return spec -} - // KernelParamStatusRD is auxiliary resource data for KernelParamStatus. type KernelParamStatusRD struct{} diff --git a/pkg/machinery/resources/runtime/mount_status.go b/pkg/machinery/resources/runtime/mount_status.go index 0a8fff0b3..a39525c54 100644 --- a/pkg/machinery/resources/runtime/mount_status.go +++ b/pkg/machinery/resources/runtime/mount_status.go @@ -32,11 +32,6 @@ func NewMountStatus(namespace resource.Namespace, id resource.ID) *MountStatus { ) } -// DeepCopy implements typed.DeepCopyable interface. -func (spec MountStatusSpec) DeepCopy() MountStatusSpec { - return spec -} - // MountStatusRD is auxiliary resource data for MountStatus. type MountStatusRD struct{} diff --git a/pkg/machinery/resources/secrets/api.go b/pkg/machinery/resources/secrets/api.go index f79d75094..d92d6001c 100644 --- a/pkg/machinery/resources/secrets/api.go +++ b/pkg/machinery/resources/secrets/api.go @@ -15,6 +15,9 @@ import ( "github.com/talos-systems/talos/pkg/machinery/proto" ) +//nolint:lll +//go:generate deep-copy -type APICertsSpec -type CertSANSpec -type EtcdCertsSpec -type EtcdRootSpec -type KubeletSpec -type KubernetesCertsSpec -type KubernetesRootSpec -type OSRootSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // APIType is type of API resource. const APIType = resource.Type("ApiCertificates.secrets.talos.dev") @@ -81,11 +84,6 @@ func (spec *APICertsSpec) UnmarshalProto(protoBytes []byte) error { return nil } -// DeepCopy implements the DeepCopyable interface. -func (spec APICertsSpec) DeepCopy() APICertsSpec { - return spec -} - // APIRD provides auxiliary methods for API. type APIRD struct{} diff --git a/pkg/machinery/resources/secrets/cert_sans.go b/pkg/machinery/resources/secrets/cert_sans.go index 7266b3d27..ec3935453 100644 --- a/pkg/machinery/resources/secrets/cert_sans.go +++ b/pkg/machinery/resources/secrets/cert_sans.go @@ -54,15 +54,6 @@ func (CertSANRD) ResourceDefinition(resource.Metadata, CertSANSpec) meta.Resourc } } -// DeepCopy implements DeepCopyable. -func (spec CertSANSpec) DeepCopy() CertSANSpec { - return CertSANSpec{ - IPs: append([]netaddr.IP(nil), spec.IPs...), - DNSNames: append([]string(nil), spec.DNSNames...), - FQDN: spec.FQDN, - } -} - // Reset the list of SANs. func (spec *CertSANSpec) Reset() { spec.DNSNames = nil diff --git a/pkg/machinery/resources/secrets/deep_copy.generated.go b/pkg/machinery/resources/secrets/deep_copy.generated.go new file mode 100644 index 000000000..71c2ea2c2 --- /dev/null +++ b/pkg/machinery/resources/secrets/deep_copy.generated.go @@ -0,0 +1,155 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type APICertsSpec -type CertSANSpec -type EtcdCertsSpec -type EtcdRootSpec -type KubeletSpec -type KubernetesCertsSpec -type KubernetesRootSpec -type OSRootSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package secrets + +import ( + "inet.af/netaddr" + "net" + "net/url" +) + +// DeepCopy generates a deep copy of APICertsSpec. +func (o APICertsSpec) DeepCopy() APICertsSpec { + var cp APICertsSpec = o + if o.CA != nil { + cp.CA = o.CA.DeepCopy() + } + if o.Client != nil { + cp.Client = o.Client.DeepCopy() + } + if o.Server != nil { + cp.Server = o.Server.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of CertSANSpec. +func (o CertSANSpec) DeepCopy() CertSANSpec { + var cp CertSANSpec = o + if o.IPs != nil { + cp.IPs = make([]netaddr.IP, len(o.IPs)) + copy(cp.IPs, o.IPs) + } + if o.DNSNames != nil { + cp.DNSNames = make([]string, len(o.DNSNames)) + copy(cp.DNSNames, o.DNSNames) + } + return cp +} + +// DeepCopy generates a deep copy of EtcdCertsSpec. +func (o EtcdCertsSpec) DeepCopy() EtcdCertsSpec { + var cp EtcdCertsSpec = o + if o.Etcd != nil { + cp.Etcd = o.Etcd.DeepCopy() + } + if o.EtcdPeer != nil { + cp.EtcdPeer = o.EtcdPeer.DeepCopy() + } + if o.EtcdAdmin != nil { + cp.EtcdAdmin = o.EtcdAdmin.DeepCopy() + } + if o.EtcdAPIServer != nil { + cp.EtcdAPIServer = o.EtcdAPIServer.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of EtcdRootSpec. +func (o EtcdRootSpec) DeepCopy() EtcdRootSpec { + var cp EtcdRootSpec = o + if o.EtcdCA != nil { + cp.EtcdCA = o.EtcdCA.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of KubeletSpec. +func (o KubeletSpec) DeepCopy() KubeletSpec { + var cp KubeletSpec = o + if o.Endpoint != nil { + cp.Endpoint = new(url.URL) + *cp.Endpoint = *o.Endpoint + if o.Endpoint.User != nil { + cp.Endpoint.User = new(url.Userinfo) + *cp.Endpoint.User = *o.Endpoint.User + } + } + if o.CA != nil { + cp.CA = o.CA.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of KubernetesCertsSpec. +func (o KubernetesCertsSpec) DeepCopy() KubernetesCertsSpec { + var cp KubernetesCertsSpec = o + if o.APIServer != nil { + cp.APIServer = o.APIServer.DeepCopy() + } + if o.APIServerKubeletClient != nil { + cp.APIServerKubeletClient = o.APIServerKubeletClient.DeepCopy() + } + if o.FrontProxy != nil { + cp.FrontProxy = o.FrontProxy.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of KubernetesRootSpec. +func (o KubernetesRootSpec) DeepCopy() KubernetesRootSpec { + var cp KubernetesRootSpec = o + if o.Endpoint != nil { + cp.Endpoint = new(url.URL) + *cp.Endpoint = *o.Endpoint + if o.Endpoint.User != nil { + cp.Endpoint.User = new(url.Userinfo) + *cp.Endpoint.User = *o.Endpoint.User + } + } + if o.CertSANs != nil { + cp.CertSANs = make([]string, len(o.CertSANs)) + copy(cp.CertSANs, o.CertSANs) + } + if o.APIServerIPs != nil { + cp.APIServerIPs = make([]net.IP, len(o.APIServerIPs)) + copy(cp.APIServerIPs, o.APIServerIPs) + for i2 := range o.APIServerIPs { + if o.APIServerIPs[i2] != nil { + cp.APIServerIPs[i2] = make([]byte, len(o.APIServerIPs[i2])) + copy(cp.APIServerIPs[i2], o.APIServerIPs[i2]) + } + } + } + if o.CA != nil { + cp.CA = o.CA.DeepCopy() + } + if o.ServiceAccount != nil { + cp.ServiceAccount = o.ServiceAccount.DeepCopy() + } + if o.AggregatorCA != nil { + cp.AggregatorCA = o.AggregatorCA.DeepCopy() + } + return cp +} + +// DeepCopy generates a deep copy of OSRootSpec. +func (o OSRootSpec) DeepCopy() OSRootSpec { + var cp OSRootSpec = o + if o.CA != nil { + cp.CA = o.CA.DeepCopy() + } + if o.CertSANIPs != nil { + cp.CertSANIPs = make([]netaddr.IP, len(o.CertSANIPs)) + copy(cp.CertSANIPs, o.CertSANIPs) + } + if o.CertSANDNSNames != nil { + cp.CertSANDNSNames = make([]string, len(o.CertSANDNSNames)) + copy(cp.CertSANDNSNames, o.CertSANDNSNames) + } + return cp +} diff --git a/pkg/machinery/resources/secrets/etcd.go b/pkg/machinery/resources/secrets/etcd.go index cb4f0f149..3f781e5bc 100644 --- a/pkg/machinery/resources/secrets/etcd.go +++ b/pkg/machinery/resources/secrets/etcd.go @@ -36,11 +36,6 @@ func NewEtcd() *Etcd { ) } -// DeepCopy implements the DeepCopyable interface. -func (s EtcdCertsSpec) DeepCopy() EtcdCertsSpec { - return s -} - // EtcdRD provides auxiliary methods for Etcd. type EtcdRD struct{} diff --git a/pkg/machinery/resources/secrets/etcd_root.go b/pkg/machinery/resources/secrets/etcd_root.go index a18ce72ad..d4d1a8328 100644 --- a/pkg/machinery/resources/secrets/etcd_root.go +++ b/pkg/machinery/resources/secrets/etcd_root.go @@ -33,11 +33,6 @@ func NewEtcdRoot(id resource.ID) *EtcdRoot { ) } -// DeepCopy implements the DeepCopyable interface. -func (s EtcdRootSpec) DeepCopy() EtcdRootSpec { - return s -} - // EtcdRootRD provides auxiliary methods for EtcdRoot. type EtcdRootRD struct{} diff --git a/pkg/machinery/resources/secrets/kubelet.go b/pkg/machinery/resources/secrets/kubelet.go index 721b7a0e2..6ba32f771 100644 --- a/pkg/machinery/resources/secrets/kubelet.go +++ b/pkg/machinery/resources/secrets/kubelet.go @@ -40,11 +40,6 @@ func NewKubelet(id resource.ID) *Kubelet { ) } -// DeepCopy implements the DeepCopyable interface. -func (s KubeletSpec) DeepCopy() KubeletSpec { - return s -} - // KubeletRD provides auxiliary methods for Kubelet. type KubeletRD struct{} diff --git a/pkg/machinery/resources/secrets/kubernetes.go b/pkg/machinery/resources/secrets/kubernetes.go index 3dec6add6..b0fcc050f 100644 --- a/pkg/machinery/resources/secrets/kubernetes.go +++ b/pkg/machinery/resources/secrets/kubernetes.go @@ -42,11 +42,6 @@ func NewKubernetes() *Kubernetes { ) } -// DeepCopy implements the DeepCopyable interface. -func (s KubernetesCertsSpec) DeepCopy() KubernetesCertsSpec { - return s -} - // KubernetesRD provides auxiliary methods for Kubernetes. type KubernetesRD struct{} diff --git a/pkg/machinery/resources/secrets/kubernetes_root.go b/pkg/machinery/resources/secrets/kubernetes_root.go index dbd724a9f..bf4d322e0 100644 --- a/pkg/machinery/resources/secrets/kubernetes_root.go +++ b/pkg/machinery/resources/secrets/kubernetes_root.go @@ -49,11 +49,6 @@ func NewKubernetesRoot(id resource.ID) *KubernetesRoot { ) } -// DeepCopy implements the DeepCopyable interface. -func (spec KubernetesRootSpec) DeepCopy() KubernetesRootSpec { - return spec -} - // KubernetesRootRD provides auxiliary methods for KubernetesRoot. type KubernetesRootRD struct{} diff --git a/pkg/machinery/resources/secrets/os_root.go b/pkg/machinery/resources/secrets/os_root.go index b08b1544d..4674011b0 100644 --- a/pkg/machinery/resources/secrets/os_root.go +++ b/pkg/machinery/resources/secrets/os_root.go @@ -38,11 +38,6 @@ func NewOSRoot(id resource.ID) *OSRoot { ) } -// DeepCopy implements the DeepCopyable interface. -func (spec OSRootSpec) DeepCopy() OSRootSpec { - return spec -} - // OSRootRD provides auxiliary methods for OSRoot. type OSRootRD struct{} diff --git a/pkg/machinery/resources/time/deep_copy.generated.go b/pkg/machinery/resources/time/deep_copy.generated.go new file mode 100644 index 000000000..8375953be --- /dev/null +++ b/pkg/machinery/resources/time/deep_copy.generated.go @@ -0,0 +1,13 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type StatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package time + +// DeepCopy generates a deep copy of StatusSpec. +func (o StatusSpec) DeepCopy() StatusSpec { + var cp StatusSpec = o + return cp +} diff --git a/pkg/machinery/resources/time/status.go b/pkg/machinery/resources/time/status.go index 6b5f8f2c8..9efb7fa8f 100644 --- a/pkg/machinery/resources/time/status.go +++ b/pkg/machinery/resources/time/status.go @@ -12,6 +12,9 @@ import ( "github.com/talos-systems/talos/pkg/machinery/resources/v1alpha1" ) +//nolint:lll +//go:generate deep-copy -type StatusSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // StatusType is type of TimeSync resource. const StatusType = resource.Type("TimeStatuses.v1alpha1.talos.dev") @@ -41,11 +44,6 @@ func NewStatus() *Status { ) } -// DeepCopy implements the DeepCopyable interface. -func (s StatusSpec) DeepCopy() StatusSpec { - return s -} - // StatusRD provides auxiliary methods for Status. type StatusRD struct{} diff --git a/pkg/machinery/resources/v1alpha1/deep_copy.generated.go b/pkg/machinery/resources/v1alpha1/deep_copy.generated.go new file mode 100644 index 000000000..06c3bd8f7 --- /dev/null +++ b/pkg/machinery/resources/v1alpha1/deep_copy.generated.go @@ -0,0 +1,13 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Code generated by "deep-copy -type ServiceSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go ."; DO NOT EDIT. + +package v1alpha1 + +// DeepCopy generates a deep copy of ServiceSpec. +func (o ServiceSpec) DeepCopy() ServiceSpec { + var cp ServiceSpec = o + return cp +} diff --git a/pkg/machinery/resources/v1alpha1/service.go b/pkg/machinery/resources/v1alpha1/service.go index 6a4adf483..0001328e2 100644 --- a/pkg/machinery/resources/v1alpha1/service.go +++ b/pkg/machinery/resources/v1alpha1/service.go @@ -10,6 +10,9 @@ import ( "github.com/cosi-project/runtime/pkg/resource/typed" ) +//nolint:lll +//go:generate deep-copy -type ServiceSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go . + // ServiceType is type of Service resource. const ServiceType = resource.Type("Services.v1alpha1.talos.dev") @@ -31,11 +34,6 @@ func NewService(id resource.ID) *Service { ) } -// DeepCopy implements the DeepCopyable interface. -func (s ServiceSpec) DeepCopy() ServiceSpec { - return s -} - // ServiceRD provides auxiliary methods for Service. type ServiceRD struct{}