Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions data/data/ibmcloud/variables-ibmcloud.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand Down
27 changes: 13 additions & 14 deletions pkg/asset/installconfig/ibmcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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{}
Expand All @@ -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())
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions pkg/asset/installconfig/ibmcloud/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/installconfig/ibmcloud/ibmcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}),
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/installconfig/ibmcloud/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sync"

"github.com/IBM/go-sdk-core/v5/core"
"github.com/pkg/errors"

"github.com/openshift/installer/pkg/types"
)
Expand Down Expand Up @@ -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)
}
}

Expand Down
17 changes: 8 additions & 9 deletions pkg/asset/installconfig/ibmcloud/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package ibmcloud

import (
"context"

"github.com/pkg/errors"
"fmt"
)

// Subnet represents an IBM Cloud VPC Subnet
Expand All @@ -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{
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/machines/ibmcloud/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/machines/ibmcloud/machinesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strings"

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

Expand Down Expand Up @@ -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{
Expand Down
17 changes: 8 additions & 9 deletions pkg/destroy/ibmcloud/cloudobjectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"

"github.com/IBM/platform-services-go-sdk/resourcecontrollerv2"
"github.com/pkg/errors"
)

const (
Expand All @@ -27,15 +26,15 @@ 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)
for _, reclamation := range resources.Resources {
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)
Expand All @@ -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)
Expand All @@ -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{}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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.
Expand All @@ -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")
}
Loading