Merge pull request #2404 from ross-bryan/multi-version-refactor

Multi version refactor
This commit is contained in:
Ross Bryan 2022-09-20 13:15:07 -04:00 коммит произвёл GitHub
Родитель 6eaaa74ffa 7812c70247
Коммит d897df3534
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
59 изменённых файлов: 813 добавлений и 506 удалений

Просмотреть файл

@ -1,4 +1,4 @@
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
e4e522e41855de71c0318db31cbd96c8713e7a74e7c81911bb494f0b194b3f43 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-04-01/redhatopenshift.json
70e23386b8277aea07a1babd61fb2c1252cff46ad032f700b02074fb46a58c4c swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json
009e7ade338aa2803cb5ef94e3d6057b7093af7ed9b194e51b86e4eb71b4ac05 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json

Просмотреть файл

@ -31,11 +31,13 @@ func getLatestOCPVersions(ctx context.Context, log *logrus.Entry) ([]api.OpenShi
var (
OpenshiftVersions = []api.OpenShiftVersion{
{
Properties: api.OpenShiftVersionProperties{
Version: version.InstallStream.Version.String(),
OpenShiftPullspec: version.InstallStream.PullSpec,
InstallerPullspec: dstRepo + "/aro-installer:release-4.10",
Enabled: true,
},
},
}
)
return OpenshiftVersions, nil
@ -121,13 +123,13 @@ func updateOpenShiftVersions(ctx context.Context, dbOpenShiftVersions database.O
newVersions := make(map[string]api.OpenShiftVersion)
for _, doc := range latestVersions {
newVersions[doc.Version] = doc
newVersions[doc.Properties.Version] = doc
}
for _, doc := range existingVersions.OpenShiftVersionDocuments {
existing, found := newVersions[doc.OpenShiftVersion.Version]
existing, found := newVersions[doc.OpenShiftVersion.Properties.Version]
if found {
log.Printf("Found Version %q, patching", existing.Version)
log.Printf("Found Version %q, patching", existing.Properties.Version)
_, err := dbOpenShiftVersions.Patch(ctx, doc.ID, func(inFlightDoc *api.OpenShiftVersionDocument) error {
inFlightDoc.OpenShiftVersion = &existing
return nil
@ -135,12 +137,12 @@ func updateOpenShiftVersions(ctx context.Context, dbOpenShiftVersions database.O
if err != nil {
return err
}
log.Printf("Version %q found", existing.Version)
delete(newVersions, existing.Version)
log.Printf("Version %q found", existing.Properties.Version)
delete(newVersions, existing.Properties.Version)
continue
}
log.Printf("Version %q not found, deleting", doc.OpenShiftVersion.Version)
log.Printf("Version %q not found, deleting", doc.OpenShiftVersion.Properties.Version)
err := dbOpenShiftVersions.Delete(ctx, doc)
if err != nil {
return err
@ -148,7 +150,7 @@ func updateOpenShiftVersions(ctx context.Context, dbOpenShiftVersions database.O
}
for _, doc := range newVersions {
log.Printf("Version %q not found in database, creating", doc.Version)
log.Printf("Version %q not found in database, creating", doc.Properties.Version)
newDoc := api.OpenShiftVersionDocument{
ID: dbOpenShiftVersions.NewUUID(),
OpenShiftVersion: &doc,

Просмотреть файл

@ -216,6 +216,15 @@
curl -X GET -k "https://localhost:8443/admin/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.RedHatOpenShift/openShiftClusters/$CLUSTER/kubernetespodlogs?podname=$POD&namespace=$NAMESPACE&container=$CONTAINER"
```
## OpenShift Version
* We have a cosmos container which contains supported installable OCP versions, more information on the definition in `pkg/api/openshiftversion.go`.
* Populate the `OpenShiftVersions` container via admin api
```bash
curl -X PUT -k "https://localhost:8443/admin/versions" --header "Content-Type: application/json" -d '{ "properties": { "version": "4.10.0", "enabled": true, "openShiftPullspec": "test.com/a:b", "installerPullspec": "test.com/a:b" }}'
```
## OpenShift Cluster Manager (OCM) Configuration API Actions
* Create a new OCM configuration

Просмотреть файл

@ -10,6 +10,19 @@ type OpenShiftVersionList struct {
}
type OpenShiftVersion struct {
// The ID for the resource.
ID string `json:"id,omitempty"`
// Name of the resource.
Name string `json:"name,omitempty"`
// The properties for the OpenShiftVersion resource.
Properties OpenShiftVersionProperties `json:"properties,omitempty"`
}
// OpenShiftVersionProperties represents the properties of an OpenShiftVersion.
type OpenShiftVersionProperties struct {
// Version represents the version to create the cluster at.
Version string `json:"version,omitempty"`
OpenShiftPullspec string `json:"openShiftPullspec,omitempty" mutable:"true"`
InstallerPullspec string `json:"installerPullspec,omitempty" mutable:"true"`

Просмотреть файл

@ -16,10 +16,12 @@ type openShiftVersionConverter struct{}
// returned objects.
func (openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{} {
out := &OpenShiftVersion{
Version: v.Version,
OpenShiftPullspec: v.OpenShiftPullspec,
InstallerPullspec: v.InstallerPullspec,
Enabled: v.Enabled,
Properties: OpenShiftVersionProperties{
Version: v.Properties.Version,
OpenShiftPullspec: v.Properties.OpenShiftPullspec,
InstallerPullspec: v.Properties.InstallerPullspec,
Enabled: v.Properties.Enabled,
},
}
return out
@ -46,8 +48,8 @@ func (c openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion)
func (c openShiftVersionConverter) ToInternal(_new interface{}, out *api.OpenShiftVersion) {
new := _new.(*OpenShiftVersion)
out.Enabled = new.Enabled
out.InstallerPullspec = new.InstallerPullspec
out.OpenShiftPullspec = new.OpenShiftPullspec
out.Version = new.Version
out.Properties.Enabled = new.Properties.Enabled
out.Properties.InstallerPullspec = new.Properties.InstallerPullspec
out.Properties.OpenShiftPullspec = new.Properties.OpenShiftPullspec
out.Properties.Version = new.Properties.Version
}

Просмотреть файл

@ -34,15 +34,15 @@ func (sv openShiftVersionStaticValidator) Static(_new interface{}, _current *api
}
func (sv openShiftVersionStaticValidator) validate(new *OpenShiftVersion, isCreate bool) error {
if new.Version == "" {
if new.Properties.Version == "" {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "version", "Must be provided")
}
if new.InstallerPullspec == "" {
if new.Properties.InstallerPullspec == "" {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "installerPullspec", "Must be provided")
}
if new.OpenShiftPullspec == "" {
if new.Properties.OpenShiftPullspec == "" {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "openShiftPullspec", "Must be provided")
}
return nil

Просмотреть файл

@ -1,16 +0,0 @@
package installversion
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
// OpenShiftCluster represents the portion of the OpenShift cluster
// representation which provides the cluster installation version.
type openShiftCluster struct {
Properties openShiftClusterProperties `json:"properties,omitempty"`
}
// OpenShiftClusterProperties represents an OpenShift cluster's properties.
type openShiftClusterProperties struct {
// The cluster install version.
InstallVersion string `json:"installVersion,omitempty"`
}

Просмотреть файл

@ -1,19 +0,0 @@
package installversion
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"encoding/json"
)
func FromExternalBytes(body []byte) (*openShiftCluster, error) {
r := &openShiftCluster{}
err := json.Unmarshal(body, &r)
if err != nil {
return nil, err
}
return r, nil
}

Просмотреть файл

@ -1,83 +0,0 @@
package installversion
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"encoding/json"
"testing"
v20200430 "github.com/Azure/ARO-RP/pkg/api/v20200430"
v20220904 "github.com/Azure/ARO-RP/pkg/api/v20220904"
)
func TestParsePreInstallAPI(t *testing.T) {
preInstallVersion := &v20200430.OpenShiftCluster{
Properties: v20200430.OpenShiftClusterProperties{
ClusterProfile: v20200430.ClusterProfile{
Domain: "example",
},
},
}
b, err := json.Marshal(preInstallVersion)
if err != nil {
t.Fatal(err)
}
ver, err := FromExternalBytes(b)
if err != nil {
t.Fatal(err)
}
if ver.Properties.InstallVersion != "" {
t.Error(ver.Properties.InstallVersion)
}
}
func TestParsePostInstallAPI(t *testing.T) {
postInstallVersion := &v20220904.OpenShiftCluster{
Properties: v20220904.OpenShiftClusterProperties{
ClusterProfile: v20220904.ClusterProfile{
Domain: "example",
},
},
}
b, err := json.Marshal(postInstallVersion)
if err != nil {
t.Fatal(err)
}
ver, err := FromExternalBytes(b)
if err != nil {
t.Fatal(err)
}
if ver.Properties.InstallVersion != "" {
t.Error(ver.Properties.InstallVersion)
}
postInstallVersionWithVersion := &v20220904.OpenShiftCluster{
Properties: v20220904.OpenShiftClusterProperties{
InstallVersion: "4.10.0",
ClusterProfile: v20220904.ClusterProfile{
Domain: "example",
},
},
}
b, err = json.Marshal(postInstallVersionWithVersion)
if err != nil {
t.Fatal(err)
}
ver, err = FromExternalBytes(b)
if err != nil {
t.Fatal(err)
}
if ver.Properties.InstallVersion != "4.10.0" {
t.Error(ver.Properties.InstallVersion)
}
}

Просмотреть файл

@ -8,8 +8,17 @@ type OpenShiftVersion struct {
MissingFields
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Deleting bool `json:"deleting,omitempty"` // https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed-design-patterns#deletes
// The properties for the OpenShiftVersion resource.
Properties OpenShiftVersionProperties `json:"properties,omitempty"`
}
// OpenShiftVersionProperties represents the properties of an OpenShiftVersion.
type OpenShiftVersionProperties struct {
// Version represents the version to create the cluster at.
Version string `json:"version,omitempty"`
OpenShiftPullspec string `json:"openShiftPullspec,omitempty"`
InstallerPullspec string `json:"installerPullspec,omitempty"`

Просмотреть файл

@ -0,0 +1,22 @@
package api
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
func ExampleOpenShiftVersionDocument() *OpenShiftVersionDocument {
return &OpenShiftVersionDocument{
MissingFields: MissingFields{},
ID: "00000000-0000-0000-0000-000000000000",
OpenShiftVersion: &OpenShiftVersion{
ID: "00000000-0000-0000-0000-000000000000",
Name: "default",
Type: "Microsoft.RedHatOpenShift/OpenShiftVersion",
Properties: OpenShiftVersionProperties{
Version: "4.10.20",
OpenShiftPullspec: "ab:c",
InstallerPullspec: "de:f",
Enabled: true,
},
},
}
}

Просмотреть файл

@ -35,10 +35,6 @@ type OpenShiftVersionConverter interface {
ToInternal(interface{}, *OpenShiftVersion)
}
type InstallVersionsConverter interface {
ToExternal(*InstallVersions) interface{}
}
type OpenShiftVersionStaticValidator interface {
Static(interface{}, *OpenShiftVersion) error
}
@ -52,7 +48,6 @@ type Version struct {
OpenShiftClusterAdminKubeconfigConverter OpenShiftClusterAdminKubeconfigConverter
OpenShiftVersionConverter OpenShiftVersionConverter
OpenShiftVersionStaticValidator OpenShiftVersionStaticValidator
InstallVersionsConverter InstallVersionsConverter
OperationList OperationList
}

Просмотреть файл

@ -18,7 +18,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
"github.com/Azure/ARO-RP/pkg/util/subnet"
"github.com/Azure/ARO-RP/pkg/util/uuid"
"github.com/Azure/ARO-RP/pkg/util/version"
)
type openShiftClusterStaticValidator struct {
@ -149,10 +148,6 @@ func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".domain", "The provided domain '%s' is invalid.", cp.Domain)
}
if isCreate && cp.Version != version.InstallStream.Version.String() {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".version", "The provided version '%s' is invalid.", cp.Version)
}
if !validate.RxResourceGroupID.MatchString(cp.ResourceGroupID) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".resourceGroupId", "The provided resource group '%s' is invalid.", cp.ResourceGroupID)
}

Просмотреть файл

@ -317,13 +317,6 @@ func TestOpenShiftClusterStaticValidateClusterProfile(t *testing.T) {
oc.Properties.ClusterProfile.PullSecret = ""
},
},
{
name: "version invalid",
modify: func(oc *OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "invalid"
},
wantErr: "400: InvalidParameter: properties.clusterProfile.version: The provided version 'invalid' is invalid.",
},
{
name: "leading digit domain invalid",
modify: func(oc *OpenShiftCluster) {

Просмотреть файл

@ -18,7 +18,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
"github.com/Azure/ARO-RP/pkg/util/subnet"
"github.com/Azure/ARO-RP/pkg/util/uuid"
"github.com/Azure/ARO-RP/pkg/util/version"
)
type openShiftClusterStaticValidator struct {
@ -152,10 +151,6 @@ func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".domain", "The provided domain '%s' is invalid.", cp.Domain)
}
if isCreate && cp.Version != version.InstallStream.Version.String() {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".version", "The provided version '%s' is invalid.", cp.Version)
}
if !validate.RxResourceGroupID.MatchString(cp.ResourceGroupID) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".resourceGroupId", "The provided resource group '%s' is invalid.", cp.ResourceGroupID)
}

Просмотреть файл

@ -317,13 +317,6 @@ func TestOpenShiftClusterStaticValidateClusterProfile(t *testing.T) {
oc.Properties.ClusterProfile.PullSecret = ""
},
},
{
name: "version invalid",
modify: func(oc *OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "invalid"
},
wantErr: "400: InvalidParameter: properties.clusterProfile.version: The provided version 'invalid' is invalid.",
},
{
name: "leading digit domain invalid",
modify: func(oc *OpenShiftCluster) {

Просмотреть файл

@ -18,7 +18,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
"github.com/Azure/ARO-RP/pkg/util/subnet"
"github.com/Azure/ARO-RP/pkg/util/uuid"
"github.com/Azure/ARO-RP/pkg/util/version"
)
type openShiftClusterStaticValidator struct {
@ -152,10 +151,6 @@ func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".domain", "The provided domain '%s' is invalid.", cp.Domain)
}
if isCreate && cp.Version != version.InstallStream.Version.String() {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".version", "The provided version '%s' is invalid.", cp.Version)
}
if !validate.RxResourceGroupID.MatchString(cp.ResourceGroupID) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".resourceGroupId", "The provided resource group '%s' is invalid.", cp.ResourceGroupID)
}

Просмотреть файл

@ -334,13 +334,6 @@ func TestOpenShiftClusterStaticValidateClusterProfile(t *testing.T) {
oc.Properties.ClusterProfile.PullSecret = ""
},
},
{
name: "version invalid",
modify: func(oc *OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "invalid"
},
wantErr: "400: InvalidParameter: properties.clusterProfile.version: The provided version 'invalid' is invalid.",
},
{
name: "leading digit domain invalid",
modify: func(oc *OpenShiftCluster) {

Просмотреть файл

@ -18,7 +18,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
"github.com/Azure/ARO-RP/pkg/util/subnet"
"github.com/Azure/ARO-RP/pkg/util/uuid"
"github.com/Azure/ARO-RP/pkg/util/version"
)
type openShiftClusterStaticValidator struct {
@ -152,10 +151,6 @@ func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".domain", "The provided domain '%s' is invalid.", cp.Domain)
}
if isCreate && cp.Version != version.InstallStream.Version.String() {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".version", "The provided version '%s' is invalid.", cp.Version)
}
if !validate.RxResourceGroupID.MatchString(cp.ResourceGroupID) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".resourceGroupId", "The provided resource group '%s' is invalid.", cp.ResourceGroupID)
}

Просмотреть файл

@ -348,13 +348,6 @@ func TestOpenShiftClusterStaticValidateClusterProfile(t *testing.T) {
oc.Properties.ClusterProfile.PullSecret = ""
},
},
{
name: "version invalid",
modify: func(oc *OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "invalid"
},
wantErr: "400: InvalidParameter: properties.clusterProfile.version: The provided version 'invalid' is invalid.",
},
{
name: "leading digit domain invalid",
modify: func(oc *OpenShiftCluster) {

Просмотреть файл

@ -1,7 +0,0 @@
package v20220904
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
// InstallVersions represents a List of OpenShift installable versions.
type InstallVersions []InstallVersion

Просмотреть файл

@ -1,12 +0,0 @@
package v20220904
import "github.com/Azure/ARO-RP/pkg/api"
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
type installVersionsConverter struct{}
func (installVersionsConverter) ToExternal(installVersions *api.InstallVersions) interface{} {
return installVersions
}

Просмотреть файл

@ -1,10 +0,0 @@
package v20220904
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
// ExampleInstallVersions returns an example
// InstallVersions object i.e []string that the RP would return to an end-user.
func ExampleInstallVersionsResponse() interface{} {
return &InstallVersions{"4.10.20"}
}

Просмотреть файл

@ -69,9 +69,6 @@ type OpenShiftClusterProperties struct {
// The cluster ingress profiles.
IngressProfiles []IngressProfile `json:"ingressProfiles,omitempty"`
// The cluster install version.
InstallVersion string `json:"installVersion,omitempty"`
}
// ProvisioningState represents a provisioning state.
@ -87,9 +84,6 @@ const (
ProvisioningStateFailed ProvisioningState = "Failed"
)
// InstallVersion is the OpenShift installation version string.
type InstallVersion string
// FipsValidatedModules determines if FIPS is used.
type FipsValidatedModules string

Просмотреть файл

@ -37,7 +37,6 @@ func ExampleOpenShiftClusterPutParameter() interface{} {
oc.Properties.APIServerProfile.IP = ""
oc.Properties.IngressProfiles[0].IP = ""
oc.Properties.MasterProfile.EncryptionAtHost = EncryptionAtHost(EncryptionAtHostEnabled)
oc.Properties.InstallVersion = ""
oc.SystemData = nil
return oc

Просмотреть файл

@ -151,10 +151,6 @@ func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".domain", "The provided domain '%s' is invalid.", cp.Domain)
}
if isCreate && !validate.RxInstallVersion.MatchString(cp.Version) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".version", "The provided version '%s' is invalid.", cp.Version)
}
if !validate.RxResourceGroupID.MatchString(cp.ResourceGroupID) {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".resourceGroupId", "The provided resource group '%s' is invalid.", cp.ResourceGroupID)
}

Просмотреть файл

@ -363,13 +363,6 @@ func TestOpenShiftClusterStaticValidateClusterProfile(t *testing.T) {
oc.Properties.ClusterProfile.PullSecret = ""
},
},
{
name: "version invalid",
modify: func(oc *OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "invalid"
},
wantErr: "400: InvalidParameter: properties.clusterProfile.version: The provided version 'invalid' is invalid.",
},
{
name: "leading digit domain invalid",
modify: func(oc *OpenShiftCluster) {

Просмотреть файл

@ -0,0 +1,36 @@
package v20220904
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
// OpenShiftVersionList represents a List of available versions.
type OpenShiftVersionList struct {
// The List of available versions.
OpenShiftVersions []*OpenShiftVersion `json:"value"`
// Next Link to next operation.
NextLink string `json:"nextLink,omitempty"`
}
// OpenShiftVersion represents an OpenShift version that can be installed.
type OpenShiftVersion struct {
proxyResource bool
// The ID for the resource.
ID string `json:"id,omitempty" mutable:"case"`
// Name of the resource.
Name string `json:"name,omitempty" mutable:"case"`
// The resource type.
Type string `json:"type,omitempty" mutable:"case"`
// The properties for the OpenShiftVersion resource.
Properties OpenShiftVersionProperties `json:"properties,omitempty"`
}
// OpenShiftVersionProperties represents the properties of an OpenShiftVersion.
type OpenShiftVersionProperties struct {
// Version represents the version to create the cluster at.
Version string `json:"version,omitempty"`
}

Просмотреть файл

@ -0,0 +1,49 @@
package v20220904
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"github.com/Azure/ARO-RP/pkg/api"
)
type openShiftVersionConverter struct{}
// openShiftVersionConverter.ToExternal returns a new external representation
// of the internal object, reading from the subset of the internal object's
// fields that appear in the external representation. ToExternal does not
// modify its argument; there is no pointer aliasing between the passed and
// returned objects.
func (openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{} {
out := &OpenShiftVersion{
proxyResource: true,
Properties: OpenShiftVersionProperties{
Version: v.Properties.Version,
},
}
return out
}
// ToExternalList returns a slice of external representations of the internal
// objects
func (c openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion) interface{} {
l := &OpenShiftVersionList{
OpenShiftVersions: make([]*OpenShiftVersion, 0, len(vers)),
}
for _, ver := range vers {
l.OpenShiftVersions = append(l.OpenShiftVersions, c.ToExternal(ver).(*OpenShiftVersion))
}
return l
}
// ToInternal overwrites in place a pre-existing internal object, setting (only)
// all mapped fields from the external representation. ToInternal modifies its
// argument; there is no pointer aliasing between the passed and returned
// objects
func (c openShiftVersionConverter) ToInternal(_new interface{}, out *api.OpenShiftVersion) {
new := _new.(*OpenShiftVersion)
out.Properties.Version = new.Properties.Version
}

Просмотреть файл

@ -0,0 +1,24 @@
package v20220904
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import "github.com/Azure/ARO-RP/pkg/api"
func exampleOpenShiftVersion() *OpenShiftVersion {
doc := api.ExampleOpenShiftVersionDocument()
ext := (&openShiftVersionConverter{}).ToExternal(doc.OpenShiftVersion)
return ext.(*OpenShiftVersion)
}
func ExampleOpenShiftVersionResponse() interface{} {
return exampleOpenShiftVersion()
}
func ExampleOpenShiftVersionListResponse() interface{} {
return &OpenShiftVersionList{
OpenShiftVersions: []*OpenShiftVersion{
ExampleOpenShiftVersionResponse().(*OpenShiftVersion),
},
}
}

Просмотреть файл

@ -21,7 +21,7 @@ func init() {
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
OpenShiftClusterAdminKubeconfigConverter: openShiftClusterAdminKubeconfigConverter{},
InstallVersionsConverter: installVersionsConverter{},
OpenShiftVersionConverter: openShiftVersionConverter{},
OperationList: api.OperationList{
Operations: []api.Operation{
api.OperationResultsRead,

Просмотреть файл

@ -122,12 +122,6 @@ type IngressProfile struct {
IP *string `json:"ip,omitempty"`
}
// ListString ...
type ListString struct {
autorest.Response `json:"-"`
Value *[]string `json:"value,omitempty"`
}
// MachinePool machinePool represents a MachinePool
type MachinePool struct {
autorest.Response `json:"-"`
@ -754,8 +748,6 @@ type OpenShiftClusterProperties struct {
ApiserverProfile *APIServerProfile `json:"apiserverProfile,omitempty"`
// IngressProfiles - The cluster ingress profiles.
IngressProfiles *[]IngressProfile `json:"ingressProfiles,omitempty"`
// InstallVersion - The cluster install version.
InstallVersion *string `json:"installVersion,omitempty"`
}
// OpenShiftClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a
@ -945,6 +937,44 @@ func (oscu *OpenShiftClusterUpdate) UnmarshalJSON(body []byte) error {
return nil
}
// OpenShiftVersion openShiftVersion represents an OpenShift version that can be installed.
type OpenShiftVersion struct {
// Properties - The properties for the OpenShiftVersion resource.
Properties *OpenShiftVersionProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; The name of the resource
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
Type *string `json:"type,omitempty"`
// SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
SystemData *SystemData `json:"systemData,omitempty"`
}
// MarshalJSON is the custom marshaler for OpenShiftVersion.
func (osv OpenShiftVersion) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if osv.Properties != nil {
objectMap["properties"] = osv.Properties
}
return json.Marshal(objectMap)
}
// OpenShiftVersionList openShiftVersionList represents a List of available versions.
type OpenShiftVersionList struct {
autorest.Response `json:"-"`
// Value - The List of available versions.
Value *[]OpenShiftVersion `json:"value,omitempty"`
// NextLink - Next Link to next operation.
NextLink *string `json:"nextLink,omitempty"`
}
// OpenShiftVersionProperties openShiftVersionProperties represents the properties of an OpenShiftVersion.
type OpenShiftVersionProperties struct {
// Version - Version represents the version to create the cluster at.
Version *string `json:"version,omitempty"`
}
// Operation operation represents an RP operation.
type Operation struct {
// Name - Operation name: {provider}/{resource}/{operation}.

Просмотреть файл

@ -27,28 +27,29 @@ import (
"github.com/Azure/go-autorest/tracing"
)
// InstallVersionsClient is the rest API for Azure Red Hat OpenShift 4
type InstallVersionsClient struct {
// OpenShiftVersionsClient is the rest API for Azure Red Hat OpenShift 4
type OpenShiftVersionsClient struct {
BaseClient
}
// NewInstallVersionsClient creates an instance of the InstallVersionsClient client.
func NewInstallVersionsClient(subscriptionID string) InstallVersionsClient {
return NewInstallVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
// NewOpenShiftVersionsClient creates an instance of the OpenShiftVersionsClient client.
func NewOpenShiftVersionsClient(subscriptionID string) OpenShiftVersionsClient {
return NewOpenShiftVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewInstallVersionsClientWithBaseURI creates an instance of the InstallVersionsClient client using a custom endpoint.
// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
func NewInstallVersionsClientWithBaseURI(baseURI string, subscriptionID string) InstallVersionsClient {
return InstallVersionsClient{NewWithBaseURI(baseURI, subscriptionID)}
// NewOpenShiftVersionsClientWithBaseURI creates an instance of the OpenShiftVersionsClient client using a custom
// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
// stack).
func NewOpenShiftVersionsClientWithBaseURI(baseURI string, subscriptionID string) OpenShiftVersionsClient {
return OpenShiftVersionsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List the operation returns the installable OpenShift versions as strings.
// Parameters:
// location - the name of Azure region.
func (client InstallVersionsClient) List(ctx context.Context, location string) (result ListString, err error) {
func (client OpenShiftVersionsClient) List(ctx context.Context, location string) (result OpenShiftVersionList, err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/InstallVersionsClient.List")
ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftVersionsClient.List")
defer func() {
sc := -1
if result.Response.Response != nil {
@ -62,25 +63,25 @@ func (client InstallVersionsClient) List(ctx context.Context, location string) (
Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
{TargetValue: location,
Constraints: []validation.Constraint{{Target: "location", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
return result, validation.NewError("redhatopenshift.InstallVersionsClient", "List", err.Error())
return result, validation.NewError("redhatopenshift.OpenShiftVersionsClient", "List", err.Error())
}
req, err := client.ListPreparer(ctx, location)
if err != nil {
err = autorest.NewErrorWithError(err, "redhatopenshift.InstallVersionsClient", "List", nil, "Failure preparing request")
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftVersionsClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "redhatopenshift.InstallVersionsClient", "List", resp, "Failure sending request")
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftVersionsClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "redhatopenshift.InstallVersionsClient", "List", resp, "Failure responding to request")
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftVersionsClient", "List", resp, "Failure responding to request")
return
}
@ -88,7 +89,7 @@ func (client InstallVersionsClient) List(ctx context.Context, location string) (
}
// ListPreparer prepares the List request.
func (client InstallVersionsClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
func (client OpenShiftVersionsClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"location": autorest.Encode("path", location),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
@ -109,17 +110,17 @@ func (client InstallVersionsClient) ListPreparer(ctx context.Context, location s
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client InstallVersionsClient) ListSender(req *http.Request) (*http.Response, error) {
func (client OpenShiftVersionsClient) ListSender(req *http.Request) (*http.Response, error) {
return client.Send(req, azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client InstallVersionsClient) ListResponder(resp *http.Response) (result ListString, err error) {
func (client OpenShiftVersionsClient) ListResponder(resp *http.Response) (result OpenShiftVersionList, err error) {
err = autorest.Respond(
resp,
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result.Value),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return

Просмотреть файл

@ -33,12 +33,12 @@ type OperationsClientAPI interface {
var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil)
// InstallVersionsClientAPI contains the set of methods on the InstallVersionsClient type.
type InstallVersionsClientAPI interface {
List(ctx context.Context, location string) (result redhatopenshift.ListString, err error)
// OpenShiftVersionsClientAPI contains the set of methods on the OpenShiftVersionsClient type.
type OpenShiftVersionsClientAPI interface {
List(ctx context.Context, location string) (result redhatopenshift.OpenShiftVersionList, err error)
}
var _ InstallVersionsClientAPI = (*redhatopenshift.InstallVersionsClient)(nil)
var _ OpenShiftVersionsClientAPI = (*redhatopenshift.OpenShiftVersionsClient)(nil)
// OpenShiftClustersClientAPI contains the set of methods on the OpenShiftClustersClient type.
type OpenShiftClustersClientAPI interface {

Просмотреть файл

@ -23,7 +23,7 @@ func (m *manager) openShiftVersionFromVersion(ctx context.Context) (*api.OpenShi
activeOpenShiftVersions := make([]*api.OpenShiftVersion, 0)
for _, doc := range docs.OpenShiftVersionDocuments {
if doc.OpenShiftVersion.Enabled {
if doc.OpenShiftVersion.Properties.Enabled {
activeOpenShiftVersions = append(activeOpenShiftVersions, doc.OpenShiftVersion)
}
}
@ -48,17 +48,18 @@ func (m *manager) openShiftVersionFromVersion(ctx context.Context) (*api.OpenShi
}
return &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.InstallStream.Version.String(),
OpenShiftPullspec: openshiftPullSpec,
InstallerPullspec: installerPullSpec,
Enabled: true,
}, nil
}}, nil
}
for _, active := range activeOpenShiftVersions {
if requestedInstallVersion == active.Version {
if requestedInstallVersion == active.Properties.Version {
if m.installViaHive {
active.OpenShiftPullspec = strings.Replace(active.OpenShiftPullspec, "quay.io", m.env.ACRDomain(), 1)
active.Properties.OpenShiftPullspec = strings.Replace(active.Properties.OpenShiftPullspec, "quay.io", m.env.ACRDomain(), 1)
}
return active, nil
}

Просмотреть файл

@ -50,26 +50,32 @@ func TestGetOpenShiftVersionFromVersion(t *testing.T) {
},
wantErrString: "",
want: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.InstallStream.Version.String(),
OpenShiftPullspec: version.InstallStream.PullSpec,
InstallerPullspec: fmt.Sprintf("%s/aro-installer:release-%d.%d", testACRDomain, version.InstallStream.Version.V[0], version.InstallStream.Version.V[1]),
},
},
},
{
name: "select nonexistent version",
f: func(f *testdatabase.Fixture) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.20",
Enabled: true,
},
},
}, &api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.27",
Enabled: true,
},
},
},
)
},
m: manager{
@ -123,9 +129,9 @@ func TestGetOpenShiftVersionFromVersion(t *testing.T) {
}
if tt.want != nil {
assert.Equal(t, tt.want.Version, version.Version, "Version does not match")
assert.Equal(t, tt.want.OpenShiftPullspec, version.OpenShiftPullspec, "OpenShiftPullspec does not match")
assert.Equal(t, tt.want.InstallerPullspec, version.InstallerPullspec, "InstallerPullspec does not match")
assert.Equal(t, tt.want.Properties.Version, version.Properties.Version, "Version does not match")
assert.Equal(t, tt.want.Properties.OpenShiftPullspec, version.Properties.OpenShiftPullspec, "OpenShiftPullspec does not match")
assert.Equal(t, tt.want.Properties.InstallerPullspec, version.Properties.InstallerPullspec, "InstallerPullspec does not match")
}
})
}

Просмотреть файл

@ -37,7 +37,9 @@ func (f *frontend) getAdminOpenShiftVersions(w http.ResponseWriter, r *http.Requ
}
}
sort.Slice(vers, func(i, j int) bool { return semver.New(vers[i].Version).LessThan(*semver.New(vers[j].Version)) })
sort.Slice(vers, func(i, j int) bool {
return semver.New(vers[i].Properties.Version).LessThan(*semver.New(vers[j].Properties.Version))
})
b, err := json.MarshalIndent(converter.ToExternalList(vers), "", " ")
adminReply(log, w, nil, b, err)

Просмотреть файл

@ -40,44 +40,57 @@ func TestOpenShiftVersionList(t *testing.T) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
},
},
},
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.9.9",
Enabled: true,
OpenShiftPullspec: "a:a/b",
InstallerPullspec: "b:b/c",
},
},
},
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.1",
Enabled: false,
OpenShiftPullspec: "a:a/b",
InstallerPullspec: "b:b/c",
},
},
},
)
},
wantStatusCode: http.StatusOK,
wantResponse: &admin.OpenShiftVersionList{
OpenShiftVersions: []*admin.OpenShiftVersion{
{
Properties: admin.OpenShiftVersionProperties{
Version: "4.9.9",
Enabled: true,
OpenShiftPullspec: "a:a/b",
InstallerPullspec: "b:b/c",
},
},
{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
},
},
{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.1",
Enabled: false,
OpenShiftPullspec: "a:a/b",
@ -86,6 +99,7 @@ func TestOpenShiftVersionList(t *testing.T) {
},
},
},
},
} {
t.Run(tt.name, func(t *testing.T) {
ti := newTestInfra(t).WithOpenShiftVersions()

Просмотреть файл

@ -47,7 +47,7 @@ func (f *frontend) putAdminOpenShiftVersion(w http.ResponseWriter, r *http.Reque
if docs != nil {
for _, doc := range docs.OpenShiftVersionDocuments {
if doc.OpenShiftVersion.Version == version.Version {
if doc.OpenShiftVersion.Properties.Version == version.Properties.Version {
versionDoc = doc
break
}

Просмотреть файл

@ -34,30 +34,37 @@ func TestOpenShiftVersionPut(t *testing.T) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
},
},
},
)
},
body: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: false,
OpenShiftPullspec: "c:c/d",
InstallerPullspec: "d:d/e",
},
},
wantStatusCode: http.StatusOK,
wantResponse: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: false,
OpenShiftPullspec: "c:c/d",
InstallerPullspec: "d:d/e",
},
},
wantDocuments: []*api.OpenShiftVersionDocument{
{
ID: "07070707-0707-0707-0707-070707070001",
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: false,
OpenShiftPullspec: "c:c/d",
@ -66,44 +73,54 @@ func TestOpenShiftVersionPut(t *testing.T) {
},
},
},
},
{
name: "creating new version",
fixture: func(f *testdatabase.Fixture) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
},
},
},
)
},
body: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.1",
Enabled: true,
OpenShiftPullspec: "f:f/g",
InstallerPullspec: "g:g/h",
},
},
wantStatusCode: http.StatusCreated,
wantResponse: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.1",
Enabled: true,
OpenShiftPullspec: "f:f/g",
InstallerPullspec: "g:g/h",
},
},
wantDocuments: []*api.OpenShiftVersionDocument{
{
ID: "07070707-0707-0707-0707-070707070001",
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
},
},
},
{
ID: "07070707-0707-0707-0707-070707070002",
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.1",
Enabled: true,
OpenShiftPullspec: "f:f/g",
@ -112,31 +129,37 @@ func TestOpenShiftVersionPut(t *testing.T) {
},
},
},
},
{
name: "updating known version requires installer pullspec",
fixture: func(f *testdatabase.Fixture) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
InstallerPullspec: "d:d/e",
},
},
},
)
},
body: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "c:c/d",
},
},
wantStatusCode: http.StatusBadRequest,
wantError: "400: InvalidParameter: installerPullspec: Must be provided",
wantDocuments: []*api.OpenShiftVersionDocument{
{
ID: "07070707-0707-0707-0707-070707070001",
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
@ -145,31 +168,37 @@ func TestOpenShiftVersionPut(t *testing.T) {
},
},
},
},
{
name: "updating known version requires openshift pullspec",
fixture: func(f *testdatabase.Fixture) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
InstallerPullspec: "d:d/e",
},
},
},
)
},
body: &admin.OpenShiftVersion{
Properties: admin.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
InstallerPullspec: "c:c/d",
},
},
wantStatusCode: http.StatusBadRequest,
wantError: "400: InvalidParameter: openShiftPullspec: Must be provided",
wantDocuments: []*api.OpenShiftVersionDocument{
{
ID: "07070707-0707-0707-0707-070707070001",
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.0",
Enabled: true,
OpenShiftPullspec: "a:a/b",
@ -178,6 +207,7 @@ func TestOpenShiftVersionPut(t *testing.T) {
},
},
},
},
{
name: "creating new version needs body",
fixture: func(f *testdatabase.Fixture) {},

Просмотреть файл

@ -65,11 +65,6 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
return nil, err
}
installVersion, err := f.validateAndReturnInstallVersion(ctx, body)
if err != nil {
return nil, err
}
doc = &api.OpenShiftClusterDocument{
ID: f.dbOpenShiftClusters.NewUUID(),
Key: path,
@ -83,9 +78,6 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
CreatedAt: f.now().UTC(),
CreatedBy: version.GitCommit,
ProvisionedBy: version.GitCommit,
ClusterProfile: api.ClusterProfile{
Version: installVersion,
},
},
},
}
@ -178,6 +170,11 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
f.systemDataClusterDocEnricher(doc, systemData)
if isCreate {
err = f.validateInstallVersion(ctx, doc)
if err != nil {
return nil, err
}
// on create, make the cluster resourcegroup ID lower case to work
// around LB/PLS bug
doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID = strings.ToLower(doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID)
@ -239,7 +236,7 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret = ""
doc.OpenShiftCluster.Properties.ServicePrincipalProfile.ClientSecret = ""
b, err := json.MarshalIndent(converter.ToExternal(doc.OpenShiftCluster), "", "\t")
b, err := json.MarshalIndent(converter.ToExternal(doc.OpenShiftCluster), "", " ")
if err != nil {
return nil, err
}

Просмотреть файл

@ -672,7 +672,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
{
name: "create a new cluster",
request: func(oc *v20200430.OpenShiftCluster) {
oc.Properties.ClusterProfile.Version = "4.3.0"
oc.Properties.ClusterProfile.Version = "4.10.20"
},
fixture: func(f *testdatabase.Fixture) {
f.AddSubscriptionDocuments(&api.SubscriptionDocument{
@ -708,7 +708,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
CreatedAt: mockCurrentTime,
CreatedBy: version.GitCommit,
ClusterProfile: api.ClusterProfile{
Version: "4.3.0",
Version: "4.10.20",
FipsValidatedModules: api.FipsValidatedModulesDisabled,
},
NetworkProfile: api.NetworkProfile{
@ -735,7 +735,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
Properties: v20200430.OpenShiftClusterProperties{
ProvisioningState: v20200430.ProvisioningStateCreating,
ClusterProfile: v20200430.ClusterProfile{
Version: "4.3.0",
Version: "4.10.20",
},
},
},
@ -1314,7 +1314,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
Properties: api.OpenShiftClusterProperties{
ProvisioningState: api.ProvisioningStateCreating,
ClusterProfile: api.ClusterProfile{
Version: "4.3.0",
Version: "4.10.20",
ResourceGroupID: fmt.Sprintf("/subscriptions/%s/resourcegroups/aro-vjb21wca", mockSubID),
FipsValidatedModules: api.FipsValidatedModulesDisabled,
},
@ -1359,7 +1359,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
Properties: api.OpenShiftClusterProperties{
ProvisioningState: api.ProvisioningStateCreating,
ClusterProfile: api.ClusterProfile{
Version: "4.3.0",
Version: "4.10.20",
FipsValidatedModules: api.FipsValidatedModulesDisabled,
},
NetworkProfile: api.NetworkProfile{

Просмотреть файл

@ -22,40 +22,44 @@ func (f *frontend) listInstallVersions(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
if f.apis[vars["api-version"]].InstallVersionsConverter == nil {
if f.apis[vars["api-version"]].OpenShiftVersionConverter == nil {
api.WriteError(w, http.StatusBadRequest, api.CloudErrorCodeInvalidResourceType, "", "The endpoint could not be found in the namespace '%s' for api version '%s'.", vars["resourceProviderNamespace"], vars["api-version"])
return
}
versions, err := f.getInstallVersions(ctx)
versions, err := f.getEnabledInstallVersions(ctx)
if err != nil {
log.Error(err)
api.WriteError(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Unable to list the available OpenShift versions in this region.")
return
}
converter := f.apis[vars["api-version"]].InstallVersionsConverter
converter := f.apis[vars["api-version"]].OpenShiftVersionConverter
b, err := json.Marshal(converter.ToExternal((*api.InstallVersions)(&versions)))
b, err := json.MarshalIndent(converter.ToExternalList(([]*api.OpenShiftVersion)(versions)), "", " ")
reply(log, w, nil, b, err)
}
func (f *frontend) getInstallVersions(ctx context.Context) ([]string, error) {
func (f *frontend) getEnabledInstallVersions(ctx context.Context) ([]*api.OpenShiftVersion, error) {
docs, err := f.dbOpenShiftVersions.ListAll(ctx)
if err != nil {
return nil, fmt.Errorf("unable to list the entries in the OpenShift versions database: %s", err.Error())
}
versions := make([]string, 0)
versions := make([]*api.OpenShiftVersion, 0)
for _, doc := range docs.OpenShiftVersionDocuments {
if doc.OpenShiftVersion.Enabled {
versions = append(versions, doc.OpenShiftVersion.Version)
if doc.OpenShiftVersion.Properties.Enabled {
versions = append(versions, doc.OpenShiftVersion)
}
}
// add the default from version.InstallStream, when we have no active versions
if len(versions) == 0 {
versions = append(versions, version.InstallStream.Version.String())
versions = append(versions, &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.InstallStream.Version.String(),
},
})
}
return versions, nil

Просмотреть файл

@ -11,6 +11,8 @@ import (
"sort"
"testing"
"github.com/coreos/go-semver/semver"
"github.com/Azure/ARO-RP/pkg/api"
v20220904 "github.com/Azure/ARO-RP/pkg/api/v20220904"
"github.com/Azure/ARO-RP/pkg/metrics/noop"
@ -28,7 +30,7 @@ func TestListInstallVersions(t *testing.T) {
name string
fixture func(f *testdatabase.Fixture)
wantStatusCode int
wantResponse *v20220904.InstallVersions
wantResponse v20220904.OpenShiftVersionList
wantError string
}
@ -47,8 +49,14 @@ func TestListInstallVersions(t *testing.T) {
})
},
wantStatusCode: http.StatusOK,
wantResponse: &v20220904.InstallVersions{
v20220904.InstallVersion((v20220904.InstallVersion)(version.InstallStream.Version.String())),
wantResponse: v20220904.OpenShiftVersionList{
OpenShiftVersions: []*v20220904.OpenShiftVersion{
{
Properties: v20220904.OpenShiftVersionProperties{
Version: version.InstallStream.Version.String(),
},
},
},
},
},
{
@ -66,27 +74,43 @@ func TestListInstallVersions(t *testing.T) {
f.AddOpenShiftVersionDocuments(
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.20",
Enabled: false,
},
},
}, &api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.10.27",
Enabled: true,
},
},
},
&api.OpenShiftVersionDocument{
OpenShiftVersion: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: "4.11.5",
Enabled: true,
},
},
},
)
},
wantStatusCode: http.StatusOK,
wantResponse: &v20220904.InstallVersions{
"4.10.27",
"4.11.5",
wantResponse: v20220904.OpenShiftVersionList{
OpenShiftVersions: []*v20220904.OpenShiftVersion{
{
Properties: v20220904.OpenShiftVersionProperties{
Version: "4.10.27",
},
},
{
Properties: v20220904.OpenShiftVersionProperties{
Version: "4.11.5",
},
},
},
},
},
} {
@ -114,20 +138,31 @@ func TestListInstallVersions(t *testing.T) {
t.Fatal(err)
}
// sort the response as the version order might be changed
if b != nil {
var v []string
var v v20220904.OpenShiftVersionList
if err = json.Unmarshal(b, &v); err != nil {
t.Error(err)
}
sort.Strings(v)
sort.Slice(v.OpenShiftVersions, func(i, j int) bool {
return semver.New(v.OpenShiftVersions[i].Properties.Version).LessThan(*semver.New(v.OpenShiftVersions[j].Properties.Version))
})
b, err = json.Marshal(v)
if err != nil {
t.Error(err)
}
}
err = validateResponse(resp, b, tt.wantStatusCode, tt.wantError, tt.wantResponse)
// marshal the expected response into a []byte otherwise
// it will compare zero values to omitempty json tags
want, err := json.Marshal(tt.wantResponse)
if err != nil {
t.Error(err)
}
err = validateResponse(resp, b, tt.wantStatusCode, tt.wantError, want)
if err != nil {
t.Error(err)
}

Просмотреть файл

@ -12,7 +12,6 @@ import (
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/api/components/installversion"
"github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
utilnamespace "github.com/Azure/ARO-RP/pkg/util/namespace"
@ -167,42 +166,41 @@ func validateAdminVMSize(vmSize string) error {
return nil
}
func (f *frontend) validateAndReturnInstallVersion(ctx context.Context, body []byte) (string, error) {
oc, err := installversion.FromExternalBytes(body)
if err != nil {
return "", api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidRequestContent, "", "The request content was invalid and could not be deserialized: %q.", err)
}
// validateInstallVersion validates the install version set in the clusterprofile.version
// TODO convert this into static validation instead of this receiver function in the vaidate for frontend.
func (f *frontend) validateInstallVersion(ctx context.Context, doc *api.OpenShiftClusterDocument) error {
oc := doc.OpenShiftCluster
// If this request is from an older API or the user never specified
// the version to install we default to the InstallStream.Version
if len(oc.Properties.InstallVersion) == 0 {
return version.InstallStream.Version.String(), nil
if oc.Properties.ClusterProfile.Version == "" {
oc.Properties.ClusterProfile.Version = version.InstallStream.Version.String()
return nil
}
errInvalidVersion := api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "properties.installversion", "The requested OpenShift version '%s' is invalid.", oc.Properties.InstallVersion)
errInvalidVersion := api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "properties.clusterProfile.version", "The requested OpenShift version '%s' is invalid.", oc.Properties.ClusterProfile.Version)
if !validate.RxInstallVersion.MatchString(oc.Properties.InstallVersion) {
return "", errInvalidVersion
if !validate.RxInstallVersion.MatchString(oc.Properties.ClusterProfile.Version) {
return errInvalidVersion
}
docs, err := f.dbOpenShiftVersions.ListAll(ctx)
if err != nil {
return "", err
return err
}
// If we have no OpenShiftVersion entries in CosmoDB, default to using the InstallStream.Version
if len(docs.OpenShiftVersionDocuments) == 0 {
if oc.Properties.InstallVersion != version.InstallStream.Version.String() {
return "", errInvalidVersion
if oc.Properties.ClusterProfile.Version != version.InstallStream.Version.String() {
return errInvalidVersion
}
return version.InstallStream.Version.String(), nil
return nil
}
for _, doc := range docs.OpenShiftVersionDocuments {
if oc.Properties.InstallVersion == doc.OpenShiftVersion.Version {
return oc.Properties.InstallVersion, nil
if oc.Properties.ClusterProfile.Version == doc.OpenShiftVersion.Properties.Version {
return nil
}
}
return "", errInvalidVersion
return errInvalidVersion
}

Просмотреть файл

@ -187,8 +187,8 @@ func (c *clusterManager) clusterDeploymentForInstall(doc *api.OpenShiftClusterDo
Name: pullsecretSecretName,
},
Provisioning: &hivev1.Provisioning{
InstallerImageOverride: version.InstallerPullspec,
ReleaseImage: version.OpenShiftPullspec,
InstallerImageOverride: version.Properties.InstallerPullspec,
ReleaseImage: version.Properties.OpenShiftPullspec,
InstallConfigSecretRef: &corev1.LocalObjectReference{
Name: installConfigName,
},

Просмотреть файл

@ -232,8 +232,8 @@ func (m *manager) generateInstallConfig(ctx context.Context) (*installconfig.Ins
}
image := &releaseimage.Image{}
if m.oc.Properties.ClusterProfile.Version == m.version.Version {
image.PullSpec = m.version.OpenShiftPullspec
if m.oc.Properties.ClusterProfile.Version == m.version.Properties.Version {
image.PullSpec = m.version.Properties.OpenShiftPullspec
} else {
return nil, nil, fmt.Errorf("unimplemented version %q", m.oc.Properties.ClusterProfile.Version)
}

Просмотреть файл

@ -164,8 +164,8 @@ func (g *generator) generateExamples(outputDir string, s *Swagger) error {
body = g.exampleOpenShiftClusterListResponse()
case "#/definitions/OperationList":
body = g.exampleOperationListResponse()
case "#/definitions/InstallVersions":
body = g.exampleInstallVersions()
case "#/definitions/OpenShiftVersionList":
body = g.exampleOpenShiftVersionListResponse()
}
}

Просмотреть файл

@ -41,7 +41,7 @@ type generator struct {
exampleOpenShiftClusterCredentialsResponse func() interface{}
exampleOpenShiftClusterAdminKubeconfigResponse func() interface{}
exampleOpenShiftClusterListResponse func() interface{}
exampleInstallVersions func() interface{}
exampleOpenShiftVersionListResponse func() interface{}
exampleOperationListResponse func() interface{}
systemData bool
@ -120,7 +120,7 @@ var apis = map[string]*generator{
exampleOpenShiftClusterCredentialsResponse: v20220904.ExampleOpenShiftClusterCredentialsResponse,
exampleOpenShiftClusterListResponse: v20220904.ExampleOpenShiftClusterListResponse,
exampleOpenShiftClusterAdminKubeconfigResponse: v20220904.ExampleOpenShiftClusterAdminKubeconfigResponse,
exampleInstallVersions: v20220904.ExampleInstallVersionsResponse,
exampleOpenShiftVersionListResponse: v20220904.ExampleOpenShiftVersionListResponse,
exampleOperationListResponse: api.ExampleOperationListResponse,
xmsEnum: []string{"EncryptionAtHost", "FipsValidatedModules", "SoftwareDefinedNetwork", "Visibility"},

Просмотреть файл

@ -22,6 +22,7 @@ var proxyResources = []string{
"SyncIdentityProvider",
"MachinePool",
"Secret",
"OpenShiftVersion",
}
func Run(api, outputDir string) error {
@ -102,12 +103,12 @@ func Run(api, outputDir string) error {
if g.installVersionList {
s.Paths["/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/locations/{location}/listinstallversions"] = &PathItem{
Get: &Operation{
Tags: []string{"InstallVersions"},
Tags: []string{"OpenShiftVersions"},
Summary: "Lists all OpenShift versions available to install in the specified location.",
Description: "The operation returns the installable OpenShift versions as strings.",
OperationID: "InstallVersions_List",
Parameters: g.populateParameters(6, "InstallVersions", "Install Versions"),
Responses: g.populateResponses("InstallVersions", false, http.StatusOK),
OperationID: "OpenShiftVersions_List",
Parameters: g.populateParameters(6, "OpenShiftVersionList", "OpenShift Versions"),
Responses: g.populateResponses("OpenShiftVersionList", false, http.StatusOK),
},
}
}
@ -127,7 +128,7 @@ func Run(api, outputDir string) error {
}
if g.installVersionList {
names = append(names, "InstallVersions")
names = append(names, "OpenShiftVersionList")
}
if g.clusterManager {

Просмотреть файл

@ -106,6 +106,8 @@ def aro_create(cmd, # pylint: disable=too-many-locals
resource_group_id=(f"/subscriptions/{subscription_id}"
f"/resourceGroups/{cluster_resource_group or 'aro-' + random_id}"),
fips_validated_modules='Enabled' if fips_validated_modules else 'Disabled',
install_version=install_version or '',
),
service_principal_profile=openshiftcluster.ServicePrincipalProfile(
client_id=client_id,
@ -142,7 +144,6 @@ def aro_create(cmd, # pylint: disable=too-many-locals
visibility=ingress_visibility or 'Public',
)
],
install_version=install_version or '',
)
sp_obj_ids = [client_sp_id, rp_client_sp_id]
@ -224,7 +225,11 @@ def aro_list_admin_credentials(cmd, client, resource_group_name, resource_name,
def aro_get_versions(client, location):
return client.install_versions.list(location)
openshift_verions = client.open_shift_versions.list(location)
versions = []
for ver in openshift_verions.additional_properties["value"]:
versions.append(ver["properties"]["version"])
return sorted(versions)
def aro_update(cmd,

Просмотреть файл

@ -23,7 +23,7 @@ from azure.mgmt.core import ARMPipelineClient
from . import models
from ._configuration import AzureRedHatOpenShiftClientConfiguration
from .operations import InstallVersionsOperations, MachinePoolsOperations, OpenShiftClustersOperations, Operations, SecretsOperations, SyncIdentityProvidersOperations, SyncSetsOperations
from .operations import MachinePoolsOperations, OpenShiftClustersOperations, OpenShiftVersionsOperations, Operations, SecretsOperations, SyncIdentityProvidersOperations, SyncSetsOperations
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
@ -37,9 +37,9 @@ class AzureRedHatOpenShiftClient(object): # pylint: disable=too-many-instance
:ivar operations: Operations operations
:vartype operations: azure.mgmt.redhatopenshift.v2022_09_04.operations.Operations
:ivar install_versions: InstallVersionsOperations operations
:vartype install_versions:
azure.mgmt.redhatopenshift.v2022_09_04.operations.InstallVersionsOperations
:ivar open_shift_versions: OpenShiftVersionsOperations operations
:vartype open_shift_versions:
azure.mgmt.redhatopenshift.v2022_09_04.operations.OpenShiftVersionsOperations
:ivar open_shift_clusters: OpenShiftClustersOperations operations
:vartype open_shift_clusters:
azure.mgmt.redhatopenshift.v2022_09_04.operations.OpenShiftClustersOperations
@ -82,7 +82,7 @@ class AzureRedHatOpenShiftClient(object): # pylint: disable=too-many-instance
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.install_versions = InstallVersionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.open_shift_versions = OpenShiftVersionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.machine_pools = MachinePoolsOperations(self._client, self._config, self._serialize, self._deserialize)
self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize)

Просмотреть файл

@ -31,6 +31,9 @@ try:
from ._models_py3 import OpenShiftClusterCredentials
from ._models_py3 import OpenShiftClusterList
from ._models_py3 import OpenShiftClusterUpdate
from ._models_py3 import OpenShiftVersion
from ._models_py3 import OpenShiftVersionList
from ._models_py3 import OpenShiftVersionProperties
from ._models_py3 import Operation
from ._models_py3 import OperationList
from ._models_py3 import ProxyResource
@ -65,6 +68,9 @@ except (SyntaxError, ImportError):
from ._models import OpenShiftClusterCredentials # type: ignore
from ._models import OpenShiftClusterList # type: ignore
from ._models import OpenShiftClusterUpdate # type: ignore
from ._models import OpenShiftVersion # type: ignore
from ._models import OpenShiftVersionList # type: ignore
from ._models import OpenShiftVersionProperties # type: ignore
from ._models import Operation # type: ignore
from ._models import OperationList # type: ignore
from ._models import ProxyResource # type: ignore
@ -108,6 +114,9 @@ __all__ = [
'OpenShiftClusterCredentials',
'OpenShiftClusterList',
'OpenShiftClusterUpdate',
'OpenShiftVersion',
'OpenShiftVersionList',
'OpenShiftVersionProperties',
'Operation',
'OperationList',
'ProxyResource',

Просмотреть файл

@ -619,8 +619,6 @@ class OpenShiftCluster(TrackedResource):
:vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile
:ivar ingress_profiles: The cluster ingress profiles.
:vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:ivar install_version: The cluster install version.
:vartype install_version: str
"""
_validation = {
@ -647,7 +645,6 @@ class OpenShiftCluster(TrackedResource):
'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'},
'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'},
'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'},
'install_version': {'key': 'properties.installVersion', 'type': 'str'},
}
def __init__(
@ -681,8 +678,6 @@ class OpenShiftCluster(TrackedResource):
:keyword ingress_profiles: The cluster ingress profiles.
:paramtype ingress_profiles:
list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:keyword install_version: The cluster install version.
:paramtype install_version: str
"""
super(OpenShiftCluster, self).__init__(**kwargs)
self.provisioning_state = kwargs.get('provisioning_state', None)
@ -694,7 +689,6 @@ class OpenShiftCluster(TrackedResource):
self.worker_profiles = kwargs.get('worker_profiles', None)
self.apiserver_profile = kwargs.get('apiserver_profile', None)
self.ingress_profiles = kwargs.get('ingress_profiles', None)
self.install_version = kwargs.get('install_version', None)
class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model):
@ -808,8 +802,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
:vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile
:ivar ingress_profiles: The cluster ingress profiles.
:vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:ivar install_version: The cluster install version.
:vartype install_version: str
"""
_validation = {
@ -828,7 +820,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'},
'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'},
'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'},
'install_version': {'key': 'properties.installVersion', 'type': 'str'},
}
def __init__(
@ -860,8 +851,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
:keyword ingress_profiles: The cluster ingress profiles.
:paramtype ingress_profiles:
list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:keyword install_version: The cluster install version.
:paramtype install_version: str
"""
super(OpenShiftClusterUpdate, self).__init__(**kwargs)
self.tags = kwargs.get('tags', None)
@ -875,7 +864,106 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
self.worker_profiles = kwargs.get('worker_profiles', None)
self.apiserver_profile = kwargs.get('apiserver_profile', None)
self.ingress_profiles = kwargs.get('ingress_profiles', None)
self.install_version = kwargs.get('install_version', None)
class OpenShiftVersion(ProxyResource):
"""OpenShiftVersion represents an OpenShift version that can be installed.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData
:ivar properties: The properties for the OpenShiftVersion resource.
:vartype properties: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersionProperties
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'system_data': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'system_data': {'key': 'systemData', 'type': 'SystemData'},
'properties': {'key': 'properties', 'type': 'OpenShiftVersionProperties'},
}
def __init__(
self,
**kwargs
):
"""
:keyword properties: The properties for the OpenShiftVersion resource.
:paramtype properties:
~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersionProperties
"""
super(OpenShiftVersion, self).__init__(**kwargs)
self.properties = kwargs.get('properties', None)
class OpenShiftVersionList(msrest.serialization.Model):
"""OpenShiftVersionList represents a List of available versions.
:ivar value: The List of available versions.
:vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion]
:ivar next_link: Next Link to next operation.
:vartype next_link: str
"""
_attribute_map = {
'value': {'key': 'value', 'type': '[OpenShiftVersion]'},
'next_link': {'key': 'nextLink', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
"""
:keyword value: The List of available versions.
:paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion]
:keyword next_link: Next Link to next operation.
:paramtype next_link: str
"""
super(OpenShiftVersionList, self).__init__(**kwargs)
self.value = kwargs.get('value', None)
self.next_link = kwargs.get('next_link', None)
class OpenShiftVersionProperties(msrest.serialization.Model):
"""OpenShiftVersionProperties represents the properties of an OpenShiftVersion.
:ivar version: Version represents the version to create the cluster at.
:vartype version: str
"""
_attribute_map = {
'version': {'key': 'version', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
"""
:keyword version: Version represents the version to create the cluster at.
:paramtype version: str
"""
super(OpenShiftVersionProperties, self).__init__(**kwargs)
self.version = kwargs.get('version', None)
class Operation(msrest.serialization.Model):

Просмотреть файл

@ -668,8 +668,6 @@ class OpenShiftCluster(TrackedResource):
:vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile
:ivar ingress_profiles: The cluster ingress profiles.
:vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:ivar install_version: The cluster install version.
:vartype install_version: str
"""
_validation = {
@ -696,7 +694,6 @@ class OpenShiftCluster(TrackedResource):
'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'},
'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'},
'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'},
'install_version': {'key': 'properties.installVersion', 'type': 'str'},
}
def __init__(
@ -713,7 +710,6 @@ class OpenShiftCluster(TrackedResource):
worker_profiles: Optional[List["WorkerProfile"]] = None,
apiserver_profile: Optional["APIServerProfile"] = None,
ingress_profiles: Optional[List["IngressProfile"]] = None,
install_version: Optional[str] = None,
**kwargs
):
"""
@ -743,8 +739,6 @@ class OpenShiftCluster(TrackedResource):
:keyword ingress_profiles: The cluster ingress profiles.
:paramtype ingress_profiles:
list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:keyword install_version: The cluster install version.
:paramtype install_version: str
"""
super(OpenShiftCluster, self).__init__(tags=tags, location=location, **kwargs)
self.provisioning_state = provisioning_state
@ -756,7 +750,6 @@ class OpenShiftCluster(TrackedResource):
self.worker_profiles = worker_profiles
self.apiserver_profile = apiserver_profile
self.ingress_profiles = ingress_profiles
self.install_version = install_version
class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model):
@ -878,8 +871,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
:vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile
:ivar ingress_profiles: The cluster ingress profiles.
:vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:ivar install_version: The cluster install version.
:vartype install_version: str
"""
_validation = {
@ -898,7 +889,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'},
'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'},
'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'},
'install_version': {'key': 'properties.installVersion', 'type': 'str'},
}
def __init__(
@ -914,7 +904,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
worker_profiles: Optional[List["WorkerProfile"]] = None,
apiserver_profile: Optional["APIServerProfile"] = None,
ingress_profiles: Optional[List["IngressProfile"]] = None,
install_version: Optional[str] = None,
**kwargs
):
"""
@ -942,8 +931,6 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
:keyword ingress_profiles: The cluster ingress profiles.
:paramtype ingress_profiles:
list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile]
:keyword install_version: The cluster install version.
:paramtype install_version: str
"""
super(OpenShiftClusterUpdate, self).__init__(**kwargs)
self.tags = tags
@ -957,7 +944,113 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
self.worker_profiles = worker_profiles
self.apiserver_profile = apiserver_profile
self.ingress_profiles = ingress_profiles
self.install_version = install_version
class OpenShiftVersion(ProxyResource):
"""OpenShiftVersion represents an OpenShift version that can be installed.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData
:ivar properties: The properties for the OpenShiftVersion resource.
:vartype properties: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersionProperties
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'system_data': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'system_data': {'key': 'systemData', 'type': 'SystemData'},
'properties': {'key': 'properties', 'type': 'OpenShiftVersionProperties'},
}
def __init__(
self,
*,
properties: Optional["OpenShiftVersionProperties"] = None,
**kwargs
):
"""
:keyword properties: The properties for the OpenShiftVersion resource.
:paramtype properties:
~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersionProperties
"""
super(OpenShiftVersion, self).__init__(**kwargs)
self.properties = properties
class OpenShiftVersionList(msrest.serialization.Model):
"""OpenShiftVersionList represents a List of available versions.
:ivar value: The List of available versions.
:vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion]
:ivar next_link: Next Link to next operation.
:vartype next_link: str
"""
_attribute_map = {
'value': {'key': 'value', 'type': '[OpenShiftVersion]'},
'next_link': {'key': 'nextLink', 'type': 'str'},
}
def __init__(
self,
*,
value: Optional[List["OpenShiftVersion"]] = None,
next_link: Optional[str] = None,
**kwargs
):
"""
:keyword value: The List of available versions.
:paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion]
:keyword next_link: Next Link to next operation.
:paramtype next_link: str
"""
super(OpenShiftVersionList, self).__init__(**kwargs)
self.value = value
self.next_link = next_link
class OpenShiftVersionProperties(msrest.serialization.Model):
"""OpenShiftVersionProperties represents the properties of an OpenShiftVersion.
:ivar version: Version represents the version to create the cluster at.
:vartype version: str
"""
_attribute_map = {
'version': {'key': 'version', 'type': 'str'},
}
def __init__(
self,
*,
version: Optional[str] = None,
**kwargs
):
"""
:keyword version: Version represents the version to create the cluster at.
:paramtype version: str
"""
super(OpenShiftVersionProperties, self).__init__(**kwargs)
self.version = version
class Operation(msrest.serialization.Model):

Просмотреть файл

@ -15,7 +15,7 @@
# --------------------------------------------------------------------------
from ._operations import Operations
from ._install_versions_operations import InstallVersionsOperations
from ._open_shift_versions_operations import OpenShiftVersionsOperations
from ._open_shift_clusters_operations import OpenShiftClustersOperations
from ._machine_pools_operations import MachinePoolsOperations
from ._secrets_operations import SecretsOperations
@ -24,7 +24,7 @@ from ._sync_sets_operations import SyncSetsOperations
__all__ = [
'Operations',
'InstallVersionsOperations',
'OpenShiftVersionsOperations',
'OpenShiftClustersOperations',
'MachinePoolsOperations',
'SecretsOperations',

Просмотреть файл

@ -30,7 +30,7 @@ from .._vendor import _convert_request, _format_url_section
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, List, Optional, TypeVar
from typing import Any, Callable, Dict, Optional, TypeVar
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@ -73,8 +73,8 @@ def build_list_request(
)
# fmt: on
class InstallVersionsOperations(object):
"""InstallVersionsOperations operations.
class OpenShiftVersionsOperations(object):
"""OpenShiftVersionsOperations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
@ -101,7 +101,7 @@ class InstallVersionsOperations(object):
location, # type: str
**kwargs # type: Any
):
# type: (...) -> List[str]
# type: (...) -> "_models.OpenShiftVersionList"
"""Lists all OpenShift versions available to install in the specified location.
The operation returns the installable OpenShift versions as strings.
@ -109,11 +109,11 @@ class InstallVersionsOperations(object):
:param location: The name of Azure region.
:type location: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: list of str, or the result of cls(response)
:rtype: list[str]
:return: OpenShiftVersionList, or the result of cls(response)
:rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersionList
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[List[str]]
cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftVersionList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
@ -142,7 +142,7 @@ class InstallVersionsOperations(object):
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('[str]', pipeline_response)
deserialized = self._deserialize('OpenShiftVersionList', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})

Просмотреть файл

@ -6,9 +6,15 @@
},
"responses": {
"200": {
"body": [
"4.10.20"
"body": {
"value": [
{
"properties": {
"version": "4.10.20"
}
}
]
}
}
}
}

Просмотреть файл

@ -56,11 +56,11 @@
"/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/locations/{location}/listinstallversions": {
"get": {
"tags": [
"InstallVersions"
"OpenShiftVersions"
],
"summary": "Lists all OpenShift versions available to install in the specified location.",
"description": "The operation returns the installable OpenShift versions as strings.",
"operationId": "InstallVersions_List",
"operationId": "OpenShiftVersions_List",
"parameters": [
{
"$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter"
@ -76,7 +76,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/InstallVersions"
"$ref": "#/definitions/OpenShiftVersionList"
}
},
"default": {
@ -88,7 +88,7 @@
},
"x-ms-examples": {
"Lists all OpenShift versions available to install in the specified location.": {
"$ref": "./examples/InstallVersions_List.json"
"$ref": "./examples/OpenShiftVersions_List.json"
}
}
}
@ -1801,18 +1801,6 @@
}
}
},
"InstallVersion": {
"description": "InstallVersion is the OpenShift installation version string.",
"type": "string"
},
"InstallVersions": {
"description": "InstallVersions represents a List of OpenShift installable versions.",
"type": "array",
"items": {
"$ref": "#/definitions/InstallVersion"
},
"x-ms-identifiers": []
},
"MachinePool": {
"description": "MachinePool represents a MachinePool",
"type": "object",
@ -2025,10 +2013,6 @@
"$ref": "#/definitions/IngressProfile"
},
"x-ms-identifiers": []
},
"installVersion": {
"description": "The cluster install version.",
"type": "string"
}
}
},
@ -2052,6 +2036,61 @@
}
}
},
"OpenShiftVersion": {
"description": "OpenShiftVersion represents an OpenShift version that can be installed.",
"type": "object",
"allOf": [
{
"$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ProxyResource"
}
],
"properties": {
"id": {
"description": "The ID for the resource.",
"type": "string"
},
"name": {
"description": "Name of the resource.",
"type": "string"
},
"type": {
"description": "The resource type.",
"type": "string"
},
"properties": {
"$ref": "#/definitions/OpenShiftVersionProperties",
"description": "The properties for the OpenShiftVersion resource."
}
}
},
"OpenShiftVersionList": {
"description": "OpenShiftVersionList represents a List of available versions.",
"type": "object",
"properties": {
"value": {
"description": "The List of available versions.",
"type": "array",
"items": {
"$ref": "#/definitions/OpenShiftVersion"
},
"x-ms-identifiers": []
},
"nextLink": {
"description": "Next Link to next operation.",
"type": "string"
}
}
},
"OpenShiftVersionProperties": {
"description": "OpenShiftVersionProperties represents the properties of an OpenShiftVersion.",
"type": "object",
"properties": {
"version": {
"description": "Version represents the version to create the cluster at.",
"type": "string"
}
}
},
"Operation": {
"description": "Operation represents an RP operation.",
"type": "object",