diff --git a/data/data/ibmcloud/variables-ibmcloud.tf b/data/data/ibmcloud/variables-ibmcloud.tf index 43d6a1a2064..db57a842144 100644 --- a/data/data/ibmcloud/variables-ibmcloud.tf +++ b/data/data/ibmcloud/variables-ibmcloud.tf @@ -3,9 +3,8 @@ ####################################### variable "ibmcloud_api_key" { - type = string - # TODO: Supported on tf 0.14 - # sensitive = true + type = string + sensitive = true description = "The IAM API key for authenticating with IBM Cloud APIs." } @@ -70,7 +69,7 @@ variable "ibmcloud_vpc_permitted" { variable "ibmcloud_vpc" { type = string description = "The name of an existing cluster VPC." - default = null + default = "" } variable "ibmcloud_control_plane_subnets" { @@ -110,11 +109,6 @@ variable "ibmcloud_publish_strategy" { type = string description = "The cluster publishing strategy, either Internal or External" default = "External" - # TODO: Supported on tf 0.13 - # validation { - # condition = "External" || "Internal" - # error_message = "The ibmcloud_publish_strategy value must be \"External\" or \"Internal\"." - # } } variable "ibmcloud_network_resource_group_name" { diff --git a/pkg/asset/installconfig/ibmcloud/client.go b/pkg/asset/installconfig/ibmcloud/client.go index cf0200d2e27..f69ae34c56a 100644 --- a/pkg/asset/installconfig/ibmcloud/client.go +++ b/pkg/asset/installconfig/ibmcloud/client.go @@ -17,7 +17,6 @@ import ( "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" "github.com/IBM/platform-services-go-sdk/resourcemanagerv2" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud/responses" "github.com/openshift/installer/pkg/types" @@ -91,7 +90,7 @@ func NewClient() (*Client, error) { } if err := client.loadSDKServices(); err != nil { - return nil, errors.Wrap(err, "failed to load IBM SDK services") + return nil, fmt.Errorf("failed to load IBM SDK services: %w", err) } return client, nil @@ -151,7 +150,7 @@ func (c *Client) getInstance(ctx context.Context, crnstr string, iType InstanceT options := c.controllerAPI.NewGetResourceInstanceOptions(crnstr) resourceInstance, _, err := c.controllerAPI.GetResourceInstance(options) if err != nil { - return nil, errors.Wrapf(err, "failed to get %s instances", iType) + return nil, fmt.Errorf("failed to get %s instances: %w", iType, err) } return resourceInstance, nil @@ -195,7 +194,7 @@ func (c *Client) GetDedicatedHostByName(ctx context.Context, name string, region options := c.vpcAPI.NewListDedicatedHostsOptions() dhosts, _, err := c.vpcAPI.ListDedicatedHostsWithContext(ctx, options) if err != nil { - return nil, errors.Wrap(err, "failed to list dedicated hosts") + return nil, fmt.Errorf("failed to list dedicated hosts: %w", err) } for _, dhost := range dhosts.DedicatedHosts { @@ -245,7 +244,7 @@ func (c *Client) GetDNSRecordsByName(ctx context.Context, crnstr string, zoneID Name: core.StringPtr(recordName), }) if err != nil { - return nil, errors.Wrap(err, "could not retrieve DNS records") + return nil, fmt.Errorf("could not retrieve DNS records: %w", err) } return records.Result, nil @@ -284,7 +283,7 @@ func (c *Client) getDNSDNSZones(ctx context.Context) ([]responses.DNSZoneRespons listResourceInstancesResponse, _, err := c.controllerAPI.ListResourceInstances(options) if err != nil { - return nil, errors.Wrap(err, "failed to get dns instance") + return nil, fmt.Errorf("failed to get dns instance: %w", err) } var allZones []responses.DNSZoneResponse @@ -297,7 +296,7 @@ func (c *Client) getDNSDNSZones(ctx context.Context) ([]responses.DNSZoneRespons Authenticator: authenticator, }) if err != nil { - return nil, errors.Wrap(err, "failed to list DNS zones") + return nil, fmt.Errorf("failed to list DNS zones: %w", err) } options := dnsZoneService.NewListDnszonesOptions(*instance.GUID) @@ -332,7 +331,7 @@ func (c *Client) getCISDNSZones(ctx context.Context) ([]responses.DNSZoneRespons listResourceInstancesResponse, _, err := c.controllerAPI.ListResourceInstances(options) if err != nil { - return nil, errors.Wrap(err, "failed to get cis instance") + return nil, fmt.Errorf("failed to get cis instance: %w", err) } var allZones []responses.DNSZoneResponse @@ -347,7 +346,7 @@ func (c *Client) getCISDNSZones(ctx context.Context) ([]responses.DNSZoneRespons Crn: crnstr, }) if err != nil { - return nil, errors.Wrap(err, "failed to list DNS zones") + return nil, fmt.Errorf("failed to list DNS zones: %w", err) } options := zonesService.NewListZonesOptions() @@ -460,7 +459,7 @@ func (c *Client) GetVSIProfiles(ctx context.Context) ([]vpcv1.InstanceProfile, e listInstanceProfilesOptions := c.vpcAPI.NewListInstanceProfilesOptions() profiles, _, err := c.vpcAPI.ListInstanceProfilesWithContext(ctx, listInstanceProfilesOptions) if err != nil { - return nil, errors.Wrap(err, "failed to list vpc vsi profiles") + return nil, fmt.Errorf("failed to list vpc vsi profiles: %w", err) } return profiles.Profiles, nil } @@ -478,7 +477,7 @@ func (c *Client) GetVPC(ctx context.Context, vpcID string) (*vpcv1.VPC, error) { for _, region := range regions { err := c.vpcAPI.SetServiceURL(fmt.Sprintf("%s/v1", *region.Endpoint)) if err != nil { - return nil, errors.Wrap(err, "failed to set vpc api service url") + return nil, fmt.Errorf("failed to set vpc api service url: %w", err) } if vpc, detailedResponse, err := c.vpcAPI.GetVPC(c.vpcAPI.NewGetVPCOptions(vpcID)); err != nil { @@ -500,7 +499,7 @@ func (c *Client) GetVPCs(ctx context.Context, region string) ([]vpcv1.VPC, error err := c.SetVPCServiceURLForRegion(ctx, region) if err != nil { - return nil, errors.Wrap(err, "failed to set vpc api service url") + return nil, fmt.Errorf("failed to set vpc api service url: %w", err) } allVPCs := []vpcv1.VPC{} @@ -527,7 +526,7 @@ func (c *Client) GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC, for _, region := range regions { err := c.vpcAPI.SetServiceURL(fmt.Sprintf("%s/v1", *region.Endpoint)) if err != nil { - return nil, errors.Wrap(err, "failed to set vpc api service url") + return nil, fmt.Errorf("failed to set vpc api service url: %w", err) } vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions()) @@ -569,7 +568,7 @@ func (c *Client) getVPCRegions(ctx context.Context) ([]vpcv1.Region, error) { listRegionsOptions := c.vpcAPI.NewListRegionsOptions() listRegionsResponse, _, err := c.vpcAPI.ListRegionsWithContext(ctx, listRegionsOptions) if err != nil { - return nil, errors.Wrap(err, "failed to list vpc regions") + return nil, fmt.Errorf("failed to list vpc regions: %w", err) } return listRegionsResponse.Regions, nil diff --git a/pkg/asset/installconfig/ibmcloud/dns.go b/pkg/asset/installconfig/ibmcloud/dns.go index cde83e2c6fb..84a69e739de 100644 --- a/pkg/asset/installconfig/ibmcloud/dns.go +++ b/pkg/asset/installconfig/ibmcloud/dns.go @@ -8,7 +8,6 @@ import ( survey "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/core" - "github.com/pkg/errors" "github.com/openshift/installer/pkg/types" ) @@ -34,10 +33,10 @@ func GetDNSZone() (*Zone, error) { // TODO(cjschaef): Consider also offering Internal (DNS) based domains as well publicZones, err := client.GetDNSZones(ctx, types.ExternalPublishingStrategy) if err != nil { - return nil, errors.Wrap(err, "could not retrieve base domains") + return nil, fmt.Errorf("could not retrieve base domains: %w", err) } if len(publicZones) == 0 { - return nil, errors.New("no domain names found in project") + return nil, fmt.Errorf("no domain names found in project") } var options []string @@ -65,12 +64,12 @@ func GetDNSZone() (*Zone, error) { choice := ans.(core.OptionAnswer).Value i := sort.SearchStrings(options, choice) if i == len(publicZones) || options[i] != choice { - return errors.Errorf("invalid base domain %q", choice) + return fmt.Errorf("invalid base domain %q", choice) } return nil }), ); err != nil { - return nil, errors.Wrap(err, "failed UserInput") + return nil, fmt.Errorf("failed UserInput: %w", err) } return optionToZoneMap[zoneChoice], nil diff --git a/pkg/asset/installconfig/ibmcloud/ibmcloud.go b/pkg/asset/installconfig/ibmcloud/ibmcloud.go index 9c8b20a85b8..ae878df415f 100644 --- a/pkg/asset/installconfig/ibmcloud/ibmcloud.go +++ b/pkg/asset/installconfig/ibmcloud/ibmcloud.go @@ -7,7 +7,6 @@ import ( survey "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/core" - "github.com/pkg/errors" "github.com/openshift/installer/pkg/types/ibmcloud" "github.com/openshift/installer/pkg/types/ibmcloud/validation" @@ -64,7 +63,7 @@ func selectRegion() (string, error) { choice := regionTransform(ans).(core.OptionAnswer).Value i := sort.SearchStrings(shortRegions, choice) if i == len(shortRegions) || shortRegions[i] != choice { - return errors.Errorf("invalid region %q", choice) + return fmt.Errorf("invalid region %q", choice) } return nil }), diff --git a/pkg/asset/installconfig/ibmcloud/metadata.go b/pkg/asset/installconfig/ibmcloud/metadata.go index 71913e95758..a7546d046d2 100644 --- a/pkg/asset/installconfig/ibmcloud/metadata.go +++ b/pkg/asset/installconfig/ibmcloud/metadata.go @@ -6,7 +6,6 @@ import ( "sync" "github.com/IBM/go-sdk-core/v5/core" - "github.com/pkg/errors" "github.com/openshift/installer/pkg/types" ) @@ -148,7 +147,7 @@ func (m *Metadata) IsVPCPermittedNetwork(ctx context.Context, vpcName string) (b if m.dnsInstance == nil { _, err := m.DNSInstance(ctx) if err != nil { - return false, errors.Wrap(err, "cannot collect DNS permitted networks without DNS Instance") + return false, fmt.Errorf("cannot collect DNS permitted networks without DNS Instance: %w", err) } } diff --git a/pkg/asset/installconfig/ibmcloud/subnet.go b/pkg/asset/installconfig/ibmcloud/subnet.go index ab6523899c9..422dd6d757f 100644 --- a/pkg/asset/installconfig/ibmcloud/subnet.go +++ b/pkg/asset/installconfig/ibmcloud/subnet.go @@ -2,8 +2,7 @@ package ibmcloud import ( "context" - - "github.com/pkg/errors" + "fmt" ) // Subnet represents an IBM Cloud VPC Subnet @@ -22,31 +21,31 @@ func getSubnets(ctx context.Context, client API, region string, subnetNames []st for _, name := range subnetNames { results, err := client.GetSubnetByName(ctx, name, region) if err != nil { - return nil, errors.Wrapf(err, "getting subnet %s", name) + return nil, fmt.Errorf("getting subnet %s: %w", name, err) } if results.ID == nil { - return nil, errors.Errorf("%s has no ID", name) + return nil, fmt.Errorf("%s has no ID", name) } if results.Ipv4CIDRBlock == nil { - return nil, errors.Errorf("%s has no Ipv4CIDRBlock", *results.ID) + return nil, fmt.Errorf("%s has no Ipv4CIDRBlock", *results.ID) } if results.CRN == nil { - return nil, errors.Errorf("%s has no CRN", *results.ID) + return nil, fmt.Errorf("%s has no CRN", *results.ID) } if results.Name == nil { - return nil, errors.Errorf("%s has no Name", *results.ID) + return nil, fmt.Errorf("%s has no Name", *results.ID) } if results.VPC == nil { - return nil, errors.Errorf("%s has no VPC", *results.ID) + return nil, fmt.Errorf("%s has no VPC", *results.ID) } if results.Zone == nil { - return nil, errors.Errorf("%s has no Zone", *results.ID) + return nil, fmt.Errorf("%s has no Zone", *results.ID) } subnets[*results.ID] = Subnet{ diff --git a/pkg/asset/machines/ibmcloud/machines.go b/pkg/asset/machines/ibmcloud/machines.go index 1af3e5b5e0c..b18ffd77765 100644 --- a/pkg/asset/machines/ibmcloud/machines.go +++ b/pkg/asset/machines/ibmcloud/machines.go @@ -3,7 +3,6 @@ package ibmcloud import ( "fmt" - "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -36,7 +35,7 @@ func Machines(clusterID string, config *types.InstallConfig, subnets map[string] azIndex := int(idx) % len(azs) provider, err := provider(clusterID, platform, subnets, mpool, azIndex, role, userDataSecret) if err != nil { - return nil, errors.Wrap(err, "failed to create provider") + return nil, fmt.Errorf("failed to create provider: %w", err) } machine := machineapi.Machine{ TypeMeta: metav1.TypeMeta{ diff --git a/pkg/asset/machines/ibmcloud/machinesets.go b/pkg/asset/machines/ibmcloud/machinesets.go index d49f7643c7b..32a9ea74923 100644 --- a/pkg/asset/machines/ibmcloud/machinesets.go +++ b/pkg/asset/machines/ibmcloud/machinesets.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -39,7 +38,7 @@ func MachineSets(clusterID string, config *types.InstallConfig, subnets map[stri provider, err := provider(clusterID, platform, subnets, mpool, idx, role, userDataSecret) if err != nil { - return nil, errors.Wrap(err, "failed to create provider") + return nil, fmt.Errorf("failed to create provider: %w", err) } name := fmt.Sprintf("%s-%s-%s", clusterID, pool.Name, strings.TrimPrefix(az, fmt.Sprintf("%s-", platform.Region))) mset := &machineapi.MachineSet{ diff --git a/pkg/destroy/ibmcloud/cloudobjectstorage.go b/pkg/destroy/ibmcloud/cloudobjectstorage.go index 43773a9bbe3..fd85c3a55b3 100644 --- a/pkg/destroy/ibmcloud/cloudobjectstorage.go +++ b/pkg/destroy/ibmcloud/cloudobjectstorage.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" - "github.com/pkg/errors" ) const ( @@ -27,7 +26,7 @@ func (o *ClusterUninstaller) findCOSInstanceReclamation(instance cloudResource) reclamationOptions := o.controllerSvc.NewListReclamationsOptions() resources, _, err := o.controllerSvc.ListReclamationsWithContext(ctx, reclamationOptions) if err != nil { - return nil, errors.Wrapf(err, "Failed listing reclamations for instance %s", instance.name) + return nil, fmt.Errorf("Failed listing reclamations for instance %s: %w", instance.name, err) } o.Logger.Debugf("Checking reclamations that match instance %s", instance.name) @@ -35,7 +34,7 @@ func (o *ClusterUninstaller) findCOSInstanceReclamation(instance cloudResource) getOptions := o.controllerSvc.NewGetResourceInstanceOptions(*reclamation.ResourceInstanceID) cosInstance, _, err := o.controllerSvc.GetResourceInstanceWithContext(ctx, getOptions) if err != nil { - return nil, errors.Wrapf(err, "Failed checking reclamation %s", *reclamation.ResourceInstanceID) + return nil, fmt.Errorf("Failed checking reclamation %s: %w", *reclamation.ResourceInstanceID, err) } if *cosInstance.Name == instance.name { o.Logger.Debugf("Found COS instance reclamation %s - %s", instance.name, *reclamation.ID) @@ -60,7 +59,7 @@ func (o *ClusterUninstaller) reclaimCOSInstanceReclamation(reclamationID string) o.Logger.Debugf("Reclamation not found, it has likely already been reclaimed %s", reclamationID) return nil } - return errors.Wrapf(err, "Failed to reclaim COS instance reclamation %s", reclamationID) + return fmt.Errorf("Failed to reclaim COS instance reclamation %s: %w", reclamationID, err) } o.Logger.Infof("Reclaimed %s", reclamationID) @@ -84,7 +83,7 @@ func (o *ClusterUninstaller) listCOSInstances() (cloudResources, error) { options.SetType("service_instance") resources, _, err := o.controllerSvc.ListResourceInstancesWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list COS instances") + return nil, fmt.Errorf("Failed to list COS instances: %w", err) } result := []cloudResource{} @@ -119,7 +118,7 @@ func (o *ClusterUninstaller) deleteCOSInstance(item cloudResource) error { if details != nil && details.StatusCode == http.StatusNotFound { return nil } - return errors.Wrapf(err, "Failed to delete COS Instance %s", item.name) + return fmt.Errorf("Failed to delete COS Instance %s: %w", item.name, err) } return nil @@ -162,7 +161,7 @@ func (o *ClusterUninstaller) destroyCOSInstances() error { } if items = o.getPendingItems(cosTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } @@ -179,7 +178,7 @@ func (o *ClusterUninstaller) COSInstanceID() (string, error) { } instanceList := cosInstances.list() if len(instanceList) == 0 { - return "", errors.Errorf("COS instance not found") + return "", fmt.Errorf("COS instance not found") } // Locate the installer's COS instance by name. @@ -189,5 +188,5 @@ func (o *ClusterUninstaller) COSInstanceID() (string, error) { return instance.id, nil } } - return "", errors.Errorf("COS instance not found") + return "", fmt.Errorf("COS instance not found") } diff --git a/pkg/destroy/ibmcloud/dedicatedhost.go b/pkg/destroy/ibmcloud/dedicatedhost.go index 1e9bbf64248..a367c02820f 100644 --- a/pkg/destroy/ibmcloud/dedicatedhost.go +++ b/pkg/destroy/ibmcloud/dedicatedhost.go @@ -1,12 +1,12 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const ( @@ -99,7 +99,7 @@ func (o *ClusterUninstaller) deleteDedicatedHost(item cloudResource) error { getOpts := o.vpcSvc.NewGetDedicatedHostOptions(item.id) resource, _, err := o.vpcSvc.GetDedicatedHostWithContext(ctx, getOpts) if err != nil { - return errors.Wrapf(err, "Failed to get dedicated host %q", item.name) + return fmt.Errorf("Failed to get dedicated host %q: %w", item.name, err) } if *resource.InstancePlacementEnabled { @@ -121,7 +121,7 @@ func (o *ClusterUninstaller) deleteDedicatedHost(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete dedicated host %q", item.name) + return fmt.Errorf("Failed to delete dedicated host %q: %w", item.name, err) } return nil @@ -145,7 +145,7 @@ func (o *ClusterUninstaller) deleteDedicatedHostGroup(item cloudResource) error } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete dedicated host group %q", item.name) + return fmt.Errorf("Failed to delete dedicated host group %q: %w", item.name, err) } return nil @@ -162,7 +162,7 @@ func (o *ClusterUninstaller) disableDedicatedHost(item cloudResource) error { }) _, _, err := o.vpcSvc.UpdateDedicatedHostWithContext(ctx, options) if err != nil { - return errors.Wrapf(err, "Failed to disable dedicated host %q", item.name) + return fmt.Errorf("Failed to disable dedicated host %q: %w", item.name, err) } return nil @@ -191,7 +191,7 @@ func (o *ClusterUninstaller) destroyDedicatedHosts() error { } if items = o.getPendingItems(dedicatedHostTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } @@ -219,7 +219,7 @@ func (o *ClusterUninstaller) destroyDedicatedHostGroups() error { } if items = o.getPendingItems(dedicatedHostGroupTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/disk.go b/pkg/destroy/ibmcloud/disk.go index 8405eb6acc1..5e31807961f 100644 --- a/pkg/destroy/ibmcloud/disk.go +++ b/pkg/destroy/ibmcloud/disk.go @@ -1,10 +1,9 @@ package ibmcloud import ( + "fmt" "net/http" "strings" - - "github.com/pkg/errors" ) func (o *ClusterUninstaller) listDisks() ([]cloudResource, error) { @@ -20,7 +19,7 @@ func (o *ClusterUninstaller) listDisks() ([]cloudResource, error) { options.SetLimit(100) resources, _, err := o.vpcSvc.ListVolumesWithContext(ctx, options) if err != nil { - return nil, errors.Wrap(err, "Listing disks failed") + return nil, fmt.Errorf("Listing disks failed: %w", err) } for _, volume := range resources.Volumes { @@ -59,7 +58,7 @@ func (o *ClusterUninstaller) deleteDisk(item cloudResource) error { details, err := o.vpcSvc.DeleteVolumeWithContext(ctx, options) if err != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s", item.name, item.id, item.id) + return fmt.Errorf("Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s: %w", item.name, item.id, item.id, err) } if err != nil && details.StatusCode == http.StatusNotFound { @@ -93,7 +92,7 @@ func (o *ClusterUninstaller) waitForDiskDeletion(item cloudResource) error { o.deletePendingItems(item.typeName, []cloudResource{item}) o.Logger.Infof("Deleted disk %s", item.id) } else { - return errors.Wrapf(err, "Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s", item.name, item.id, item.id) + return fmt.Errorf("Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s: %w", item.name, item.id, item.id, err) } return err @@ -122,7 +121,7 @@ func (o *ClusterUninstaller) destroyDisks() error { } if items = o.getPendingItems("disk"); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/dns.go b/pkg/destroy/ibmcloud/dns.go index 9772177b57d..1826329d843 100644 --- a/pkg/destroy/ibmcloud/dns.go +++ b/pkg/destroy/ibmcloud/dns.go @@ -4,8 +4,6 @@ import ( "fmt" "net/http" "regexp" - - "github.com/pkg/errors" ) const dnsRecordTypeName = "dns record" @@ -31,7 +29,7 @@ func (o *ClusterUninstaller) listCISDNSRecords() (cloudResources, error) { resources, _, err := o.dnsRecordsSvc.ListAllDnsRecordsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list DNS records") + return nil, fmt.Errorf("Failed to list DNS records: %w", err) } for _, record := range resources.Result { @@ -72,7 +70,7 @@ func (o *ClusterUninstaller) listDNSSvcDNSRecords() (cloudResources, error) { resources, _, err := o.dnsServicesSvc.ListResourceRecordsWithContext(ctx, options) if err != nil { - return nil, errors.Wrap(err, "Failed to list DNS records") + return nil, fmt.Errorf("Failed to list DNS records: %w", err) } for _, record := range resources.ResourceRecords { @@ -121,7 +119,7 @@ func (o *ClusterUninstaller) deleteCISDNSRecord(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete DNS record %s", item.name) + return fmt.Errorf("Failed to delete DNS record %s: %w", item.name, err) } return nil @@ -144,7 +142,7 @@ func (o *ClusterUninstaller) deleteDNSSvcDNSRecord(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete DNS record %s", item.name) + return fmt.Errorf("Failed to delete DNS record %s: %w", item.name, err) } return nil } @@ -179,7 +177,7 @@ func (o *ClusterUninstaller) destroyDNSRecords() error { } if items = o.getPendingItems(dnsRecordTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/floatingip.go b/pkg/destroy/ibmcloud/floatingip.go index 2c32e5cb51b..ee9afa9d7a7 100644 --- a/pkg/destroy/ibmcloud/floatingip.go +++ b/pkg/destroy/ibmcloud/floatingip.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const floatingIPTypeName = "floating ip" @@ -20,7 +20,7 @@ func (o *ClusterUninstaller) listFloatingIPs() (cloudResources, error) { resources, _, err := o.vpcSvc.ListFloatingIpsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list floating IPs") + return nil, fmt.Errorf("failed to list floating IPs: %w", err) } result := []cloudResource{} @@ -60,7 +60,7 @@ func (o *ClusterUninstaller) deleteFloatingIP(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete floating IP %s", item.name) + return fmt.Errorf("Failed to delete floating IP %s: %w", item.name, err) } return nil @@ -90,7 +90,7 @@ func (o *ClusterUninstaller) destroyFloatingIPs() error { } if items = o.getPendingItems(floatingIPTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/iam.go b/pkg/destroy/ibmcloud/iam.go index 426eae976b5..292324aa094 100644 --- a/pkg/destroy/ibmcloud/iam.go +++ b/pkg/destroy/ibmcloud/iam.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/platform-services-go-sdk/iampolicymanagementv1" - "github.com/pkg/errors" ) const iamAuthorizationTypeName = "iam authorization" @@ -20,7 +20,7 @@ func (o *ClusterUninstaller) listIAMAuthorizations() (cloudResources, error) { options.SetType("authorization") resources, _, err := o.iamPolicyManagementSvc.ListPoliciesWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list IAM authorizations") + return nil, fmt.Errorf("Failed to list IAM authorizations: %w", err) } result := []cloudResource{} @@ -90,7 +90,7 @@ func (o *ClusterUninstaller) deleteIAMAuthorization(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete IAM authorization %s", item.name) + return fmt.Errorf("Failed to delete IAM authorization %s: %w", item.name, err) } return nil @@ -119,7 +119,7 @@ func (o *ClusterUninstaller) destroyIAMAuthorizations() error { } if items = o.getPendingItems(iamAuthorizationTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/ibmcloud.go b/pkg/destroy/ibmcloud/ibmcloud.go index 326082d9396..c245b91127a 100644 --- a/pkg/destroy/ibmcloud/ibmcloud.go +++ b/pkg/destroy/ibmcloud/ibmcloud.go @@ -18,7 +18,6 @@ import ( "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" "github.com/IBM/platform-services-go-sdk/resourcemanagerv2" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" "github.com/sirupsen/logrus" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/wait" @@ -118,7 +117,7 @@ func (o *ClusterUninstaller) Run() (*types.ClusterQuota, error) { err = o.destroyCluster() if err != nil { - return nil, errors.Wrap(err, "failed to destroy cluster") + return nil, fmt.Errorf("failed to destroy cluster: %w", err) } return nil, nil @@ -292,7 +291,7 @@ func (o *ClusterUninstaller) loadSDKServices() error { } } if zoneID == "" { - return errors.Errorf("Could not determine CIS DNS zone ID from base domain %q", o.BaseDomain) + return fmt.Errorf("Could not determine CIS DNS zone ID from base domain %q", o.BaseDomain) } // DnsRecordsV1 @@ -338,7 +337,7 @@ func (o *ClusterUninstaller) loadSDKServices() error { } } if zoneID == "" { - return errors.Errorf("Could not determine DNS Services DNS zone ID from base domain %q", o.BaseDomain) + return fmt.Errorf("Could not determine DNS Services DNS zone ID from base domain %q", o.BaseDomain) } o.Logger.Debugf("Found DNS Services DNS zone ID for base domain %q: %s", o.BaseDomain, zoneID) o.zoneID = zoneID @@ -382,7 +381,7 @@ func (o *ClusterUninstaller) ResourceGroupID() (string, error) { // If no ResourceGroupName is available, raise an error if o.ResourceGroupName == "" { - return "", errors.Errorf("No ResourceGroupName provided") + return "", fmt.Errorf("No ResourceGroupName provided") } ctx, cancel := o.contextWithTimeout() @@ -396,9 +395,9 @@ func (o *ClusterUninstaller) ResourceGroupID() (string, error) { return "", err } if len(resources.Resources) == 0 { - return "", errors.Errorf("ResourceGroup '%q' not found", o.ResourceGroupName) + return "", fmt.Errorf("ResourceGroup '%q' not found", o.ResourceGroupName) } else if len(resources.Resources) > 1 { - return "", errors.Errorf("Too many resource groups matched name %q", o.ResourceGroupName) + return "", fmt.Errorf("Too many resource groups matched name %q", o.ResourceGroupName) } o.SetResourceGroupID(*resources.Resources[0].ID) @@ -431,7 +430,7 @@ func aggregateError(errs []error, pending ...int) error { return err } if len(pending) > 0 && pending[0] > 0 { - return errors.Errorf("%d items pending", pending[0]) + return fmt.Errorf("%d items pending", pending[0]) } return nil } diff --git a/pkg/destroy/ibmcloud/image.go b/pkg/destroy/ibmcloud/image.go index a97f078ca11..080b51b8e22 100644 --- a/pkg/destroy/ibmcloud/image.go +++ b/pkg/destroy/ibmcloud/image.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const imageTypeName = "image" @@ -19,7 +19,7 @@ func (o *ClusterUninstaller) listImages() (cloudResources, error) { options := o.vpcSvc.NewListImagesOptions() resources, _, err := o.vpcSvc.ListImagesWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list images") + return nil, fmt.Errorf("failed to list images: %w", err) } result := []cloudResource{} @@ -59,7 +59,7 @@ func (o *ClusterUninstaller) deleteImage(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete image %s", item.name) + return fmt.Errorf("Failed to delete image %s: %w", item.name, err) } return nil @@ -88,7 +88,7 @@ func (o *ClusterUninstaller) destroyImages() error { } if items = o.getPendingItems(imageTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/instance.go b/pkg/destroy/ibmcloud/instance.go index 50261346cbd..baa32b03222 100644 --- a/pkg/destroy/ibmcloud/instance.go +++ b/pkg/destroy/ibmcloud/instance.go @@ -7,7 +7,6 @@ import ( "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const ( @@ -69,7 +68,7 @@ func (o *ClusterUninstaller) stopInstances() error { } if items = o.getPendingItems(instanceActionTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } @@ -97,7 +96,7 @@ func (o *ClusterUninstaller) stopInstance(item cloudResource) error { _, _, err := o.vpcSvc.CreateInstanceActionWithContext(ctx, options) if err != nil { - return errors.Wrapf(err, "Failed to stop instance %q", item.name) + return fmt.Errorf("Failed to stop instance %q: %w", item.name, err) } return nil @@ -124,7 +123,7 @@ func (o *ClusterUninstaller) deleteInstance(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete instance %q", item.name) + return fmt.Errorf("Failed to delete instance %q: %w", item.name, err) } return nil @@ -153,7 +152,7 @@ func (o *ClusterUninstaller) destroyInstances() error { } if items = o.getPendingItems(instanceTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/loadbalancer.go b/pkg/destroy/ibmcloud/loadbalancer.go index 5cb82595180..8b2c7699860 100644 --- a/pkg/destroy/ibmcloud/loadbalancer.go +++ b/pkg/destroy/ibmcloud/loadbalancer.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const loadBalancerTypeName = "load balancer" @@ -19,7 +19,7 @@ func (o *ClusterUninstaller) listLoadBalancers() (cloudResources, error) { options := o.vpcSvc.NewListLoadBalancersOptions() resources, _, err := o.vpcSvc.ListLoadBalancersWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list load balancers") + return nil, fmt.Errorf("failed to list load balancers: %w", err) } result := []cloudResource{} @@ -59,7 +59,7 @@ func (o *ClusterUninstaller) deleteLoadBalancer(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete load balancer %s", item.name) + return fmt.Errorf("Failed to delete load balancer %s: %w", item.name, err) } return nil @@ -88,7 +88,7 @@ func (o *ClusterUninstaller) destroyLoadBalancers() error { } if items = o.getPendingItems(loadBalancerTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/publicgateway.go b/pkg/destroy/ibmcloud/publicgateway.go index 38637801c5e..e3a46fb2b9d 100644 --- a/pkg/destroy/ibmcloud/publicgateway.go +++ b/pkg/destroy/ibmcloud/publicgateway.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const publicGatewayTypeName = "public gateway" @@ -19,7 +19,7 @@ func (o *ClusterUninstaller) listPublicGateways() (cloudResources, error) { options := o.vpcSvc.NewListPublicGatewaysOptions() resources, _, err := o.vpcSvc.ListPublicGatewaysWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list public gateways") + return nil, fmt.Errorf("failed to list public gateways: %w", err) } result := []cloudResource{} @@ -59,7 +59,7 @@ func (o *ClusterUninstaller) deletePublicGateway(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete public gateway %s", item.name) + return fmt.Errorf("Failed to delete public gateway %s: %w", item.name, err) } return nil @@ -94,7 +94,7 @@ func (o *ClusterUninstaller) destroyPublicGateways() error { } if items = o.getPendingItems(publicGatewayTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/resourcegroup.go b/pkg/destroy/ibmcloud/resourcegroup.go index 971ce0c4fcc..8e183fa7cf1 100644 --- a/pkg/destroy/ibmcloud/resourcegroup.go +++ b/pkg/destroy/ibmcloud/resourcegroup.go @@ -1,9 +1,8 @@ package ibmcloud import ( + "fmt" "net/http" - - "github.com/pkg/errors" ) const resourceGroupTypeName = "resource group" @@ -18,7 +17,7 @@ func (o *ClusterUninstaller) listResourceGroups() (cloudResources, error) { options.SetAccountID(o.AccountID) resources, _, err := o.managementSvc.ListResourceGroupsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list resource groups") + return nil, fmt.Errorf("Failed to list resource groups: %w", err) } result := []cloudResource{} @@ -53,7 +52,7 @@ func (o *ClusterUninstaller) deleteResourceGroup(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete resource group %s", item.name) + return fmt.Errorf("Failed to delete resource group %s: %w", item.name, err) } return nil @@ -88,7 +87,7 @@ func (o *ClusterUninstaller) destroyResourceGroups() error { } if items = o.getPendingItems(resourceGroupTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/securitygroup.go b/pkg/destroy/ibmcloud/securitygroup.go index 120339ed500..ad4eff7002f 100644 --- a/pkg/destroy/ibmcloud/securitygroup.go +++ b/pkg/destroy/ibmcloud/securitygroup.go @@ -1,12 +1,12 @@ package ibmcloud import ( + "fmt" "net/http" "reflect" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const ( @@ -23,7 +23,7 @@ func (o *ClusterUninstaller) listSecurityGroups() (cloudResources, error) { options := o.vpcSvc.NewListSecurityGroupsOptions() resources, _, err := o.vpcSvc.ListSecurityGroupsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list security groups") + return nil, fmt.Errorf("Failed to list security groups: %w", err) } result := []cloudResource{} @@ -50,7 +50,7 @@ func (o *ClusterUninstaller) listSecurityGroupRules(securityGroupID string) (clo options := o.vpcSvc.NewListSecurityGroupRulesOptions(securityGroupID) resources, _, err := o.vpcSvc.ListSecurityGroupRulesWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "Failed to list security group rules for %q", securityGroupID) + return nil, fmt.Errorf("Failed to list security group rules for %q: %w", securityGroupID, err) } result := []cloudResource{} @@ -126,7 +126,7 @@ func (o *ClusterUninstaller) deleteSecurityGroup(item cloudResource) error { } if rules = o.getPendingItems(securityGroupRuleTypeName); len(rules) > 0 { - return errors.Errorf("%d items pending", len(rules)) + return fmt.Errorf("%d items pending", len(rules)) } options := o.vpcSvc.NewDeleteSecurityGroupOptions(item.id) @@ -140,7 +140,7 @@ func (o *ClusterUninstaller) deleteSecurityGroup(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete security group %s", item.name) + return fmt.Errorf("Failed to delete security group %s: %w", item.name, err) } return nil @@ -161,7 +161,7 @@ func (o *ClusterUninstaller) deleteSecurityGroupRule(item cloudResource, securit } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete security group rule %s", item.name) + return fmt.Errorf("Failed to delete security group rule %s: %w", item.name, err) } return nil @@ -196,7 +196,7 @@ func (o *ClusterUninstaller) destroySecurityGroups() error { } if items = o.getPendingItems(securityGroupTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/subnet.go b/pkg/destroy/ibmcloud/subnet.go index e4b09790ed6..7702c8c6901 100644 --- a/pkg/destroy/ibmcloud/subnet.go +++ b/pkg/destroy/ibmcloud/subnet.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const subnetTypeName = "subnet" @@ -19,7 +19,7 @@ func (o *ClusterUninstaller) listSubnets() (cloudResources, error) { options := o.vpcSvc.NewListSubnetsOptions() resources, _, err := o.vpcSvc.ListSubnetsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list subnets") + return nil, fmt.Errorf("failed to list subnets: %w", err) } result := []cloudResource{} @@ -59,7 +59,7 @@ func (o *ClusterUninstaller) deleteSubnet(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete subnet %s", item.name) + return fmt.Errorf("Failed to delete subnet %s: %w", item.name, err) } return nil @@ -94,7 +94,7 @@ func (o *ClusterUninstaller) destroySubnets() error { } if items = o.getPendingItems(subnetTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/destroy/ibmcloud/vpc.go b/pkg/destroy/ibmcloud/vpc.go index a9ae8b9b34b..241d631267a 100644 --- a/pkg/destroy/ibmcloud/vpc.go +++ b/pkg/destroy/ibmcloud/vpc.go @@ -1,11 +1,11 @@ package ibmcloud import ( + "fmt" "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" - "github.com/pkg/errors" ) const vpcTypeName = "vpc" @@ -19,7 +19,7 @@ func (o *ClusterUninstaller) listVPCs() (cloudResources, error) { options := o.vpcSvc.NewListVpcsOptions() resources, _, err := o.vpcSvc.ListVpcsWithContext(ctx, options) if err != nil { - return nil, errors.Wrapf(err, "failed to list vpcs") + return nil, fmt.Errorf("failed to list vpcs: %w", err) } result := []cloudResource{} @@ -59,7 +59,7 @@ func (o *ClusterUninstaller) deleteVPC(item cloudResource) error { } if err != nil && details != nil && details.StatusCode != http.StatusNotFound { - return errors.Wrapf(err, "Failed to delete VOC %s", item.name) + return fmt.Errorf("Failed to delete VPC %s: %w", item.name, err) } return nil @@ -93,7 +93,7 @@ func (o *ClusterUninstaller) destroyVPCs() error { } if items = o.getPendingItems(vpcTypeName); len(items) > 0 { - return errors.Errorf("%d items pending", len(items)) + return fmt.Errorf("%d items pending", len(items)) } return nil } diff --git a/pkg/tfvars/ibmcloud/ibmcloud.go b/pkg/tfvars/ibmcloud/ibmcloud.go index 389944ac35e..d5d388ae17f 100644 --- a/pkg/tfvars/ibmcloud/ibmcloud.go +++ b/pkg/tfvars/ibmcloud/ibmcloud.go @@ -2,8 +2,7 @@ package ibmcloud import ( "encoding/json" - - "github.com/pkg/errors" + "fmt" "github.com/openshift/installer/pkg/tfvars/internal/cache" "github.com/openshift/installer/pkg/types" @@ -65,7 +64,7 @@ type TFVarsSources struct { func TFVars(sources TFVarsSources) ([]byte, error) { cachedImage, err := cache.DownloadImageFile(sources.ImageURL) if err != nil { - return nil, errors.Wrap(err, "failed to use cached ibmcloud image") + return nil, fmt.Errorf("failed to use cached ibmcloud image: %w", err) } masterConfig := sources.MasterConfigs[0]