Found a cleaner way to ignore the unknown fields

This commit is contained in:
darthhexx 2022-12-09 17:20:12 +10:00 коммит произвёл Petr Kotas
Родитель b05945a9ae
Коммит 4fba704abb
8 изменённых файлов: 11 добавлений и 75 удалений

Просмотреть файл

@ -61,7 +61,7 @@ func (m *manager) fixMCSCert(ctx context.Context) error {
return err
}
err = pg.Get(&rootCA)
err = pg.Get(true, &rootCA)
if err != nil {
return err
}

Просмотреть файл

@ -17,10 +17,13 @@ import (
type PersistedGraph map[string]json.RawMessage
func (pg PersistedGraph) Get(is ...interface{}) error {
func (pg PersistedGraph) Get(disallowUnknownFields bool, is ...interface{}) error {
for _, i := range is {
d := json.NewDecoder(bytes.NewReader(pg[reflect.TypeOf(i).Elem().String()]))
d.DisallowUnknownFields()
if disallowUnknownFields {
d.DisallowUnknownFields()
}
err := d.Decode(i)
if err != nil {

Просмотреть файл

@ -33,7 +33,7 @@ func (m *manager) updateClusterData(ctx context.Context) error {
var installConfig *installconfig.InstallConfig
var kubeadminPassword *password.KubeadminPassword
err = pg.Get(&installConfig, &kubeadminPassword)
err = pg.Get(false, &installConfig, &kubeadminPassword)
if err != nil {
return err
}

Просмотреть файл

@ -96,7 +96,7 @@ func (m *manager) generateKubeconfigs(ctx context.Context) error {
}
var adminInternalClient *kubeconfig.AdminInternalClient
err = pg.Get(&adminInternalClient)
err = pg.Get(true, &adminInternalClient)
if err != nil {
return err
}
@ -127,7 +127,7 @@ func (m *manager) generateKubeconfigs(ctx context.Context) error {
func generateKubeconfig(pg graph.PersistedGraph, commonName string, organization []string, validity time.Duration, internal bool) (*kubeconfig.AdminInternalClient, error) {
var ca *tls.AdminKubeConfigSignerCertKey
var adminInternalClient *kubeconfig.AdminInternalClient
err := pg.Get(&ca, &adminInternalClient)
err := pg.Get(true, &ca, &adminInternalClient)
if err != nil {
return nil, err
}

Просмотреть файл

@ -27,7 +27,7 @@ func (m *manager) deployResourceTemplate(ctx context.Context) error {
var installConfig *installconfig.InstallConfig
var machineMaster *machine.Master
err = pg.Get(&installConfig, &machineMaster)
err = pg.Get(true, &installConfig, &machineMaster)
if err != nil {
return err
}

Просмотреть файл

@ -64,7 +64,7 @@ func (m *manager) initializeKubernetesClients(ctx context.Context) error {
}
var adminInternalClient *kubeconfig.AdminInternalClient
err = pg.Get(&adminInternalClient)
err = pg.Get(true, &adminInternalClient)
if err != nil {
return err
}

48
vendor/github.com/openshift/installer/pkg/types/azure/machinepool.go сгенерированный поставляемый
Просмотреть файл

@ -24,25 +24,6 @@ type MachinePool struct {
//
// +optional
OSDisk `json:"osDisk"`
// ultraSSDCapability defines if the instance should use Ultra SSD disks.
//
// +optional
// +kubebuilder:validation:Enum=Enabled;Disabled
UltraSSDCapability string `json:"ultraSSDCapability,omitempty"`
// VMNetworkingType specifies whether to enable accelerated networking.
// Accelerated networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its
// networking performance.
// eg. values: "Accelerated", "Basic"
//
// +kubebuilder:validation:Enum="Accelerated"; "Basic"
// +optional
VMNetworkingType string `json:"vmNetworkingType,omitempty"`
// OSImage defines the image to use for the OS.
// +optional
OSImage OSImage `json:"osImage,omitempty"`
}
// OSDisk defines the disk for machines on Azure.
@ -62,23 +43,6 @@ type OSDisk struct {
// DiskEncryptionSetID is a resource ID of disk encryption set
// +optional
DiskEncryptionSetID string `json:"diskEncryptionSetId,omitempty"`
// DiskEncryptionSet defines a disk encryption set.
//
// +optional
*DiskEncryptionSet `json:"diskEncryptionSet,omitempty"`
}
// DiskEncryptionSet defines the configuration for a disk encryption set.
type DiskEncryptionSet struct {
// SubscriptionID defines the Azure subscription the disk encryption
// set is in.
SubscriptionID string `json:"subscriptionId,omitempty"`
// ResourceGroup defines the Azure resource group used by the disk
// encryption set.
ResourceGroup string `json:"resourceGroup"`
// Name is the name of the disk encryption set.
Name string `json:"name"`
}
// DefaultDiskType holds the default Azure disk type used by the VMs.
@ -114,15 +78,3 @@ func (a *MachinePool) Set(required *MachinePool) {
a.OSDisk.DiskEncryptionSetID = required.OSDisk.DiskEncryptionSetID
}
}
// OSImage is the image to use for the OS of a machine.
type OSImage struct {
// Publisher is the publisher of the image.
Publisher string `json:"publisher"`
// Offer is the offer of the image.
Offer string `json:"offer"`
// SKU is the SKU of the image.
SKU string `json:"sku"`
// Version is the version of the image.
Version string `json:"version"`
}

19
vendor/github.com/openshift/installer/pkg/types/installconfig.go сгенерированный поставляемый
Просмотреть файл

@ -154,25 +154,6 @@ type InstallConfig struct {
// BootstrapInPlace is the configuration for installing a single node
// with bootstrap in place installation.
BootstrapInPlace *BootstrapInPlace `json:"bootstrapInPlace,omitempty"`
// Capabilities configures the installation of optional core cluster components.
// +optional
Capabilities *Capabilities `json:"capabilities,omitempty"`
}
// Capabilities selects the managed set of optional, core cluster components.
type Capabilities struct {
// baselineCapabilitySet selects an initial set of
// optional capabilities to enable, which can be extended via
// additionalEnabledCapabilities. The default is vCurrent.
// +optional
BaselineCapabilitySet string `json:"baselineCapabilitySet,omitempty"`
// additionalEnabledCapabilities extends the set of managed
// capabilities beyond the baseline defined in
// baselineCapabilitySet. The default is an empty set.
// +optional
AdditionalEnabledCapabilities []string `json:"additionalEnabledCapabilities,omitempty"`
}
// ClusterDomain returns the DNS domain that all records for a cluster must belong to.