forked from Azure/ARO-RP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests for multiple ips per loadbalancer (Azure#3183)
* add azureclient for 2023-07-01-preview * add UpdateAndWait to oc azure client * add e2e test for managed outbound IPs
- Loading branch information
1 parent
447445d
commit d5937fa
Showing
6 changed files
with
323 additions
and
4 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
.../azureclient/mgmt/redhatopenshift/2023-07-01-preview/redhatopenshift/openshiftclusters.go
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,54 @@ | ||
package redhatopenshift | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"context" | ||
"crypto/tls" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/Azure/go-autorest/autorest" | ||
|
||
mgmtredhatopenshift20230701preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-07-01-preview/redhatopenshift" | ||
"github.com/Azure/ARO-RP/pkg/env" | ||
"github.com/Azure/ARO-RP/pkg/util/azureclient" | ||
) | ||
|
||
// OpenShiftClustersClient is a minimal interface for azure OpenshiftClustersClient | ||
type OpenShiftClustersClient interface { | ||
ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result mgmtredhatopenshift20230701preview.OpenShiftClusterCredentials, err error) | ||
Get(ctx context.Context, resourceGroupName string, resourceName string) (result mgmtredhatopenshift20230701preview.OpenShiftCluster, err error) | ||
OpenShiftClustersClientAddons | ||
} | ||
|
||
type openShiftClustersClient struct { | ||
mgmtredhatopenshift20230701preview.OpenShiftClustersClient | ||
} | ||
|
||
var _ OpenShiftClustersClient = &openShiftClustersClient{} | ||
|
||
// NewOpenShiftClustersClient creates a new OpenShiftClustersClient | ||
func NewOpenShiftClustersClient(environment *azureclient.AROEnvironment, subscriptionID string, authorizer autorest.Authorizer) OpenShiftClustersClient { | ||
var client mgmtredhatopenshift20230701preview.OpenShiftClustersClient | ||
if env.IsLocalDevelopmentMode() { | ||
client = mgmtredhatopenshift20230701preview.NewOpenShiftClustersClientWithBaseURI("https://localhost:8443", subscriptionID) | ||
client.Sender = &http.Client{ | ||
Transport: &http.Transport{ | ||
TLSClientConfig: &tls.Config{ | ||
InsecureSkipVerify: true, // #nosec G402 | ||
}, | ||
}, | ||
} | ||
} else { | ||
client = mgmtredhatopenshift20230701preview.NewOpenShiftClustersClientWithBaseURI(environment.ResourceManagerEndpoint, subscriptionID) | ||
client.Authorizer = authorizer | ||
} | ||
client.PollingDelay = 10 * time.Second | ||
client.PollingDuration = 2 * time.Hour | ||
|
||
return &openShiftClustersClient{ | ||
OpenShiftClustersClient: client, | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...lient/mgmt/redhatopenshift/2023-07-01-preview/redhatopenshift/openshiftclusters_addons.go
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,82 @@ | ||
package redhatopenshift | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"context" | ||
|
||
mgmtredhatopenshift20230701preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-07-01-preview/redhatopenshift" | ||
) | ||
|
||
// OpenShiftClustersClientAddons contains addons for OpenShiftClustersClient | ||
type OpenShiftClustersClientAddons interface { | ||
CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20230701preview.OpenShiftCluster) error | ||
UpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20230701preview.OpenShiftClusterUpdate) error | ||
DeleteAndWait(ctx context.Context, resourceGroupName string, resourceName string) error | ||
List(ctx context.Context) (clusters []mgmtredhatopenshift20230701preview.OpenShiftCluster, err error) | ||
ListByResourceGroup(ctx context.Context, resourceGroupName string) (clusters []mgmtredhatopenshift20230701preview.OpenShiftCluster, err error) | ||
} | ||
|
||
func (c *openShiftClustersClient) CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20230701preview.OpenShiftCluster) error { | ||
future, err := c.CreateOrUpdate(ctx, resourceGroupName, resourceName, parameters) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return future.WaitForCompletionRef(ctx, c.Client) | ||
} | ||
|
||
func (c *openShiftClustersClient) UpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20230701preview.OpenShiftClusterUpdate) error { | ||
future, err := c.Update(ctx, resourceGroupName, resourceName, parameters) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return future.WaitForCompletionRef(ctx, c.Client) | ||
} | ||
|
||
func (c *openShiftClustersClient) DeleteAndWait(ctx context.Context, resourceGroupName string, resourceName string) error { | ||
future, err := c.Delete(ctx, resourceGroupName, resourceName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return future.WaitForCompletionRef(ctx, c.Client) | ||
} | ||
|
||
func (c *openShiftClustersClient) List(ctx context.Context) (clusters []mgmtredhatopenshift20230701preview.OpenShiftCluster, err error) { | ||
page, err := c.OpenShiftClustersClient.List(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for page.NotDone() { | ||
clusters = append(clusters, page.Values()...) | ||
|
||
err = page.NextWithContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return clusters, nil | ||
} | ||
|
||
func (c *openShiftClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (clusters []mgmtredhatopenshift20230701preview.OpenShiftCluster, err error) { | ||
page, err := c.OpenShiftClustersClient.ListByResourceGroup(ctx, resourceGroupName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for page.NotDone() { | ||
clusters = append(clusters, page.Values()...) | ||
|
||
err = page.NextWithContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return clusters, nil | ||
} |
48 changes: 48 additions & 0 deletions
48
pkg/util/azureclient/mgmt/redhatopenshift/2023-07-01-preview/redhatopenshift/operations.go
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,48 @@ | ||
package redhatopenshift | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"crypto/tls" | ||
"net/http" | ||
|
||
"github.com/Azure/go-autorest/autorest" | ||
|
||
mgmtredhatopenshift20230701preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-07-01-preview/redhatopenshift" | ||
"github.com/Azure/ARO-RP/pkg/env" | ||
"github.com/Azure/ARO-RP/pkg/util/azureclient" | ||
) | ||
|
||
// OperationsClient is a minimal interface for azure OperationsClient | ||
type OperationsClient interface { | ||
OperationsClientAddons | ||
} | ||
|
||
type operationsClient struct { | ||
mgmtredhatopenshift20230701preview.OperationsClient | ||
} | ||
|
||
var _ OperationsClient = &operationsClient{} | ||
|
||
// NewOperationsClient creates a new OperationsClient | ||
func NewOperationsClient(environment *azureclient.AROEnvironment, subscriptionID string, authorizer autorest.Authorizer) OperationsClient { | ||
var client mgmtredhatopenshift20230701preview.OperationsClient | ||
if env.IsLocalDevelopmentMode() { | ||
client = mgmtredhatopenshift20230701preview.NewOperationsClientWithBaseURI("https://localhost:8443", subscriptionID) | ||
client.Sender = &http.Client{ | ||
Transport: &http.Transport{ | ||
TLSClientConfig: &tls.Config{ | ||
InsecureSkipVerify: true, // #nosec G402 | ||
}, | ||
}, | ||
} | ||
} else { | ||
client = mgmtredhatopenshift20230701preview.NewOperationsClientWithBaseURI(environment.ResourceManagerEndpoint, subscriptionID) | ||
client.Authorizer = authorizer | ||
} | ||
|
||
return &operationsClient{ | ||
OperationsClient: client, | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../azureclient/mgmt/redhatopenshift/2023-07-01-preview/redhatopenshift/operations_addons.go
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,33 @@ | ||
package redhatopenshift | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"context" | ||
|
||
mgmtredhatopenshift20230701preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-07-01-preview/redhatopenshift" | ||
) | ||
|
||
// OperationsClientAddons contains addons for OperationsClient | ||
type OperationsClientAddons interface { | ||
List(ctx context.Context) (operations []mgmtredhatopenshift20230701preview.Operation, err error) | ||
} | ||
|
||
func (c *operationsClient) List(ctx context.Context) (operations []mgmtredhatopenshift20230701preview.Operation, err error) { | ||
page, err := c.OperationsClient.List(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for page.NotDone() { | ||
operations = append(operations, page.Values()...) | ||
|
||
err = page.NextWithContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return operations, nil | ||
} |
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