Skip to content

Commit

Permalink
adding 2023-11-22 stable
Browse files Browse the repository at this point in the history
  • Loading branch information
b-jhoreman committed Jan 15, 2024
1 parent a74bdf1 commit 8ac47de
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .sha256sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ b1f1de0fe40d05de90742b17928968923b936adc294000f58974f50a297581dd swagger/redhat
01ba9562a8dac2824998ff0ad0d2465f79e6a66597bdb321e9409b9f2d12d222 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-04-01/redhatopenshift.json
c023515341196746454c0ae7af077d40d3ec13f6b88b33cb558f0a7ab17a5a24 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2023-07-01-preview/redhatopenshift.json
440748951dd1c3b34b5ccbdcb7cd966e3b89490887a1f1d64429561fad789515 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-09-04/redhatopenshift.json
695bf8dea5e971d23b77e9468f64cbc8abf877b86cd1486b84d6150b5e717ce0 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22/redhatopenshift.json
98b241e3225ff4bbe96f4046aea98dae06c2bac2cc0e25ab8d85583bfc7f1861 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22/redhatopenshift.json
6 changes: 0 additions & 6 deletions pkg/api/v20231122/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ type LoadBalancerProfile struct {
ManagedOutboundIPs *ManagedOutboundIPs `json:"managedOutboundIps,omitempty" mutable:"true"`
// The list of effective outbound IP addresses of the public load balancer.
EffectiveOutboundIPs []EffectiveOutboundIP `json:"effectiveOutboundIps,omitempty" swagger:"readOnly"`
// The desired outbound IP resources for the cluster load balancer.
OutboundIPs []OutboundIP `json:"outboundIps,omitempty" mutable:"true"`
// The desired outbound IP Prefix resources for the cluster load balancer.
OutboundIPPrefixes []OutboundIPPrefix `json:"outboundIpPrefixes,omitempty" mutable:"true"`
// The desired number of allocated SNAT ports per VM. Allowed values are in the range of 0 to 64000 (inclusive). The default value is 1024.
AllocatedOutboundPorts *int `json:"allocatedOutboundPorts,omitempty" mutable:"true"`
}

// EffectiveOutboundIP represents an effective outbound IP resource of the cluster public load balancer.
Expand Down
38 changes: 0 additions & 38 deletions pkg/api/v20231122/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
if oc.Properties.NetworkProfile.LoadBalancerProfile != nil {
out.Properties.NetworkProfile.LoadBalancerProfile = &LoadBalancerProfile{}

if oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts = oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts
}

if oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs = &ManagedOutboundIPs{
Count: oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs.Count,
Expand All @@ -76,24 +72,6 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
})
}
}

if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs = make([]OutboundIP, 0, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs))
for _, outboundIP := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs = append(out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs, OutboundIP{
ID: outboundIP.ID,
})
}
}

if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = make([]OutboundIPPrefix, 0, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes))
for _, outboundIPPrefix := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = append(out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes, OutboundIPPrefix{
ID: outboundIPPrefix.ID,
})
}
}
}

if oc.Properties.WorkerProfiles != nil {
Expand Down Expand Up @@ -216,27 +194,11 @@ func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShif

out.Properties.NetworkProfile.LoadBalancerProfile = &loadBalancerProfile

if oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts = oc.Properties.NetworkProfile.LoadBalancerProfile.AllocatedOutboundPorts
}

if oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs = &api.ManagedOutboundIPs{
Count: oc.Properties.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs.Count,
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs = make([]api.OutboundIP, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs))
for i := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs[i].ID = oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPs[i].ID
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = make([]api.OutboundIPPrefix, len(oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes))
for i := range oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes {
out.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes[i].ID = oc.Properties.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes[i].ID
}
}
if oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs != nil {
out.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = make([]api.EffectiveOutboundIP, len(oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs))
for i := range oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs {
Expand Down
46 changes: 3 additions & 43 deletions pkg/api/v20231122/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func (sv openShiftClusterStaticValidator) validateProperties(path string, p *Ope
if err := sv.validateNetworkProfile(path+".networkProfile", &p.NetworkProfile, p.APIServerProfile.Visibility, p.IngressProfiles[0].Visibility); err != nil {
return err
}
if err := sv.validateLoadBalancerProfile(path+".networkProfile.loadBalancerProfile", p.NetworkProfile.LoadBalancerProfile, isCreate); err != nil {
return err
}
if err := sv.validateMasterProfile(path+".masterProfile", &p.MasterProfile); err != nil {
return err
}
Expand Down Expand Up @@ -245,33 +248,13 @@ func (sv openShiftClusterStaticValidator) validateLoadBalancerProfile(path strin
return nil
}

err := checkPickedExactlyOne(path, lbp)
if err != nil {
return err
}

switch {
case lbp.ManagedOutboundIPs != nil:
err := validateManagedOutboundIPs(path, *lbp.ManagedOutboundIPs)
if err != nil {
return err
}
case lbp.OutboundIPs != nil:
err := validateOutboundIPs(path, lbp.OutboundIPs)
if err != nil {
return err
}
case lbp.OutboundIPPrefixes != nil:
err := validateOutboundIPPrefixes(path, lbp.OutboundIPPrefixes)
if err != nil {
return err
}
}

if lbp.AllocatedOutboundPorts != nil {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".allocatedOutboundPorts", "The field allocatedOutboundPorts is not implemented at this time, please check back later.")
}

// Prevents EffectiveOutboundIPs from being set during create,
// during update validateDelta will prevent the field from being changed.
if lbp.EffectiveOutboundIPs != nil && isCreate {
Expand All @@ -280,36 +263,13 @@ func (sv openShiftClusterStaticValidator) validateLoadBalancerProfile(path strin
return nil
}

func checkPickedExactlyOne(path string, lbp *LoadBalancerProfile) error {
var isManagedOutboundIPCount = lbp.ManagedOutboundIPs != nil
var isOutboundIPs = lbp.OutboundIPs != nil
var isOutboundIPPrefixes = lbp.OutboundIPPrefixes != nil

if !isManagedOutboundIPCount && !isOutboundIPPrefixes && !isOutboundIPs {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path, "The provided loadBalancerProfile is invalid: must specify one of managedOutboundIps, outboundIps, or outboundIpPrefixes.")
} else if !((isManagedOutboundIPCount && !isOutboundIPs && !isOutboundIPPrefixes) ||
(!isManagedOutboundIPCount && isOutboundIPs && !isOutboundIPPrefixes) ||
(!isManagedOutboundIPCount && !isOutboundIPs && isOutboundIPPrefixes)) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path, "The provided loadBalancerProfile is invalid: can only use one of managedOutboundIps, outboundIps, or outboundIpPrefixes at a time.")
}
return nil
}

