From 1ec05d03b853e428088a4188f351126bed4f8b8d Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Thu, 22 Apr 2021 16:07:39 -0700 Subject: [PATCH 01/12] Add ListHVNRoutes client; initial scaffolding for HVN route data source. --- go.mod | 2 +- go.sum | 8 +-- internal/clients/hvn_route.go | 25 ++++++++ internal/provider/data_source_hvn_route.go | 67 ++++++++++++++++++++++ internal/provider/resource_hvn_route.go | 54 +++++++++++++++++ 5 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 internal/clients/hvn_route.go create mode 100644 internal/provider/data_source_hvn_route.go create mode 100644 internal/provider/resource_hvn_route.go diff --git a/go.mod b/go.mod index 9ca77969d..b44fd59a4 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,6 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/hcp-sdk-go v0.6.0 github.com/hashicorp/terraform-plugin-docs v0.4.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0 github.com/stretchr/testify v1.7.0 ) diff --git a/go.sum b/go.sum index 564960976..4a0e4a150 100644 --- a/go.sum +++ b/go.sum @@ -321,10 +321,10 @@ github.com/hashicorp/terraform-json v0.8.0 h1:XObQ3PgqU52YLQKEaJ08QtUshAfN3yu4u8 github.com/hashicorp/terraform-json v0.8.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= github.com/hashicorp/terraform-plugin-docs v0.4.0 h1:xJIXsMzBFwBvC1zcjoNz743GL2tNEfYFFU9+Hjp4Uek= github.com/hashicorp/terraform-plugin-docs v0.4.0/go.mod h1:fKj/V3t45tiXpSlUms/0G4OrBayyWpbUJ4WtLjBkINU= -github.com/hashicorp/terraform-plugin-go v0.2.1 h1:EW/R8bB2Zbkjmugzsy1d27yS8/0454b3MtYHkzOknqA= -github.com/hashicorp/terraform-plugin-go v0.2.1/go.mod h1:10V6F3taeDWVAoLlkmArKttR3IULlRWFAGtQIQTIDr4= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0 h1:4EHNOAjwiYCeBxY16rt2KwyRNNVsCaVO3kWBbiXfYM0= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0/go.mod h1:z+cMZ0iswzZOahBJ3XmNWgWkVnAd2bl8g+FhyyuPDH4= +github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA= +github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0 h1:mPZW0DDXlD70/Y+jenKz8fmkyxdmuE9T8mrftycxuZ0= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0/go.mod h1:r2d5s4frIMvyjEuv4a47xI4f7mkaQlRu7bLgw2/LAaY= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= diff --git a/internal/clients/hvn_route.go b/internal/clients/hvn_route.go new file mode 100644 index 000000000..6eeb829b5 --- /dev/null +++ b/internal/clients/hvn_route.go @@ -0,0 +1,25 @@ +package clients + +import ( + "context" + + "github.com/hashicorp/hcp-sdk-go/clients/cloud-network/preview/2020-09-07/client/network_service" + networkmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-network/preview/2020-09-07/models" + sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" +) + +// ListHVNRoutes lists the routes for an HVN. +func ListHVNRoutes(ctx context.Context, client *Client, hvnID string, loc *sharedmodels.HashicorpCloudLocationLocation) ([]*networkmodels.HashicorpCloudNetwork20200907HVNRoute, error) { + listHVNRoutesParams := network_service.NewListHVNRoutesParams() + listHVNRoutesParams.Context = ctx + listHVNRoutesParams.HvnID = hvnID + listHVNRoutesParams.HvnLocationOrganizationID = loc.OrganizationID + listHVNRoutesParams.HvnLocationProjectID = loc.ProjectID + + listHVNRoutesResponse, err := client.Network.ListHVNRoutes(listHVNRoutesParams, nil) + if err != nil { + return nil, err + } + + return listHVNRoutesResponse.Payload.Routes, nil +} diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go new file mode 100644 index 000000000..70271a8a2 --- /dev/null +++ b/internal/provider/data_source_hvn_route.go @@ -0,0 +1,67 @@ +package provider + +import ( + "context" + + sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-hcp/internal/clients" +) + +func dataSourceHVNRoute() *schema.Resource { + return &schema.Resource{ + Description: "The HVN Route data source provides information about an existing HVN Route.", + ReadContext: dataSourceHVNRouteRead, + Timeouts: &schema.ResourceTimeout{ + Default: &hvnRouteDefaultTimeout, + }, + Schema: map[string]*schema.Schema{ + // Required inputs + "hvn_id": { + Description: "The ID of the HashiCorp Virtual Network (HVN).", + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: validateSlugID, + }, + "destination_cidr": { + Description: "The destination CIDR of the HVN Route", + Type: schema.TypeString, + Required: true, + }, + // Computed outputs + "organization_id": { + Description: "The ID of the HCP organization where the HVN Route is located. Always matches the HVN's organization.", + Type: schema.TypeString, + Computed: true, + }, + "project_id": { + Description: "The ID of the HCP project where the HVN Route is located. Always matches the HVN's project.", + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*clients.Client) + + hvnID := d.Get("hvn_id").(string) + + loc := &sharedmodels.HashicorpCloudLocationLocation{ + OrganizationID: client.Config.OrganizationID, + ProjectID: client.Config.ProjectID, + } + + _, err := clients.ListHVNRoutes(ctx, client, hvnID, loc) + if err != nil { + return diag.FromErr(err) + } + + // if err := setHVNRouteResourceData(d, routes); err != nil { + // return diag.FromErr(err) + // } + + return nil +} diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go new file mode 100644 index 000000000..4b5344514 --- /dev/null +++ b/internal/provider/resource_hvn_route.go @@ -0,0 +1,54 @@ +package provider + +import ( + "time" + + networkmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-network/preview/2020-09-07/models" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var hvnRouteDefaultTimeout = time.Minute * 1 + +func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.HashicorpCloudNetwork20200907HVNRoute) error { + if err := d.Set("hvn_id", route.Hvn.ID); err != nil { + return err + } + + if err := d.Set("hvn_region", route.Hvn.Location.Region.Region); err != nil { + return err + } + + if err := d.Set("hvn_provider", route.Hvn.Location.Region.Provider); err != nil { + return err + } + + if err := d.Set("organization_id", route.Hvn.Location.OrganizationID); err != nil { + return err + } + + if err := d.Set("project_id", route.Hvn.Location.ProjectID); err != nil { + return err + } + + if err := d.Set("hvn_route_id", route.ID); err != nil { + return err + } + + if err := d.Set("destination_cidr", route.Destination); err != nil { + return err + } + + if err := d.Set("target", route.Target); err != nil { + return err + } + + if err := d.Set("state", route.State); err != nil { + return err + } + + if err := d.Set("created_at", route.CreatedAt.String()); err != nil { + return err + } + + return nil +} From fb37e9b15ace64c6a2c89f5c3be4421ce2fb7f19 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Tue, 27 Apr 2021 14:29:33 -0700 Subject: [PATCH 02/12] Bumps HCP SDK version --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b44fd59a4..793523f32 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-openapi/strfmt v0.20.1 github.com/google/uuid v1.2.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 - github.com/hashicorp/hcp-sdk-go v0.6.0 + github.com/hashicorp/hcp-sdk-go v0.7.0 github.com/hashicorp/terraform-plugin-docs v0.4.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0 github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index 4a0e4a150..e883e7fe6 100644 --- a/go.sum +++ b/go.sum @@ -312,6 +312,8 @@ github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggU github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= github.com/hashicorp/hcp-sdk-go v0.6.0 h1:vG6ZV0hOTZoYK4o/ZsqkgrhLFc3JIWG0y8l1thinQiA= github.com/hashicorp/hcp-sdk-go v0.6.0/go.mod h1:vpV5eSGZVmfCFcksi4AH8d/QSybuyLSH5UQcwmnRUQk= +github.com/hashicorp/hcp-sdk-go v0.7.0 h1:OtbcR/rMBlfK5BLowHIPe0HJtb0rEs8FyRAzS+xH9vI= +github.com/hashicorp/hcp-sdk-go v0.7.0/go.mod h1:M+kmFj0s4KWNA5GVOgLhNtCTu3ypTR+QjWYIMgedA5Q= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.12.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= From 669860d96b3ac0b4512bd3d448f6d65f051583ec Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Tue, 27 Apr 2021 14:36:58 -0700 Subject: [PATCH 03/12] setHVNRouteResourceData does not set all HVN fields, ListHVNRoutes client takes additional params;HVN Route data sources uses self_link --- internal/clients/hvn_route.go | 7 +++- internal/provider/data_source_hvn_route.go | 46 +++++++++++++--------- internal/provider/link.go | 3 ++ internal/provider/provider.go | 1 + internal/provider/resource_hvn_route.go | 8 ---- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/internal/clients/hvn_route.go b/internal/clients/hvn_route.go index 6eeb829b5..80ee082be 100644 --- a/internal/clients/hvn_route.go +++ b/internal/clients/hvn_route.go @@ -9,12 +9,17 @@ import ( ) // ListHVNRoutes lists the routes for an HVN. -func ListHVNRoutes(ctx context.Context, client *Client, hvnID string, loc *sharedmodels.HashicorpCloudLocationLocation) ([]*networkmodels.HashicorpCloudNetwork20200907HVNRoute, error) { +func ListHVNRoutes(ctx context.Context, client *Client, hvnID string, + destination string, targetID string, targetType string, + loc *sharedmodels.HashicorpCloudLocationLocation) ([]*networkmodels.HashicorpCloudNetwork20200907HVNRoute, error) { listHVNRoutesParams := network_service.NewListHVNRoutesParams() listHVNRoutesParams.Context = ctx listHVNRoutesParams.HvnID = hvnID listHVNRoutesParams.HvnLocationOrganizationID = loc.OrganizationID listHVNRoutesParams.HvnLocationProjectID = loc.ProjectID + listHVNRoutesParams.Destination = &destination + listHVNRoutesParams.TargetID = &targetID + listHVNRoutesParams.TargetType = &targetType listHVNRoutesResponse, err := client.Network.ListHVNRoutes(listHVNRoutesParams, nil) if err != nil { diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index 70271a8a2..fd052efbc 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -18,25 +18,19 @@ func dataSourceHVNRoute() *schema.Resource { }, Schema: map[string]*schema.Schema{ // Required inputs - "hvn_id": { - Description: "The ID of the HashiCorp Virtual Network (HVN).", - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: validateSlugID, + "hvn": { + Description: "The Self Link of the HashiCorp Virtual Network (HVN).", + Type: schema.TypeString, + Required: true, }, "destination_cidr": { - Description: "The destination CIDR of the HVN Route", + Description: "The destination CIDR of the HVN route", Type: schema.TypeString, Required: true, }, // Computed outputs - "organization_id": { - Description: "The ID of the HCP organization where the HVN Route is located. Always matches the HVN's organization.", - Type: schema.TypeString, - Computed: true, - }, - "project_id": { - Description: "The ID of the HCP project where the HVN Route is located. Always matches the HVN's project.", + "self_link": { + Description: "A unique URL identifying the HVN route.", Type: schema.TypeString, Computed: true, }, @@ -47,21 +41,37 @@ func dataSourceHVNRoute() *schema.Resource { func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*clients.Client) - hvnID := d.Get("hvn_id").(string) + hvn := d.Get("hvn").(string) + var hvnLink *sharedmodels.HashicorpCloudLocationLink + + hvnLink, err := parseLinkURL(hvn, "hashicorp.network.hvn") + if err != nil { + return diag.FromErr(err) + } loc := &sharedmodels.HashicorpCloudLocationLocation{ OrganizationID: client.Config.OrganizationID, ProjectID: client.Config.ProjectID, } - _, err := clients.ListHVNRoutes(ctx, client, hvnID, loc) + destination := d.Get("destination_cidr").(string) + route, err := clients.ListHVNRoutes(ctx, client, hvnLink.ID, destination, "", "", loc) + if err != nil { + return diag.FromErr(err) + } + + // TODO check len(route)>0; handle error otherwise + + link := newLink(loc, HVNRouteResourceType, route[0].ID) + url, err := linkURL(link) if err != nil { return diag.FromErr(err) } + d.SetId(url) - // if err := setHVNRouteResourceData(d, routes); err != nil { - // return diag.FromErr(err) - // } + if err := setHVNRouteResourceData(d, route[0]); err != nil { + return diag.FromErr(err) + } return nil } diff --git a/internal/provider/link.go b/internal/provider/link.go index 84bd7d605..df1c68769 100644 --- a/internal/provider/link.go +++ b/internal/provider/link.go @@ -31,6 +31,9 @@ const ( // TgwAttachmentResourceType is the resource type of a TGW attachment TgwAttachmentResourceType = "hashicorp.network.tgw-attachment" + // HVNRouteResourceType is the resource type of an HVN route + HVNRouteResourceType = "hashicorp.network.route" + // ConsulSnapshotResourceType is the resource type of a Consul snapshot ConsulSnapshotResourceType = "hashicorp.consul.snapshot" diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 103de5d15..d2d231b0c 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -25,6 +25,7 @@ func New() func() *schema.Provider { "hcp_consul_cluster": dataSourceConsulCluster(), "hcp_consul_versions": dataSourceConsulVersions(), "hcp_hvn": dataSourceHvn(), + "hcp_hvn_route": dataSourceHVNRoute(), "hcp_vault_cluster": dataSourceVaultCluster(), }, ResourcesMap: map[string]*schema.Resource{ diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index 4b5344514..81875b3f4 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -14,14 +14,6 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic return err } - if err := d.Set("hvn_region", route.Hvn.Location.Region.Region); err != nil { - return err - } - - if err := d.Set("hvn_provider", route.Hvn.Location.Region.Provider); err != nil { - return err - } - if err := d.Set("organization_id", route.Hvn.Location.OrganizationID); err != nil { return err } From 5472d41895eda31031d52b825ba2907c0acf93d1 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Wed, 28 Apr 2021 10:40:02 -0700 Subject: [PATCH 04/12] HVN route data source returns target, state, created_at --- internal/provider/data_source_hvn_route.go | 21 ++++++++-- internal/provider/resource_hvn_route.go | 45 +++++++++++++++++----- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index fd052efbc..585f56e17 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -11,7 +11,7 @@ import ( func dataSourceHVNRoute() *schema.Resource { return &schema.Resource{ - Description: "The HVN Route data source provides information about an existing HVN Route.", + Description: "The HVN Route data source provides information about an existing HVN route.", ReadContext: dataSourceHVNRouteRead, Timeouts: &schema.ResourceTimeout{ Default: &hvnRouteDefaultTimeout, @@ -19,7 +19,7 @@ func dataSourceHVNRoute() *schema.Resource { Schema: map[string]*schema.Schema{ // Required inputs "hvn": { - Description: "The Self Link of the HashiCorp Virtual Network (HVN).", + Description: "The `self_link` of the HashiCorp Virtual Network (HVN).", Type: schema.TypeString, Required: true, }, @@ -34,6 +34,21 @@ func dataSourceHVNRoute() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "target": { + Description: "The `self_link` identifying the target of the HVN route.", + Type: schema.TypeString, + Computed: true, + }, + "state": { + Description: "The state of the HVN route.", + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Description: "The time that the HVN route was created.", + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -69,7 +84,7 @@ func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta in } d.SetId(url) - if err := setHVNRouteResourceData(d, route[0]); err != nil { + if err := setHVNRouteResourceData(d, route[0], loc); err != nil { return diag.FromErr(err) } diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index 81875b3f4..7adcb4499 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -1,36 +1,61 @@ package provider import ( + "errors" "time" networkmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-network/preview/2020-09-07/models" + sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var hvnRouteDefaultTimeout = time.Minute * 1 -func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.HashicorpCloudNetwork20200907HVNRoute) error { - if err := d.Set("hvn_id", route.Hvn.ID); err != nil { - return err - } +func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.HashicorpCloudNetwork20200907HVNRoute, + loc *sharedmodels.HashicorpCloudLocationLocation) error { - if err := d.Set("organization_id", route.Hvn.Location.OrganizationID); err != nil { + // Set self_link + link := newLink(loc, HVNRouteResourceType, route.ID) + selfLink, err := linkURL(link) + if err != nil { return err } - if err := d.Set("project_id", route.Hvn.Location.ProjectID); err != nil { + if err := d.Set("self_link", selfLink); err != nil { return err } - if err := d.Set("hvn_route_id", route.ID); err != nil { - return err + // Set target self_link + var targetLink string + + switch route.Target.HvnConnection.Type { + case HvnResourceType: + hvnLink := newLink(loc, HvnResourceType, route.Target.HvnConnection.ID) + targetLink, err = linkURL(hvnLink) + if err != nil { + return err + } + case PeeringResourceType: + peeringLink := newLink(loc, PeeringResourceType, route.Target.HvnConnection.ID) + targetLink, err = linkURL(peeringLink) + if err != nil { + return err + } + case TgwAttachmentResourceType: + tgwAttLink := newLink(loc, PeeringResourceType, route.Target.HvnConnection.ID) + targetLink, err = linkURL(tgwAttLink) + if err != nil { + return err + } + default: + return errors.New("Unable to set target self_link - HVN Route target is not a known type.") } - if err := d.Set("destination_cidr", route.Destination); err != nil { + if err := d.Set("target", targetLink); err != nil { return err } - if err := d.Set("target", route.Target); err != nil { + if err := d.Set("destination_cidr", route.Destination); err != nil { return err } From 3523aff69c261c167eb76e75bbe87befb57694d3 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Wed, 28 Apr 2021 10:51:40 -0700 Subject: [PATCH 05/12] Error handling for unexpected # of routes returnedd;improve comments, add logging --- internal/provider/data_source_hvn_route.go | 12 +++++++++--- internal/provider/resource_hvn_route.go | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index 585f56e17..de3e46114 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -2,6 +2,7 @@ package provider import ( "context" + "log" sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -68,14 +69,19 @@ func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta in OrganizationID: client.Config.OrganizationID, ProjectID: client.Config.ProjectID, } - destination := d.Get("destination_cidr").(string) + + log.Printf("[INFO] Reading HVN route for HVN (%s) with destination_cidr=%s ", hvn, destination) route, err := clients.ListHVNRoutes(ctx, client, hvnLink.ID, destination, "", "", loc) if err != nil { - return diag.FromErr(err) + return diag.Errorf("unable to retrieve HVN route for HVN (%s) with destination_cidr=%s: %v", + hvn, destination, err) } - // TODO check len(route)>0; handle error otherwise + // ListHVNRoutes call should return 1 and only 1 HVN route. + if len(route) != 1 { + return diag.Errorf("Unexpected number of HVN routes returned: %d", len(route)) + } link := newLink(loc, HVNRouteResourceType, route[0].ID) url, err := linkURL(link) diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index 7adcb4499..bf091c22d 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -14,7 +14,7 @@ var hvnRouteDefaultTimeout = time.Minute * 1 func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.HashicorpCloudNetwork20200907HVNRoute, loc *sharedmodels.HashicorpCloudLocationLocation) error { - // Set self_link + // Set self_link for the HVN route. link := newLink(loc, HVNRouteResourceType, route.ID) selfLink, err := linkURL(link) if err != nil { @@ -25,7 +25,7 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic return err } - // Set target self_link + // Set self_link identifying the target of the HVN route. var targetLink string switch route.Target.HvnConnection.Type { @@ -48,7 +48,7 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic return err } default: - return errors.New("Unable to set target self_link - HVN Route target is not a known type.") + return errors.New("Unable to set self_link identifying the target - HVN Route target is not a known type.") } if err := d.Set("target", targetLink); err != nil { From 66f70f70ad61c07cdd189d1f59ff4bc74e917167 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Wed, 28 Apr 2021 10:59:47 -0700 Subject: [PATCH 06/12] Add generated doc, add example for HVN route data source --- docs/data-sources/hvn_route.md | 49 +++++++++++++++++++ .../data-sources/hcp_hvn_route/data-source.tf | 4 ++ .../data-sources/hcp_hvn_route/variables.tf | 9 ++++ go.sum | 2 - 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/data-sources/hvn_route.md create mode 100644 examples/data-sources/hcp_hvn_route/data-source.tf create mode 100644 examples/data-sources/hcp_hvn_route/variables.tf diff --git a/docs/data-sources/hvn_route.md b/docs/data-sources/hvn_route.md new file mode 100644 index 000000000..6344e5c12 --- /dev/null +++ b/docs/data-sources/hvn_route.md @@ -0,0 +1,49 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "hcp_hvn_route Data Source - terraform-provider-hcp" +subcategory: "" +description: |- + The HVN Route data source provides information about an existing HVN route. +--- + +# hcp_hvn_route (Data Source) + +The HVN Route data source provides information about an existing HVN route. + +## Example Usage + +```terraform +data "hcp_hvn_route" "example" { + hvn = var.hvn + destination_cidr = var.destination_cidr +} +``` + + +## Schema + +### Required + +- **destination_cidr** (String) The destination CIDR of the HVN route +- **hvn** (String) The `self_link` of the HashiCorp Virtual Network (HVN). + +### Optional + +- **id** (String) The ID of this resource. +- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- **created_at** (String) The time that the HVN route was created. +- **self_link** (String) A unique URL identifying the HVN route. +- **state** (String) The state of the HVN route. +- **target** (String) The `self_link` identifying the target of the HVN route. + + +### Nested Schema for `timeouts` + +Optional: + +- **default** (String) + + diff --git a/examples/data-sources/hcp_hvn_route/data-source.tf b/examples/data-sources/hcp_hvn_route/data-source.tf new file mode 100644 index 000000000..f2b7b5b98 --- /dev/null +++ b/examples/data-sources/hcp_hvn_route/data-source.tf @@ -0,0 +1,4 @@ +data "hcp_hvn_route" "example" { + hvn = var.hvn + destination_cidr = var.destination_cidr +} diff --git a/examples/data-sources/hcp_hvn_route/variables.tf b/examples/data-sources/hcp_hvn_route/variables.tf new file mode 100644 index 000000000..8e6fd7c40 --- /dev/null +++ b/examples/data-sources/hcp_hvn_route/variables.tf @@ -0,0 +1,9 @@ +variable "hvn" { + description = "The `self_link` of the HashiCorp Virtual Network (HVN)." + type = string +} + +variable "destination_cidr" { + description = "The destination CIDR of the HVN route." + type = string +} diff --git a/go.sum b/go.sum index e883e7fe6..d28b429aa 100644 --- a/go.sum +++ b/go.sum @@ -310,8 +310,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= -github.com/hashicorp/hcp-sdk-go v0.6.0 h1:vG6ZV0hOTZoYK4o/ZsqkgrhLFc3JIWG0y8l1thinQiA= -github.com/hashicorp/hcp-sdk-go v0.6.0/go.mod h1:vpV5eSGZVmfCFcksi4AH8d/QSybuyLSH5UQcwmnRUQk= github.com/hashicorp/hcp-sdk-go v0.7.0 h1:OtbcR/rMBlfK5BLowHIPe0HJtb0rEs8FyRAzS+xH9vI= github.com/hashicorp/hcp-sdk-go v0.7.0/go.mod h1:M+kmFj0s4KWNA5GVOgLhNtCTu3ypTR+QjWYIMgedA5Q= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= From a3c5712f79e3c81ff19cb174e2e67f64a4933e95 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Wed, 28 Apr 2021 13:45:00 -0700 Subject: [PATCH 07/12] HVN route data source target is a map instead of string;more useful error returned if ListHVNRoutes returns no route --- docs/data-sources/hvn_route.md | 2 +- internal/provider/data_source_hvn_route.go | 16 +++++++++++----- internal/provider/resource_hvn_route.go | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/data-sources/hvn_route.md b/docs/data-sources/hvn_route.md index 6344e5c12..95efae97d 100644 --- a/docs/data-sources/hvn_route.md +++ b/docs/data-sources/hvn_route.md @@ -37,7 +37,7 @@ data "hcp_hvn_route" "example" { - **created_at** (String) The time that the HVN route was created. - **self_link** (String) A unique URL identifying the HVN route. - **state** (String) The state of the HVN route. -- **target** (String) The `self_link` identifying the target of the HVN route. +- **target** (Map of String) The target of the HVN route. ### Nested Schema for `timeouts` diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index de3e46114..04ca3eb0e 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -36,9 +36,12 @@ func dataSourceHVNRoute() *schema.Resource { Computed: true, }, "target": { - Description: "The `self_link` identifying the target of the HVN route.", - Type: schema.TypeString, - Computed: true, + Description: "The target of the HVN route.", + Type: schema.TypeMap, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, }, "state": { Description: "The state of the HVN route.", @@ -79,8 +82,11 @@ func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta in } // ListHVNRoutes call should return 1 and only 1 HVN route. - if len(route) != 1 { - return diag.Errorf("Unexpected number of HVN routes returned: %d", len(route)) + if len(route) > 1 { + return diag.Errorf("Unexpected number of HVN routes returned for destination_cidr=%s: %d", destination, len(route)) + } + if len(route) == 0 { + return diag.Errorf("No HVN route found for destionation_cidr=%s", destination) } link := newLink(loc, HVNRouteResourceType, route[0].ID) diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index bf091c22d..90b54014d 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -51,7 +51,7 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic return errors.New("Unable to set self_link identifying the target - HVN Route target is not a known type.") } - if err := d.Set("target", targetLink); err != nil { + if err := d.Set("target", map[string]interface{}{"self_link": targetLink}); err != nil { return err } From fa10e8e10db27acc094c3379382e661bb94152ed Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Wed, 28 Apr 2021 15:45:18 -0700 Subject: [PATCH 08/12] Replace switch case in setting target link for HVN route data source --- internal/provider/resource_hvn_route.go | 28 ++++--------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index 90b54014d..db86b705d 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -1,7 +1,6 @@ package provider import ( - "errors" "time" networkmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-network/preview/2020-09-07/models" @@ -26,29 +25,10 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic } // Set self_link identifying the target of the HVN route. - var targetLink string - - switch route.Target.HvnConnection.Type { - case HvnResourceType: - hvnLink := newLink(loc, HvnResourceType, route.Target.HvnConnection.ID) - targetLink, err = linkURL(hvnLink) - if err != nil { - return err - } - case PeeringResourceType: - peeringLink := newLink(loc, PeeringResourceType, route.Target.HvnConnection.ID) - targetLink, err = linkURL(peeringLink) - if err != nil { - return err - } - case TgwAttachmentResourceType: - tgwAttLink := newLink(loc, PeeringResourceType, route.Target.HvnConnection.ID) - targetLink, err = linkURL(tgwAttLink) - if err != nil { - return err - } - default: - return errors.New("Unable to set self_link identifying the target - HVN Route target is not a known type.") + hvnLink := newLink(loc, route.Target.HvnConnection.Type, route.Target.HvnConnection.ID) + targetLink, err := linkURL(hvnLink) + if err != nil { + return err } if err := d.Set("target", map[string]interface{}{"self_link": targetLink}); err != nil { From 7a41938de9ad1610e7869d898e12791d89b364f3 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Thu, 29 Apr 2021 15:00:13 -0700 Subject: [PATCH 09/12] Use constant for HVN source type;flatter schema for HVN route data source by using target_link --- internal/provider/data_source_hvn_route.go | 13 +++++-------- internal/provider/resource_hvn_route.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index 04ca3eb0e..c9e75979d 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -35,13 +35,10 @@ func dataSourceHVNRoute() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "target": { - Description: "The target of the HVN route.", - Type: schema.TypeMap, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, + "target_link": { + Description: "A unique URL identifying the target of the HVN route.", + Type: schema.TypeString, + Computed: true, }, "state": { Description: "The state of the HVN route.", @@ -63,7 +60,7 @@ func dataSourceHVNRouteRead(ctx context.Context, d *schema.ResourceData, meta in hvn := d.Get("hvn").(string) var hvnLink *sharedmodels.HashicorpCloudLocationLink - hvnLink, err := parseLinkURL(hvn, "hashicorp.network.hvn") + hvnLink, err := parseLinkURL(hvn, HvnResourceType) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/resource_hvn_route.go b/internal/provider/resource_hvn_route.go index db86b705d..09192e82b 100644 --- a/internal/provider/resource_hvn_route.go +++ b/internal/provider/resource_hvn_route.go @@ -31,7 +31,7 @@ func setHVNRouteResourceData(d *schema.ResourceData, route *networkmodels.Hashic return err } - if err := d.Set("target", map[string]interface{}{"self_link": targetLink}); err != nil { + if err := d.Set("target_link", targetLink); err != nil { return err } From e8b260b9b20ea3f45160a43777d16adb9457a018 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Thu, 29 Apr 2021 15:07:39 -0700 Subject: [PATCH 10/12] Unbump terraform-plugin-sdk version;comment capitalization fix;regen docs --- docs/data-sources/hvn_route.md | 6 +++--- go.mod | 2 +- go.sum | 8 ++++---- internal/provider/data_source_hvn_route.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/data-sources/hvn_route.md b/docs/data-sources/hvn_route.md index 95efae97d..54fad111c 100644 --- a/docs/data-sources/hvn_route.md +++ b/docs/data-sources/hvn_route.md @@ -3,12 +3,12 @@ page_title: "hcp_hvn_route Data Source - terraform-provider-hcp" subcategory: "" description: |- - The HVN Route data source provides information about an existing HVN route. + The HVN route data source provides information about an existing HVN route. --- # hcp_hvn_route (Data Source) -The HVN Route data source provides information about an existing HVN route. +The HVN route data source provides information about an existing HVN route. ## Example Usage @@ -37,7 +37,7 @@ data "hcp_hvn_route" "example" { - **created_at** (String) The time that the HVN route was created. - **self_link** (String) A unique URL identifying the HVN route. - **state** (String) The state of the HVN route. -- **target** (Map of String) The target of the HVN route. +- **target_link** (String) A unique URL identifying the target of the HVN route. ### Nested Schema for `timeouts` diff --git a/go.mod b/go.mod index 793523f32..b556de2d6 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,6 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/hcp-sdk-go v0.7.0 github.com/hashicorp/terraform-plugin-docs v0.4.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0 github.com/stretchr/testify v1.7.0 ) diff --git a/go.sum b/go.sum index d28b429aa..fcf73e804 100644 --- a/go.sum +++ b/go.sum @@ -321,10 +321,10 @@ github.com/hashicorp/terraform-json v0.8.0 h1:XObQ3PgqU52YLQKEaJ08QtUshAfN3yu4u8 github.com/hashicorp/terraform-json v0.8.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= github.com/hashicorp/terraform-plugin-docs v0.4.0 h1:xJIXsMzBFwBvC1zcjoNz743GL2tNEfYFFU9+Hjp4Uek= github.com/hashicorp/terraform-plugin-docs v0.4.0/go.mod h1:fKj/V3t45tiXpSlUms/0G4OrBayyWpbUJ4WtLjBkINU= -github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA= -github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0 h1:mPZW0DDXlD70/Y+jenKz8fmkyxdmuE9T8mrftycxuZ0= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.0/go.mod h1:r2d5s4frIMvyjEuv4a47xI4f7mkaQlRu7bLgw2/LAaY= +github.com/hashicorp/terraform-plugin-go v0.2.1 h1:EW/R8bB2Zbkjmugzsy1d27yS8/0454b3MtYHkzOknqA= +github.com/hashicorp/terraform-plugin-go v0.2.1/go.mod h1:10V6F3taeDWVAoLlkmArKttR3IULlRWFAGtQIQTIDr4= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0 h1:4EHNOAjwiYCeBxY16rt2KwyRNNVsCaVO3kWBbiXfYM0= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0/go.mod h1:z+cMZ0iswzZOahBJ3XmNWgWkVnAd2bl8g+FhyyuPDH4= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index c9e75979d..19c23e19f 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -12,7 +12,7 @@ import ( func dataSourceHVNRoute() *schema.Resource { return &schema.Resource{ - Description: "The HVN Route data source provides information about an existing HVN route.", + Description: "The HVN route data source provides information about an existing HVN route.", ReadContext: dataSourceHVNRouteRead, Timeouts: &schema.ResourceTimeout{ Default: &hvnRouteDefaultTimeout, From cac528622db30f18bc46a8e086dfe71fedc276af Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Fri, 30 Apr 2021 12:46:15 -0700 Subject: [PATCH 11/12] Add validation for HVN route data source destination_cidr --- go.mod | 7 ++ go.sum | 102 +++++++++++++++------ internal/provider/data_source_hvn_route.go | 7 +- internal/provider/validators.go | 58 ++++++++++++ internal/provider/validators_test.go | 73 +++++++++++++++ 5 files changed, 217 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index b556de2d6..ee7c88546 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,19 @@ module github.com/hashicorp/terraform-provider-hcp go 1.15 require ( + github.com/armon/go-radix v1.0.0 // indirect + github.com/aws/aws-sdk-go v1.37.0 // indirect github.com/go-openapi/runtime v0.19.28 github.com/go-openapi/strfmt v0.20.1 github.com/google/uuid v1.2.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/hcl/v2 v2.8.2 // indirect github.com/hashicorp/hcp-sdk-go v0.7.0 + github.com/hashicorp/terraform-exec v0.13.3 // indirect github.com/hashicorp/terraform-plugin-docs v0.4.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0 + github.com/posener/complete v1.2.1 // indirect github.com/stretchr/testify v1.7.0 + golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect + google.golang.org/api v0.34.0 // indirect ) diff --git a/go.sum b/go.sum index fcf73e804..9ddf2fd76 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,9 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3Q github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -64,8 +67,11 @@ github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2 github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0 h1:bNEQyAGak9tojivJNkoqWErVCQbjdL7GzRt3F8NvfJ0= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -76,8 +82,9 @@ github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGL github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPIk= github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= +github.com/aws/aws-sdk-go v1.37.0 h1:GzFnhOIsrGyQ69s7VgqtrG2BG8v7X7vwB3Xpbd/DBBk= +github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= @@ -111,12 +118,15 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc= +github.com/go-git/go-billy/v5 v5.1.0 h1:4pl5BV4o7ZG/lterP4S6WzJ6xr49Ba5ET9ygheTYahk= +github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= -github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk= +github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M= +github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM= +github.com/go-git/go-git/v5 v5.3.0 h1:8WKMtJR2j8RntEXR/uvTKagfEt4GYlwQ7mntE4+0GWc= +github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -255,8 +265,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs= @@ -282,13 +293,15 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= -github.com/hashicorp/go-getter v1.5.0 h1:ciWJaeZWSMbc5OiLMpKp40MKFPqO44i0h3uyfXPBkkk= github.com/hashicorp/go-getter v1.5.0/go.mod h1:a7z7NPPfNQpJWcn4rSWFtdrSldqLdLPEF3d8nFMsSLM= +github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= +github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.15.0 h1:qMuK0wxsoW4D0ddCCYwPSTm4KQv1X1ke3WmPWZ0Mvsk= @@ -304,21 +317,25 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= +github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= +github.com/hashicorp/hcl/v2 v2.8.2 h1:wmFle3D1vu0okesm8BTLVDyJ6/OL9DCLUwn0b2OptiY= +github.com/hashicorp/hcl/v2 v2.8.2/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= github.com/hashicorp/hcp-sdk-go v0.7.0 h1:OtbcR/rMBlfK5BLowHIPe0HJtb0rEs8FyRAzS+xH9vI= github.com/hashicorp/hcp-sdk-go v0.7.0/go.mod h1:M+kmFj0s4KWNA5GVOgLhNtCTu3ypTR+QjWYIMgedA5Q= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.12.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= -github.com/hashicorp/terraform-exec v0.13.0 h1:1Pth+pdWJAufJuWWjaVOVNEkoRTOjGn3hQpAqj4aPdg= github.com/hashicorp/terraform-exec v0.13.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= -github.com/hashicorp/terraform-json v0.8.0 h1:XObQ3PgqU52YLQKEaJ08QtUshAfN3yu4u8ebSW0vztc= +github.com/hashicorp/terraform-exec v0.13.3 h1:R6L2mNpDGSEqtLrSONN8Xth0xYwNrnEVzDz6LF/oJPk= +github.com/hashicorp/terraform-exec v0.13.3/go.mod h1:SSg6lbUsVB3DmFyCPjBPklqf6EYGX0TlQ6QTxOlikDU= github.com/hashicorp/terraform-json v0.8.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= +github.com/hashicorp/terraform-json v0.10.0 h1:9syPD/Y5t+3uFjG8AiWVPu1bklJD8QB8iTCaJASc8oQ= +github.com/hashicorp/terraform-json v0.10.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= github.com/hashicorp/terraform-plugin-docs v0.4.0 h1:xJIXsMzBFwBvC1zcjoNz743GL2tNEfYFFU9+Hjp4Uek= github.com/hashicorp/terraform-plugin-docs v0.4.0/go.mod h1:fKj/V3t45tiXpSlUms/0G4OrBayyWpbUJ4WtLjBkINU= github.com/hashicorp/terraform-plugin-go v0.2.1 h1:EW/R8bB2Zbkjmugzsy1d27yS8/0454b3MtYHkzOknqA= @@ -332,12 +349,14 @@ github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -352,16 +371,20 @@ github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfE github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= -github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -412,7 +435,6 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= @@ -432,8 +454,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI= +github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -441,8 +464,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -468,8 +492,9 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaU github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= +github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= +github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= @@ -479,10 +504,12 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.7.1 h1:AvsC01GMhMLFL8CgEYdHGM+yLnnDOwhPAYcgTkeF0Gw= github.com/zclconf/go-cty v1.7.1/go.mod h1:VDR4+I79ubFBGm1uJac1226K5yANQFHeauxPBoP54+o= +github.com/zclconf/go-cty v1.8.2 h1:u+xZfBKgpycDnTNjPhGiTEYZS5qS/Sb5MqSfm7vzcjg= +github.com/zclconf/go-cty v1.8.2/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= @@ -510,8 +537,9 @@ golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -576,13 +604,18 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= +golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 h1:Mj83v+wSRNEar42a/MQgxk9X42TdEmrOl9i+y8WbxLo= golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -594,6 +627,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -614,6 +648,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -631,8 +666,15 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 h1:B6caxRw+hozq68X2MY7jEpZh/cr4/aHLv9xU8Kkadrw= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -690,8 +732,10 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d h1:W07d4xkoAUSNOkOzdzXCdFGxT7o2rW4q8M34tB2i//k= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb h1:KVWk3RW1AZlxWum4tYqegLgwJHb5oouozcGM8HfNQaw= +golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -712,8 +756,9 @@ google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0 h1:yfrXXP61wVuLb0vBcG6qaOoIoqYEzOQS8jum51jkv2w= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.34.0 h1:k40adF3uR+6x/+hO5Dh4ZFUqFp67vxvbpafFiJxl10A= +google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -751,8 +796,9 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987 h1:PDIOdWxZ8eRizhKa1AAvY53xsvLB1cWorMjslvY3VA8= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -766,6 +812,7 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -782,8 +829,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index 19c23e19f..93f7d12f5 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -25,9 +25,10 @@ func dataSourceHVNRoute() *schema.Resource { Required: true, }, "destination_cidr": { - Description: "The destination CIDR of the HVN route", - Type: schema.TypeString, - Required: true, + Description: "The destination CIDR of the HVN route", + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: validateIsStartOfPrivateCIDRRange, }, // Computed outputs "self_link": { diff --git a/internal/provider/validators.go b/internal/provider/validators.go index 5f2ee5044..6fd069509 100644 --- a/internal/provider/validators.go +++ b/internal/provider/validators.go @@ -2,6 +2,7 @@ package provider import ( "fmt" + "net" "regexp" "strings" @@ -148,3 +149,60 @@ func validateConsulClusterSize(v interface{}, path cty.Path) diag.Diagnostics { return diagnostics } + +// validateIsStartOfPrivateCIDRRange validates that a value passed is (a)a valid +// CIDR, (b)a valid RFC 1819 address, and (c)at the start of the CIDR range. +func validateIsStartOfPrivateCIDRRange(v interface{}, path cty.Path) diag.Diagnostics { + var diagnostics diag.Diagnostics + + // Validation fails if value is not string. + s, ok := v.(string) + if !ok { + msg := fmt.Sprintf("expected type of %v to be string", v) + diagnostics = append(diagnostics, diag.Diagnostic{ + Severity: diag.Error, + Summary: msg, + Detail: msg, + AttributePath: path, + }) + return diagnostics + } + + // Validation fails if string cannot be parsed as CIDR. + ip, net, err := net.ParseCIDR(s) + if err != nil { + msg := fmt.Sprintf("expected \"%v\" to be a valid IPv4 value", v) + diagnostics = append(diagnostics, diag.Diagnostic{ + Severity: diag.Error, + Summary: msg, + Detail: msg, + AttributePath: path, + }) + return diagnostics + } + + // Validation fails if address is not within valid RFC 1819 ranges + if !regexp.MustCompile(`^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\..*`).MatchString(v.(string)) { + msg := "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16" + diagnostics = append(diagnostics, diag.Diagnostic{ + Severity: diag.Error, + Summary: msg, + Detail: msg, + AttributePath: path, + }) + return diagnostics + } + + // Validation fails if value is not at the beginning of the CIDR range. + if !ip.Equal(net.IP) { + msg := fmt.Sprintf("invalid CIDR range start %v, should have been %v", ip, net.IP) + diagnostics = append(diagnostics, diag.Diagnostic{ + Severity: diag.Error, + Summary: msg, + Detail: msg + "; CIDR value must be at the start of the range", + AttributePath: path, + }) + } + + return diagnostics +} diff --git a/internal/provider/validators_test.go b/internal/provider/validators_test.go index cd71924db..d8a37b449 100644 --- a/internal/provider/validators_test.go +++ b/internal/provider/validators_test.go @@ -341,3 +341,76 @@ func Test_validateConsulClusterSize(t *testing.T) { }) } } + +func Test_validateIsStartOfPrivateCIDRRange(t *testing.T) { + tcs := map[string]struct { + expected diag.Diagnostics + input string + }{ + "valid CIDR case A": { + input: "192.168.0.0/20", + expected: nil, + }, + "valid CIDR case B": { + input: "172.25.16.0/24", + expected: nil, + }, + "valid CIDR case C": { + input: "10.0.0.0/16", + expected: nil, + }, + "not a CIDR case A": { + input: "string123", + expected: diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Error, + Summary: "expected \"string123\" to be a valid IPv4 value", + Detail: "expected \"string123\" to be a valid IPv4 value", + AttributePath: nil, + }, + }, + }, + "not a CIDR case B": { + input: "10.255.255asdfasdfaqsd.250", + expected: diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Error, + Summary: "expected \"10.255.255asdfasdfaqsd.250\" to be a valid IPv4 value", + Detail: "expected \"10.255.255asdfasdfaqsd.250\" to be a valid IPv4 value", + AttributePath: nil, + }, + }, + }, + "invalid CIDR": { + input: "87.70.141.1/22", + expected: diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Error, + Summary: "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16", + Detail: "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16", + AttributePath: nil, + }, + }, + }, + "not start of range": { + input: "192.168.255.255/24", + expected: diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Error, + Summary: "invalid CIDR range start 192.168.255.255, should have been 192.168.255.0", + Detail: "invalid CIDR range start 192.168.255.255, should have been 192.168.255.0; CIDR value must be at the start of the range", + AttributePath: nil, + }, + }, + }, + } + + for n, tc := range tcs { + t.Run(n, func(t *testing.T) { + r := require.New(t) + + result := validateIsStartOfPrivateCIDRRange(tc.input, nil) + r.Equal(tc.expected, result) + }) + } +} From ebe9f22548527af5219c94d6bb01b68a02494506 Mon Sep 17 00:00:00 2001 From: Ti Zhang Date: Mon, 3 May 2021 10:17:28 -0700 Subject: [PATCH 12/12] Replace custom validator with IsCIDR --- internal/provider/data_source_hvn_route.go | 9 +-- internal/provider/validators.go | 58 ----------------- internal/provider/validators_test.go | 73 ---------------------- 3 files changed, 5 insertions(+), 135 deletions(-) diff --git a/internal/provider/data_source_hvn_route.go b/internal/provider/data_source_hvn_route.go index 93f7d12f5..04380ec29 100644 --- a/internal/provider/data_source_hvn_route.go +++ b/internal/provider/data_source_hvn_route.go @@ -7,6 +7,7 @@ import ( sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-hcp/internal/clients" ) @@ -25,10 +26,10 @@ func dataSourceHVNRoute() *schema.Resource { Required: true, }, "destination_cidr": { - Description: "The destination CIDR of the HVN route", - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: validateIsStartOfPrivateCIDRRange, + Description: "The destination CIDR of the HVN route", + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsCIDR, }, // Computed outputs "self_link": { diff --git a/internal/provider/validators.go b/internal/provider/validators.go index 6fd069509..5f2ee5044 100644 --- a/internal/provider/validators.go +++ b/internal/provider/validators.go @@ -2,7 +2,6 @@ package provider import ( "fmt" - "net" "regexp" "strings" @@ -149,60 +148,3 @@ func validateConsulClusterSize(v interface{}, path cty.Path) diag.Diagnostics { return diagnostics } - -// validateIsStartOfPrivateCIDRRange validates that a value passed is (a)a valid -// CIDR, (b)a valid RFC 1819 address, and (c)at the start of the CIDR range. -func validateIsStartOfPrivateCIDRRange(v interface{}, path cty.Path) diag.Diagnostics { - var diagnostics diag.Diagnostics - - // Validation fails if value is not string. - s, ok := v.(string) - if !ok { - msg := fmt.Sprintf("expected type of %v to be string", v) - diagnostics = append(diagnostics, diag.Diagnostic{ - Severity: diag.Error, - Summary: msg, - Detail: msg, - AttributePath: path, - }) - return diagnostics - } - - // Validation fails if string cannot be parsed as CIDR. - ip, net, err := net.ParseCIDR(s) - if err != nil { - msg := fmt.Sprintf("expected \"%v\" to be a valid IPv4 value", v) - diagnostics = append(diagnostics, diag.Diagnostic{ - Severity: diag.Error, - Summary: msg, - Detail: msg, - AttributePath: path, - }) - return diagnostics - } - - // Validation fails if address is not within valid RFC 1819 ranges - if !regexp.MustCompile(`^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\..*`).MatchString(v.(string)) { - msg := "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16" - diagnostics = append(diagnostics, diag.Diagnostic{ - Severity: diag.Error, - Summary: msg, - Detail: msg, - AttributePath: path, - }) - return diagnostics - } - - // Validation fails if value is not at the beginning of the CIDR range. - if !ip.Equal(net.IP) { - msg := fmt.Sprintf("invalid CIDR range start %v, should have been %v", ip, net.IP) - diagnostics = append(diagnostics, diag.Diagnostic{ - Severity: diag.Error, - Summary: msg, - Detail: msg + "; CIDR value must be at the start of the range", - AttributePath: path, - }) - } - - return diagnostics -} diff --git a/internal/provider/validators_test.go b/internal/provider/validators_test.go index d8a37b449..cd71924db 100644 --- a/internal/provider/validators_test.go +++ b/internal/provider/validators_test.go @@ -341,76 +341,3 @@ func Test_validateConsulClusterSize(t *testing.T) { }) } } - -func Test_validateIsStartOfPrivateCIDRRange(t *testing.T) { - tcs := map[string]struct { - expected diag.Diagnostics - input string - }{ - "valid CIDR case A": { - input: "192.168.0.0/20", - expected: nil, - }, - "valid CIDR case B": { - input: "172.25.16.0/24", - expected: nil, - }, - "valid CIDR case C": { - input: "10.0.0.0/16", - expected: nil, - }, - "not a CIDR case A": { - input: "string123", - expected: diag.Diagnostics{ - diag.Diagnostic{ - Severity: diag.Error, - Summary: "expected \"string123\" to be a valid IPv4 value", - Detail: "expected \"string123\" to be a valid IPv4 value", - AttributePath: nil, - }, - }, - }, - "not a CIDR case B": { - input: "10.255.255asdfasdfaqsd.250", - expected: diag.Diagnostics{ - diag.Diagnostic{ - Severity: diag.Error, - Summary: "expected \"10.255.255asdfasdfaqsd.250\" to be a valid IPv4 value", - Detail: "expected \"10.255.255asdfasdfaqsd.250\" to be a valid IPv4 value", - AttributePath: nil, - }, - }, - }, - "invalid CIDR": { - input: "87.70.141.1/22", - expected: diag.Diagnostics{ - diag.Diagnostic{ - Severity: diag.Error, - Summary: "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16", - Detail: "must be within 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16", - AttributePath: nil, - }, - }, - }, - "not start of range": { - input: "192.168.255.255/24", - expected: diag.Diagnostics{ - diag.Diagnostic{ - Severity: diag.Error, - Summary: "invalid CIDR range start 192.168.255.255, should have been 192.168.255.0", - Detail: "invalid CIDR range start 192.168.255.255, should have been 192.168.255.0; CIDR value must be at the start of the range", - AttributePath: nil, - }, - }, - }, - } - - for n, tc := range tcs { - t.Run(n, func(t *testing.T) { - r := require.New(t) - - result := validateIsStartOfPrivateCIDRRange(tc.input, nil) - r.Equal(tc.expected, result) - }) - } -}