-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3262 from cloudflare/mux-cloudflare-go-versions
provider: introduce a muxed client
- Loading branch information
Showing
45 changed files
with
551 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:internal | ||
provider: introduce a muxed client to support using cloudflare-go/v0 and cloudflare-go/v2 together | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
examples/data-sources/cloudflare_account_roles/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package muxclient | ||
|
||
import ( | ||
cfv1 "github.com/cloudflare/cloudflare-go" | ||
cfv2 "github.com/cloudflare/cloudflare-go/v2" | ||
) | ||
|
||
// Client is the intermediatry structure to allow us to run both versions of the | ||
// Go SDK alongside one another without collisions. | ||
// | ||
// The usage is resource dependent and no safe guards are included here. | ||
type Client struct { | ||
V1 *cfv1.API | ||
V2 *cfv2.Client | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package muxclient_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
cfv1 "github.com/cloudflare/cloudflare-go" | ||
cfv2 "github.com/cloudflare/cloudflare-go/v2" | ||
"github.com/cloudflare/cloudflare-go/v2/option" | ||
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/muxclient" | ||
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/provider" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMuxClientInitialised(t *testing.T) { | ||
c1 := muxclient.Client{} | ||
assert.Empty(t, c1) | ||
|
||
v1Config := provider.Config{} | ||
v1Config.Email = "user@example.com" | ||
cfv1Client, _ := v1Config.Client(context.TODO()) | ||
|
||
cfv2Client := cfv2.NewClient( | ||
option.WithAPIEmail("user@example.com"), | ||
) | ||
c2 := &muxclient.Client{ | ||
V1: cfv1Client, | ||
V2: cfv2Client, | ||
} | ||
|
||
assert.NotEmpty(t, c2) | ||
assert.IsType(t, &cfv1.API{}, cfv1Client) | ||
assert.IsType(t, &cfv2.Client{}, cfv2Client) | ||
assert.IsType(t, &muxclient.Client{}, c2) | ||
} |
Oops, something went wrong.