func validateManagedOutboundIPs(path string, managedOutboundIPs ManagedOutboundIPs) error {
if !(managedOutboundIPs.Count > 0 && managedOutboundIPs.Count <= 20) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".managedOutboundIps.count", "The provided managedOutboundIps.count %d is invalid: managedOutboundIps.count must be in the range of 1 to 20 (inclusive).", managedOutboundIPs.Count)
}
return nil
}

func validateOutboundIPs(path string, outboundIPs []OutboundIP) error {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".outboundIps", "The field outboundIps is not implemented at this time, please check back later.")
}

func validateOutboundIPPrefixes(path string, outboundIPPrefixes []OutboundIPPrefix) error {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".outboundIpPrefixes", "The field outboundIpPrefixes is not implemented at this time, please check back later.")
}

func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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"

mgmtredhatopenshift20231122 "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-11-22/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 mgmtredhatopenshift20231122.OpenShiftClusterCredentials, err error)
Get(ctx context.Context, resourceGroupName string, resourceName string) (result mgmtredhatopenshift20231122.OpenShiftCluster, err error)
OpenShiftClustersClientAddons
}

type openShiftClustersClient struct {
mgmtredhatopenshift20231122.OpenShiftClustersClient
}

var _ OpenShiftClustersClient = &openShiftClustersClient{}

// NewOpenShiftClustersClient creates a new OpenShiftClustersClient
func NewOpenShiftClustersClient(environment *azureclient.AROEnvironment, subscriptionID string, authorizer autorest.Authorizer) OpenShiftClustersClient {
var client mgmtredhatopenshift20231122.OpenShiftClustersClient
if env.IsLocalDevelopmentMode() {
client = mgmtredhatopenshift20231122.NewOpenShiftClustersClientWithBaseURI("https://localhost:8443", subscriptionID)
client.Sender = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // #nosec G402

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
},
},
}
} else {
client = mgmtredhatopenshift20231122.NewOpenShiftClustersClientWithBaseURI(environment.ResourceManagerEndpoint, subscriptionID)
client.Authorizer = authorizer
}
client.PollingDelay = 10 * time.Second
client.PollingDuration = 2 * time.Hour

return &openShiftClustersClient{
OpenShiftClustersClient: client,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package redhatopenshift

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

import (
"context"

mgmtredhatopenshift20231122 "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-11-22/redhatopenshift"
)

// OpenShiftClustersClientAddons contains addons for OpenShiftClustersClient
type OpenShiftClustersClientAddons interface {
CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20231122.OpenShiftCluster) error
DeleteAndWait(ctx context.Context, resourceGroupName string, resourceName string) error
List(ctx context.Context) (clusters []mgmtredhatopenshift20231122.OpenShiftCluster, err error)
ListByResourceGroup(ctx context.Context, resourceGroupName string) (clusters []mgmtredhatopenshift20231122.OpenShiftCluster, err error)
}

func (c *openShiftClustersClient) CreateOrUpdateAndWait(ctx context.Context, resourceGroupName string, resourceName string, parameters mgmtredhatopenshift20231122.OpenShiftCluster) error {
future, err := c.CreateOrUpdate(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 []mgmtredhatopenshift20231122.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 []mgmtredhatopenshift20231122.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
}
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"

mgmtredhatopenshift20231122 "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2023-11-22/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 {
mgmtredhatopenshift20231122.OperationsClient
}

var _ OperationsClient = &operationsClient{}

// NewOperationsClient creates a new OperationsClient
func NewOperationsClient(environment *azureclient.AROEnvironment, subscriptionID string, authorizer autorest.Authorizer) OperationsClient {
var client mgmtredhatopenshift20231122.OperationsClient
if env.IsLocalDevelopmentMode() {
client = mgmtredhatopenshift20231122.NewOperationsClientWithBaseURI("https://localhost:8443", subscriptionID)
client.Sender = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // #nosec G402

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
},
},
}
} else {
client = mgmtredhatopenshift20231122.NewOperationsClientWithBaseURI(environment.ResourceManagerEndpoint, subscriptionID)
client.Authorizer = authorizer
}

return &operationsClient{
OperationsClient: client,
}
}
Loading

0 comments on commit 8ac47de

Please sign in to comment.