forked from Azure/ARO-RP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2023-11-22 stable API (porting 07-01-preview api) (Azure#3300)
* adding 2023-11-22 stable --------- Co-authored-by: b-jhoreman <[email protected]>
- Loading branch information
Showing
98 changed files
with
21,070 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
// SyncSetList represents a list of SyncSets | ||
type SyncSetList struct { | ||
// The list of syncsets. | ||
SyncSets []*SyncSet `json:"value"` | ||
|
||
// The link used to get the next page of operations. | ||
NextLink string `json:"nextLink,omitempty"` | ||
} | ||
|
||
// SyncSet represents a SyncSet for an Azure Red Hat OpenShift Cluster. | ||
type SyncSet struct { | ||
// This is a flag used during the swagger generation typewalker to | ||
// signal that it should be marked as a proxy resource and | ||
// not a tracked ARM resource. | ||
proxyResource bool | ||
|
||
// The resource ID. | ||
ID string `json:"id,omitempty" mutable:"case"` | ||
|
||
// The resource name. | ||
Name string `json:"name,omitempty" mutable:"case"` | ||
|
||
// The resource type. | ||
Type string `json:"type,omitempty" mutable:"case"` | ||
|
||
// SystemData metadata relating to this resource. | ||
SystemData *SystemData `json:"systemData,omitempty"` | ||
|
||
// The Syncsets properties | ||
Properties SyncSetProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// SyncSetProperties represents the properties of a SyncSet | ||
type SyncSetProperties struct { | ||
// Resources represents the SyncSets configuration. | ||
Resources string `json:"resources,omitempty"` | ||
} | ||
|
||
// MachinePoolList represents a list of MachinePools | ||
type MachinePoolList struct { | ||
// The list of Machine Pools. | ||
MachinePools []*MachinePool `json:"value"` | ||
|
||
// The link used to get the next page of operations. | ||
NextLink string `json:"nextLink,omitempty"` | ||
} | ||
|
||
// MachinePool represents a MachinePool | ||
type MachinePool struct { | ||
// This is a flag used during the swagger generation typewalker to | ||
// signal that it should be marked as a proxy resource and | ||
// not a tracked ARM resource. | ||
proxyResource bool | ||
|
||
// The Resource ID. | ||
ID string `json:"id,omitempty"` | ||
|
||
// The resource name. | ||
Name string `json:"name,omitempty"` | ||
|
||
// The resource type. | ||
Type string `json:"type,omitempty" mutable:"case"` | ||
|
||
// SystemData metadata relating to this resource. | ||
SystemData *SystemData `json:"systemData,omitempty"` | ||
|
||
// The MachinePool Properties | ||
Properties MachinePoolProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// MachinePoolProperties represents the properties of a MachinePool | ||
type MachinePoolProperties struct { | ||
Resources string `json:"resources,omitempty"` | ||
} | ||
|
||
// SyncSetList represents a list of SyncSets | ||
type SyncIdentityProviderList struct { | ||
// The list of sync identity providers | ||
SyncIdentityProviders []*SyncIdentityProvider `json:"value"` | ||
|
||
// The link used to get the next page of operations. | ||
NextLink string `json:"nextLink,omitempty"` | ||
} | ||
|
||
// SyncIdentityProvider represents a SyncIdentityProvider | ||
type SyncIdentityProvider struct { | ||
// This is a flag used during the swagger generation typewalker to | ||
// signal that it should be marked as a proxy resource and | ||
// not a tracked ARM resource. | ||
proxyResource bool | ||
|
||
// The Resource ID. | ||
ID string `json:"id,omitempty"` | ||
|
||
// The resource name. | ||
Name string `json:"name,omitempty"` | ||
|
||
// The resource type. | ||
Type string `json:"type,omitempty" mutable:"case"` | ||
|
||
// SystemData metadata relating to this resource. | ||
SystemData *SystemData `json:"systemData,omitempty"` | ||
|
||
// The SyncIdentityProvider Properties | ||
Properties SyncIdentityProviderProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// SyncSetProperties represents the properties of a SyncSet | ||
type SyncIdentityProviderProperties struct { | ||
Resources string `json:"resources,omitempty"` | ||
} | ||
|
||
// SecretList represents a list of Secrets | ||
type SecretList struct { | ||
// The list of secrets. | ||
Secrets []*Secret `json:"value"` | ||
|
||
// The link used to get the next page of operations. | ||
NextLink string `json:"nextLink,omitempty"` | ||
} | ||
|
||
// Secret represents a secret. | ||
type Secret struct { | ||
// This is a flag used during the swagger generation typewalker to | ||
// signal that it should be marked as a proxy resource and | ||
// not a tracked ARM resource. | ||
proxyResource bool | ||
|
||
// The Resource ID. | ||
ID string `json:"id,omitempty"` | ||
|
||
// The resource name. | ||
Name string `json:"name,omitempty"` | ||
|
||
// The resource type. | ||
Type string `json:"type,omitempty" mutable:"case"` | ||
|
||
// SystemData metadata relating to this resource. | ||
SystemData *SystemData `json:"systemData,omitempty"` | ||
|
||
// The Secret Properties | ||
Properties SecretProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// SecretProperties represents the properties of a Secret | ||
type SecretProperties struct { | ||
// The Secrets Resources. | ||
SecretResources string `json:"secretResources,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type clusterManagerStaticValidator struct{} | ||
|
||
func (c clusterManagerStaticValidator) Static(body string, ocmResourceType string) error { | ||
var resource map[string]interface{} | ||
|
||
if decodedBody, err := base64.StdEncoding.DecodeString(body); err == nil { | ||
err = json.Unmarshal(decodedBody, &resource) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
b := []byte(body) | ||
err := json.Unmarshal(b, &resource) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
payloadResourceKind := strings.ToLower(resource["kind"].(string)) | ||
if payloadResourceKind != ocmResourceType { | ||
return fmt.Errorf("wanted Kind '%v', resource is Kind '%v'", ocmResourceType, payloadResourceKind) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
var ocmResource = string(` | ||
{ | ||
"apiVersion": "hive.openshift.io/v1", | ||
"kind": "SyncSet", | ||
"metadata": { | ||
"name": "sample", | ||
"namespace": "aro-f60ae8a2-bca1-4987-9056-f2f6a1837caa" | ||
}, | ||
"spec": { | ||
"clusterDeploymentRefs": [], | ||
"resources": [ | ||
{ | ||
"apiVersion": "v1", | ||
"kind": "ConfigMap", | ||
"metadata": { | ||
"name": "myconfigmap" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
`) | ||
|
||
var ocmResourceEncoded = "eyAKICAiYXBpVmVyc2lvbiI6ICJoaXZlLm9wZW5zaGlmdC5pby92MSIsCiAgImtpbmQiOiAiU3luY1NldCIsCiAgIm1ldGFkYXRhIjogewogICAgIm5hbWUiOiAic2FtcGxlIiwKICAgICJuYW1lc3BhY2UiOiAiYXJvLWY2MGFlOGEyLWJjYTEtNDk4Ny05MDU2LWYyZjZhMTgzN2NhYSIKICB9LAogICJzcGVjIjogewogICAgImNsdXN0ZXJEZXBsb3ltZW50UmVmcyI6IFtdLAogICAgInJlc291cmNlcyI6IFsKICAgICAgewogICAgICAgICJhcGlWZXJzaW9uIjogInYxIiwKICAgICAgICAia2luZCI6ICJDb25maWdNYXAiLAogICAgICAgICJtZXRhZGF0YSI6IHsKICAgICAgICAgICJuYW1lIjogIm15Y29uZmlnbWFwIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQo=" | ||
|
||
func TestStatic(t *testing.T) { | ||
for _, tt := range []struct { | ||
name string | ||
ocmResource string | ||
ocmResourceType string | ||
wantErr bool | ||
err string | ||
}{ | ||
{ | ||
name: "payload Kind matches", | ||
ocmResource: ocmResource, | ||
ocmResourceType: "syncset", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "payload Kind matches and is a base64 encoded string", | ||
ocmResource: ocmResourceEncoded, | ||
ocmResourceType: "syncset", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "payload Kind does not match", | ||
ocmResource: ocmResource, | ||
ocmResourceType: "route", | ||
wantErr: true, | ||
err: "wanted Kind 'route', resource is Kind 'syncset'", | ||
}, | ||
{ | ||
name: "payload Kind does not match and is a base64 encoded string", | ||
ocmResource: ocmResourceEncoded, | ||
ocmResourceType: "route", | ||
wantErr: true, | ||
err: "wanted Kind 'route', resource is Kind 'syncset'", | ||
}, | ||
} { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := &clusterManagerStaticValidator{} | ||
|
||
err := c.Static(tt.ocmResource, tt.ocmResourceType) | ||
if err != nil && tt.wantErr { | ||
if fmt.Sprint(err) != tt.err { | ||
t.Errorf("wanted '%v', got '%v'", tt.err, err) | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
//go:generate go run ../../../hack/swagger github.com/Azure/ARO-RP/pkg/api/v20231122 ../../../swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2023-11-22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"github.com/Azure/ARO-RP/pkg/api" | ||
) | ||
|
||
type machinePoolConverter struct{} | ||
|
||
func (c machinePoolConverter) ToExternal(mp *api.MachinePool) interface{} { | ||
out := new(MachinePool) | ||
out.proxyResource = true | ||
out.ID = mp.ID | ||
out.Name = mp.Name | ||
out.Type = mp.Type | ||
out.Properties.Resources = mp.Properties.Resources | ||
return out | ||
} | ||
|
||
func (c machinePoolConverter) ToInternal(_mp interface{}, out *api.MachinePool) { | ||
ocm := _mp.(*api.MachinePool) | ||
out.ID = ocm.ID | ||
} | ||
|
||
// ToExternalList returns a slice of external representations of the internal objects | ||
func (c machinePoolConverter) ToExternalList(mp []*api.MachinePool) interface{} { | ||
l := &MachinePoolList{ | ||
MachinePools: make([]*MachinePool, 0, len(mp)), | ||
} | ||
|
||
for _, machinepool := range mp { | ||
c := c.ToExternal(machinepool) | ||
l.MachinePools = append(l.MachinePools, c.(*MachinePool)) | ||
} | ||
|
||
return l | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package v20231122 | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"github.com/Azure/ARO-RP/pkg/api" | ||
) | ||
|
||
func exampleMachinePool() *MachinePool { | ||
doc := api.ExampleClusterManagerConfigurationDocumentMachinePool() | ||
ext := (&machinePoolConverter{}).ToExternal(doc.MachinePool) | ||
return ext.(*MachinePool) | ||
} | ||
|
||
func ExampleMachinePoolPutParameter() interface{} { | ||
mp := exampleMachinePool() | ||
mp.ID = "" | ||
mp.Type = "" | ||
mp.Name = "" | ||
return mp | ||
} | ||
|
||
func ExampleMachinePoolPatchParameter() interface{} { | ||
return ExampleMachinePoolPutParameter() | ||
} | ||
|
||
func ExampleMachinePoolResponse() interface{} { | ||
return exampleMachinePool() | ||
} | ||
|
||
func ExampleMachinePoolListResponse() interface{} { | ||
return &MachinePoolList{ | ||
MachinePools: []*MachinePool{ | ||
ExampleMachinePoolResponse().(*MachinePool), | ||
}, | ||
} | ||
} |
Oops, something went wrong.