Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump github.com/cloudflare/cloudflare-go from 0.70.0 to 0.72.0 #588

Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/cloudflare/cloudflare-go v0.70.0
github.com/cloudflare/cloudflare-go v0.72.0
github.com/dnaeon/go-vcr v1.2.0
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hc-install v0.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/cloudflare-go v0.70.0 h1:4opGbUygM8DjirUuaz23jn3akuAcnOCEx+0nQtQEcFo=
github.com/cloudflare/cloudflare-go v0.70.0/go.mod h1:VW6GuazkaZ4xEDkFt24lkXQUsE8q7BiGqDniC2s8WEM=
github.com/cloudflare/cloudflare-go v0.72.0 h1:khsJV4IE3I7U8eK9CUreGnxQm16MEFN5d0xPJfPnA+0=
github.com/cloudflare/cloudflare-go v0.72.0/go.mod h1:VW6GuazkaZ4xEDkFt24lkXQUsE8q7BiGqDniC2s8WEM=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down
161 changes: 56 additions & 105 deletions internal/app/cf-terraforming/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,113 +101,64 @@ func generateResources() func(cmd *cobra.Command, args []string) {
// restrictions and the need to explicitly map out the structs.
var jsonStructData []interface{}

var identifier *cloudflare.ResourceContainer
if accountID != "" {
identifier = cloudflare.AccountIdentifier(accountID)
} else {
identifier = cloudflare.ZoneIdentifier(zoneID)
}

switch resourceType {
case "cloudflare_access_application":
if accountID != "" {
jsonPayload, _, err := api.AccessApplications(context.Background(), accountID, cloudflare.PaginationOptions{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
} else {
jsonPayload, _, err := api.ZoneLevelAccessApplications(context.Background(), zoneID, cloudflare.PaginationOptions{})
if err != nil {
log.Fatal(err)
}
jsonPayload, _, err := api.ListAccessApplications(context.Background(), identifier, cloudflare.ListAccessApplicationsParams{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
case "cloudflare_access_group":
if accountID != "" {
jsonPayload, _, err := api.AccessGroups(context.Background(), accountID, cloudflare.PaginationOptions{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
} else {
jsonPayload, _, err := api.ZoneLevelAccessGroups(context.Background(), zoneID, cloudflare.PaginationOptions{})
if err != nil {
log.Fatal(err)
}
jsonPayload, _, err := api.ListAccessGroups(context.Background(), identifier, cloudflare.ListAccessGroupsParams{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
case "cloudflare_access_identity_provider":
if accountID != "" {
jsonPayload, err := api.AccessIdentityProviders(context.Background(), accountID)
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
} else {
jsonPayload, err := api.ZoneLevelAccessIdentityProviders(context.Background(), zoneID)
if err != nil {
log.Fatal(err)
}
jsonPayload, _, err := api.ListAccessIdentityProviders(context.Background(), identifier, cloudflare.ListAccessIdentityProvidersParams{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
case "cloudflare_access_service_token":
if accountID != "" {
jsonPayload, _, err := api.AccessServiceTokens(context.Background(), accountID)
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
} else {
jsonPayload, _, err := api.ZoneLevelAccessServiceTokens(context.Background(), zoneID)
if err != nil {
log.Fatal(err)
}
jsonPayload, _, err := api.ListAccessServiceTokens(context.Background(), identifier, cloudflare.ListAccessServiceTokensParams{})
if err != nil {
log.Fatal(err)
}

resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
err = json.Unmarshal(m, &jsonStructData)
if err != nil {
log.Fatal(err)
}
case "cloudflare_access_mutual_tls_certificate":
jsonPayload, err := api.AccessMutualTLSCertificates(context.Background(), accountID)
jsonPayload, _, err := api.ListAccessMutualTLSCertificates(context.Background(), identifier, cloudflare.ListAccessMutualTLSCertificatesParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -295,7 +246,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
}
case "cloudflare_api_shield":
jsonPayload := []cloudflare.APIShield{}
apiShieldConfig, _, err := api.GetAPIShieldConfiguration(context.Background(), cloudflare.ZoneIdentifier(zoneID))
apiShieldConfig, _, err := api.GetAPIShieldConfiguration(context.Background(), identifier)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -447,7 +398,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
jsonStructData[i].(map[string]interface{})["status"] = nil
}
case "cloudflare_filter":
jsonPayload, _, err := api.Filters(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.FilterListParams{})
jsonPayload, _, err := api.Filters(context.Background(), identifier, cloudflare.FilterListParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -459,7 +410,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_firewall_rule":
jsonPayload, _, err := api.FirewallRules(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.FirewallRuleListParams{})
jsonPayload, _, err := api.FirewallRules(context.Background(), identifier, cloudflare.FirewallRuleListParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -516,7 +467,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_load_balancer":
jsonPayload, err := api.ListLoadBalancers(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListLoadBalancerParams{})
jsonPayload, err := api.ListLoadBalancers(context.Background(), identifier, cloudflare.ListLoadBalancerParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -561,7 +512,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
}

case "cloudflare_load_balancer_pool":
jsonPayload, err := api.ListLoadBalancerPools(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListLoadBalancerPoolParams{})
jsonPayload, err := api.ListLoadBalancerPools(context.Background(), identifier, cloudflare.ListLoadBalancerPoolParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -582,7 +533,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
}
}
case "cloudflare_load_balancer_monitor":
jsonPayload, err := api.ListLoadBalancerMonitors(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListLoadBalancerMonitorParams{})
jsonPayload, err := api.ListLoadBalancerMonitors(context.Background(), identifier, cloudflare.ListLoadBalancerMonitorParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -594,7 +545,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_logpush_job":
jsonPayload, err := api.LogpushJobs(context.Background(), zoneID)
jsonPayload, err := api.ListLogpushJobs(context.Background(), identifier, cloudflare.ListLogpushJobsParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -732,7 +683,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {

case "cloudflare_record":
simpleDNSTypes := []string{"A", "AAAA", "CNAME", "TXT", "MX", "NS", "PTR"}
jsonPayload, _, err := api.ListDNSRecords(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListDNSRecordsParams{})
jsonPayload, _, err := api.ListDNSRecords(context.Background(), identifier, cloudflare.ListDNSRecordsParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -969,7 +920,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
jsonStructData[i].(map[string]interface{})["connections"] = nil
}
case "cloudflare_turnstile_widget":
jsonPayload, _, err := api.ListTurnstileWidgets(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListTurnstileWidgetParams{})
jsonPayload, _, err := api.ListTurnstileWidgets(context.Background(), identifier, cloudflare.ListTurnstileWidgetParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -1012,7 +963,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_workers_kv_namespace":
jsonPayload, _, err := api.ListWorkersKVNamespaces(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListWorkersKVNamespacesParams{})
jsonPayload, _, err := api.ListWorkersKVNamespaces(context.Background(), identifier, cloudflare.ListWorkersKVNamespacesParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -1023,7 +974,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_worker_route":
jsonPayload, err := api.ListWorkerRoutes(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListWorkerRoutesParams{})
jsonPayload, err := api.ListWorkerRoutes(context.Background(), identifier, cloudflare.ListWorkerRoutesParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -1064,7 +1015,7 @@ func generateResources() func(cmd *cobra.Command, args []string) {
jsonStructData[i].(map[string]interface{})["account_id"] = jsonStructData[i].(map[string]interface{})["account"].(map[string]interface{})["id"].(string)
}
case "cloudflare_zone_lockdown":
jsonPayload, _, err := api.ListZoneLockdowns(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.LockdownListParams{})
jsonPayload, _, err := api.ListZoneLockdowns(context.Background(), identifier, cloudflare.LockdownListParams{})
if err != nil {
log.Fatal(err)
}
Expand Down
30 changes: 19 additions & 11 deletions internal/app/cf-terraforming/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ var importCommand = &cobra.Command{
func runImport() func(cmd *cobra.Command, args []string) {
return func(cmd *cobra.Command, args []string) {
var jsonStructData []interface{}

var identifier *cloudflare.ResourceContainer
if accountID != "" {
identifier = cloudflare.AccountIdentifier(accountID)
} else {
identifier = cloudflare.ZoneIdentifier(zoneID)
}

switch resourceType {
case "cloudflare_access_rule":
if accountID != "" {
Expand Down Expand Up @@ -159,7 +167,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
}
}
case "cloudflare_filter":
jsonPayload, _, err := api.Filters(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.FilterListParams{})
jsonPayload, _, err := api.Filters(context.Background(), identifier, cloudflare.FilterListParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -169,7 +177,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_firewall_rule":
jsonPayload, _, err := api.FirewallRules(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.FirewallRuleListParams{})
jsonPayload, _, err := api.FirewallRules(context.Background(), identifier, cloudflare.FirewallRuleListParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -220,7 +228,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_load_balancer":
jsonPayload, err := api.ListLoadBalancers(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListLoadBalancerParams{})
jsonPayload, err := api.ListLoadBalancers(context.Background(), identifier, cloudflare.ListLoadBalancerParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -230,7 +238,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_load_balancer_pool":
jsonPayload, err := api.ListLoadBalancerPools(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListLoadBalancerPoolParams{})
jsonPayload, err := api.ListLoadBalancerPools(context.Background(), identifier, cloudflare.ListLoadBalancerPoolParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -240,7 +248,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_load_balancer_monitor":
jsonPayload, err := api.ListLoadBalancerMonitors(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListLoadBalancerMonitorParams{})
jsonPayload, err := api.ListLoadBalancerMonitors(context.Background(), identifier, cloudflare.ListLoadBalancerMonitorParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -250,7 +258,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_logpush_job":
jsonPayload, err := api.LogpushJobs(context.Background(), zoneID)
jsonPayload, err := api.ListLogpushJobs(context.Background(), identifier, cloudflare.ListLogpushJobsParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -293,7 +301,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_record":
jsonPayload, _, err := api.ListDNSRecords(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListDNSRecordsParams{})
jsonPayload, _, err := api.ListDNSRecords(context.Background(), identifier, cloudflare.ListDNSRecordsParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -362,7 +370,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_turnstile_widget":
jsonPayload, _, err := api.ListTurnstileWidgets(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListTurnstileWidgetParams{})
jsonPayload, _, err := api.ListTurnstileWidgets(context.Background(), identifier, cloudflare.ListTurnstileWidgetParams{})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -407,7 +415,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_workers_kv_namespace":
jsonPayload, _, err := api.ListWorkersKVNamespaces(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListWorkersKVNamespacesParams{})
jsonPayload, _, err := api.ListWorkersKVNamespaces(context.Background(), identifier, cloudflare.ListWorkersKVNamespacesParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -418,7 +426,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_worker_route":
jsonPayload, err := api.ListWorkerRoutes(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListWorkerRoutesParams{})
jsonPayload, err := api.ListWorkerRoutes(context.Background(), identifier, cloudflare.ListWorkerRoutesParams{})
if err != nil {
log.Fatal(err)
}
Expand All @@ -439,7 +447,7 @@ func runImport() func(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
case "cloudflare_zone_lockdown":
jsonPayload, _, err := api.ListZoneLockdowns(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.LockdownListParams{})
jsonPayload, _, err := api.ListZoneLockdowns(context.Background(), identifier, cloudflare.LockdownListParams{})
if err != nil {
log.Fatal(err)
}
Expand Down
Loading