Skip to content
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
4 changes: 2 additions & 2 deletions .sha256sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
d2e11a7924d0cbb70672fb0dd6b1a387ccaec8b97a6968adf5a1516d325374eb swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json
749f87c84f68049c9da77f339e5aaae0e6ec86831992a31f6d6a5f997cced3ef swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-09-01-preview/redhatopenshift.json
468fa0da0a50d50640ec57843ad288af343128b39f5bf23e76e4e336580883d4 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json
c323c84befa5ea11da50a2407050abed6540ea01e796720bc2241604ce80567c swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-09-01-preview/redhatopenshift.json
4 changes: 3 additions & 1 deletion hack/build-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ function generate_golang() {
--rm \
-v $PWD/pkg/client:/github.com/Azure/ARO-RP/pkg/client:z \
-v $PWD/swagger:/swagger:z \
azuresdk/autorest \
"${AUTOREST_IMAGE}" \
--go \
--use=@microsoft.azure/autorest.go@2.1.183 \
--version=V2 \
--license-header=MICROSOFT_APACHE_NO_VERSION \
--namespace=redhatopenshift \
--input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/"$FOLDER"/"$API_VERSION"/redhatopenshift.json \
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/admin/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ type ServicePrincipalProfile struct {
SPObjectID string `json:"spObjectId,omitempty"`
}

// SDNProvider constants.
type SDNProvider string
// SoftwareDefinedNetwork constants.
type SoftwareDefinedNetwork string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
SoftwareDefinedNetworkOVNKubernetes SoftwareDefinedNetwork = "OVNKubernetes"
SoftwareDefinedNetworkOpenShiftSDN SoftwareDefinedNetwork = "OpenShiftSDN"
)

// NetworkProfile represents a network profile.
type NetworkProfile struct {
// The SDNProvider to use when installing the cluster.
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`
// The software defined network (SDN) to use when installing the cluster.
SoftwareDefinedNetwork SoftwareDefinedNetwork `json:"softwareDefinedNetwork,omitempty"`

PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/admin/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
SPObjectID: oc.Properties.ServicePrincipalProfile.SPObjectID,
},
NetworkProfile: NetworkProfile{
SDNProvider: SDNProvider(oc.Properties.NetworkProfile.SDNProvider),
SoftwareDefinedNetwork: SoftwareDefinedNetwork(oc.Properties.NetworkProfile.SoftwareDefinedNetwork),
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
APIServerPrivateEndpointIP: oc.Properties.NetworkProfile.APIServerPrivateEndpointIP,
Expand Down Expand Up @@ -172,7 +172,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
out.Properties.ServicePrincipalProfile.SPObjectID = oc.Properties.ServicePrincipalProfile.SPObjectID
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
out.Properties.NetworkProfile.SDNProvider = api.SDNProvider(oc.Properties.NetworkProfile.SDNProvider)
out.Properties.NetworkProfile.SoftwareDefinedNetwork = api.SoftwareDefinedNetwork(oc.Properties.NetworkProfile.SoftwareDefinedNetwork)
out.Properties.NetworkProfile.APIServerPrivateEndpointIP = oc.Properties.NetworkProfile.APIServerPrivateEndpointIP
out.Properties.MasterProfile.VMSize = api.VMSize(oc.Properties.MasterProfile.VMSize)
out.Properties.MasterProfile.SubnetID = oc.Properties.MasterProfile.SubnetID
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/admin/openshiftcluster_validatestatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,18 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
wantErr: "400: PropertyChangeNotAllowed: properties.servicePrincipalProfile.spObjectId: Changing property 'properties.servicePrincipalProfile.spObjectId' is not allowed.",
},
{
name: "sdnProvider change is not allowed",
name: "softwareDefinedNetwork change is not allowed",
oc: func() *OpenShiftCluster {
return &OpenShiftCluster{
Properties: OpenShiftClusterProperties{
NetworkProfile: NetworkProfile{
SDNProvider: SDNProviderOVNKubernetes,
SoftwareDefinedNetwork: SoftwareDefinedNetworkOVNKubernetes,
},
},
}
},
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.SDNProvider = "anything" },
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.sdnProvider: Changing property 'properties.networkProfile.sdnProvider' is not allowed.",
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.SoftwareDefinedNetwork = "anything" },
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.softwareDefinedNetwork: Changing property 'properties.networkProfile.softwareDefinedNetwork' is not allowed.",
},
{
name: "podCidr change is not allowed",
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ package api
// when moving between old and new versions
func SetDefaults(doc *OpenShiftClusterDocument) {
if doc.OpenShiftCluster != nil {
// SDNProvider was introduced in 2021-09-01-preview
if doc.OpenShiftCluster.Properties.NetworkProfile.SDNProvider == "" {
doc.OpenShiftCluster.Properties.NetworkProfile.SDNProvider = SDNProviderOpenShiftSDN
// SoftwareDefinedNetwork was introduced in 2021-09-01-preview
if doc.OpenShiftCluster.Properties.NetworkProfile.SoftwareDefinedNetwork == "" {
doc.OpenShiftCluster.Properties.NetworkProfile.SoftwareDefinedNetwork = SoftwareDefinedNetworkOpenShiftSDN
}

// EncryptionAtHost was introduced in 2021-09-01-preview.
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func validOpenShiftClusterDocument() *OpenShiftClusterDocument {
OpenShiftCluster: &OpenShiftCluster{
Properties: OpenShiftClusterProperties{
NetworkProfile: NetworkProfile{
SDNProvider: SDNProviderOpenShiftSDN,
SoftwareDefinedNetwork: SoftwareDefinedNetworkOpenShiftSDN,
},
MasterProfile: MasterProfile{
EncryptionAtHost: EncryptionAtHostDisabled,
Expand Down Expand Up @@ -48,18 +48,18 @@ func TestSetDefaults(t *testing.T) {
return validOpenShiftClusterDocument()
},
input: func(base *OpenShiftClusterDocument) {
base.OpenShiftCluster.Properties.NetworkProfile.SDNProvider = ""
base.OpenShiftCluster.Properties.NetworkProfile.SoftwareDefinedNetwork = ""
},
},
{
name: "preserve SDN",
want: func() *OpenShiftClusterDocument {
doc := validOpenShiftClusterDocument()
doc.OpenShiftCluster.Properties.NetworkProfile.SDNProvider = SDNProviderOVNKubernetes
doc.OpenShiftCluster.Properties.NetworkProfile.SoftwareDefinedNetwork = SoftwareDefinedNetworkOVNKubernetes
return doc
},
input: func(base *OpenShiftClusterDocument) {
base.OpenShiftCluster.Properties.NetworkProfile.SDNProvider = SDNProviderOVNKubernetes
base.OpenShiftCluster.Properties.NetworkProfile.SoftwareDefinedNetwork = SoftwareDefinedNetworkOVNKubernetes
},
},
{
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,21 @@ type ServicePrincipalProfile struct {
SPObjectID string `json:"spObjectId,omitempty"`
}

// SDNProvider
type SDNProvider string
// SoftwareDefinedNetwork
type SoftwareDefinedNetwork string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
SoftwareDefinedNetworkOVNKubernetes SoftwareDefinedNetwork = "OVNKubernetes"
SoftwareDefinedNetworkOpenShiftSDN SoftwareDefinedNetwork = "OpenShiftSDN"
)

// NetworkProfile represents a network profile
type NetworkProfile struct {
MissingFields

PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`
PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
SoftwareDefinedNetwork SoftwareDefinedNetwork `json:"softwareDefinedNetwork,omitempty"`

APIServerPrivateEndpointIP string `json:"privateEndpointIp,omitempty"`
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/v20210901preview/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type OpenShiftCluster struct {
Location string `json:"location,omitempty"`

// SystemData - The system metadata relating to this resource
SystemData SystemData `json:"systemData,omitempty"`
SystemData *SystemData `json:"systemData,omitempty"`

// The resource tags.
Tags Tags `json:"tags,omitempty" mutable:"true"`
Expand Down Expand Up @@ -114,18 +114,18 @@ type ServicePrincipalProfile struct {
ClientSecret string `json:"clientSecret,omitempty" mutable:"true"`
}

// SDNProvider constants.
type SDNProvider string
// SoftwareDefinedNetwork constants.
type SoftwareDefinedNetwork string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
SoftwareDefinedNetworkOVNKubernetes SoftwareDefinedNetwork = "OVNKubernetes"
SoftwareDefinedNetworkOpenShiftSDN SoftwareDefinedNetwork = "OpenShiftSDN"
)

// NetworkProfile represents a network profile.
type NetworkProfile struct {
// The SDNProvider to use when installing the cluster.
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`
// The software defined network (SDN) to use when installing the cluster.
SoftwareDefinedNetwork SoftwareDefinedNetwork `json:"softwareDefinedNetwork,omitempty"`

// The CIDR used for OpenShift/Kubernetes Pods.
PodCIDR string `json:"podCidr,omitempty"`
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/v20210901preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
ClientSecret: string(oc.Properties.ServicePrincipalProfile.ClientSecret),
},
NetworkProfile: NetworkProfile{
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
SDNProvider: SDNProvider(oc.Properties.NetworkProfile.SDNProvider),
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
SoftwareDefinedNetwork: SoftwareDefinedNetwork(oc.Properties.NetworkProfile.SoftwareDefinedNetwork),
},
MasterProfile: MasterProfile{
VMSize: VMSize(oc.Properties.MasterProfile.VMSize),
Expand Down Expand Up @@ -86,7 +86,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
}
}

out.SystemData = SystemData{
out.SystemData = &SystemData{
CreatedBy: oc.SystemData.CreatedBy,
CreatedAt: oc.SystemData.CreatedAt,
CreatedByType: CreatedByType(oc.SystemData.CreatedByType),
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
out.Properties.ServicePrincipalProfile.ClientSecret = api.SecureString(oc.Properties.ServicePrincipalProfile.ClientSecret)
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
out.Properties.NetworkProfile.SDNProvider = api.SDNProvider(oc.Properties.NetworkProfile.SDNProvider)
out.Properties.NetworkProfile.SoftwareDefinedNetwork = api.SoftwareDefinedNetwork(oc.Properties.NetworkProfile.SoftwareDefinedNetwork)
out.Properties.MasterProfile.VMSize = api.VMSize(oc.Properties.MasterProfile.VMSize)
out.Properties.MasterProfile.SubnetID = oc.Properties.MasterProfile.SubnetID
out.Properties.MasterProfile.EncryptionAtHost = api.EncryptionAtHost(oc.Properties.MasterProfile.EncryptionAtHost)
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v20210901preview/openshiftcluster_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func exampleOpenShiftCluster() *OpenShiftCluster {
func ExampleOpenShiftClusterPatchParameter() interface{} {
oc := ExampleOpenShiftClusterPutParameter().(*OpenShiftCluster)
oc.Location = ""
oc.SystemData = nil

return oc
}
Expand All @@ -34,6 +35,7 @@ func ExampleOpenShiftClusterPutParameter() interface{} {
oc.Properties.APIServerProfile.URL = ""
oc.Properties.APIServerProfile.IP = ""
oc.Properties.IngressProfiles[0].IP = ""
oc.SystemData = nil

return oc
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/v20210901preview/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
}
}

switch np.SDNProvider {
case SDNProviderOVNKubernetes, SDNProviderOpenShiftSDN:
switch np.SoftwareDefinedNetwork {
case SoftwareDefinedNetworkOVNKubernetes, SoftwareDefinedNetworkOpenShiftSDN:
default:
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".sdnProvider", "The provided SDNProvider '%s' is invalid.", np.SDNProvider)
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".SoftwareDefinedNetwork", "The provided SoftwareDefinedNetwork '%s' is invalid.", np.SoftwareDefinedNetwork)
}

return nil
Expand Down
34 changes: 18 additions & 16 deletions pkg/api/v20210901preview/openshiftcluster_validatestatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func validOpenShiftCluster() *OpenShiftCluster {
Tags: Tags{
"key": "value",
},
SystemData: SystemData{
SystemData: &SystemData{
CreatedBy: "00000000-0000-0000-0000-000000000000",
CreatedByType: CreatedByTypeApplication,
CreatedAt: &timestamp,
Expand All @@ -76,9 +76,9 @@ func validOpenShiftCluster() *OpenShiftCluster {
ClientID: "11111111-1111-1111-1111-111111111111",
},
NetworkProfile: NetworkProfile{
PodCIDR: "10.128.0.0/14",
ServiceCIDR: "172.30.0.0/16",
SDNProvider: SDNProviderOVNKubernetes,
PodCIDR: "10.128.0.0/14",
ServiceCIDR: "172.30.0.0/16",
SoftwareDefinedNetwork: SoftwareDefinedNetworkOVNKubernetes,
},
MasterProfile: MasterProfile{
VMSize: VMSizeStandardD8sV3,
Expand Down Expand Up @@ -415,9 +415,9 @@ func TestOpenShiftClusterStaticValidateServicePrincipalProfile(t *testing.T) {
func TestOpenShiftClusterStaticValidateNetworkProfile(t *testing.T) {
createtests := []*validateTest{
{
name: "sdnProvider create as OpenShiftSDN",
name: "SoftwareDefinedNetwork create as OpenShiftSDN",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = SDNProviderOpenShiftSDN
oc.Properties.NetworkProfile.SoftwareDefinedNetwork = SoftwareDefinedNetworkOpenShiftSDN
},
},
}
Expand Down Expand Up @@ -469,18 +469,18 @@ func TestOpenShiftClusterStaticValidateNetworkProfile(t *testing.T) {
wantErr: "400: InvalidParameter: properties.networkProfile.serviceCidr: The provided vnet CIDR '10.0.0.0/23' is invalid: must be /22 or larger.",
},
{
name: "sdnProvider given as empty",
name: "SoftwareDefinedNetwork given as empty",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = ""
oc.Properties.NetworkProfile.SoftwareDefinedNetwork = ""
},
wantErr: "400: InvalidParameter: properties.networkProfile.sdnProvider: The provided SDNProvider '' is invalid.",
wantErr: "400: InvalidParameter: properties.networkProfile.SoftwareDefinedNetwork: The provided SoftwareDefinedNetwork '' is invalid.",
},
{
name: "sdnProvider given InvalidOption",
name: "SoftwareDefinedNetwork given InvalidOption",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = "InvalidOption"
oc.Properties.NetworkProfile.SoftwareDefinedNetwork = "InvalidOption"
},
wantErr: "400: InvalidParameter: properties.networkProfile.sdnProvider: The provided SDNProvider 'InvalidOption' is invalid.",
wantErr: "400: InvalidParameter: properties.networkProfile.SoftwareDefinedNetwork: The provided SoftwareDefinedNetwork 'InvalidOption' is invalid.",
},
}

Expand Down Expand Up @@ -851,9 +851,11 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
modify: func(oc *OpenShiftCluster) { oc.Properties.ServicePrincipalProfile.ClientSecret = "invalid" },
},
{
name: "sdnProvider should fail to change from OVNKubernetes to OpenShiftSDN",
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.SDNProvider = SDNProviderOpenShiftSDN },
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.sdnProvider: Changing property 'properties.networkProfile.sdnProvider' is not allowed.",
name: "SoftwareDefinedNetwork should fail to change from OVNKubernetes to OpenShiftSDN",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SoftwareDefinedNetwork = SoftwareDefinedNetworkOpenShiftSDN
},
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.softwareDefinedNetwork: Changing property 'properties.networkProfile.softwareDefinedNetwork' is not allowed.",
},
{
name: "podCidr change",
Expand Down Expand Up @@ -916,7 +918,7 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
{
name: "systemData set to empty",
modify: func(oc *OpenShiftCluster) {
oc.SystemData = SystemData{}
oc.SystemData = &SystemData{}
},
wantErr: "400: PropertyChangeNotAllowed: systemData.createdBy: Changing property 'systemData.createdBy' is not allowed.",
},
Expand Down

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

Loading