Skip to content

Commit

Permalink
Include hand crafted resources in documentation indexes (#3055)
Browse files Browse the repository at this point in the history
* Rely on TaskName instead of the entire resource
* Add Where() to set.Set and test
* Add Except() to set.Set and test
* Use summary item for report
* Find hand crafted types based on configuration
* Add visitor method for every version
* Include hand crafted resources in the report
* Add links to samples
  • Loading branch information
theunrepentantgeek authored Jun 12, 2023
1 parent 975d4d8 commit b9c36cb
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 77 deletions.
8 changes: 5 additions & 3 deletions docs/hugo/content/reference/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ These resource versions are deprecated and will be removed in an upcoming ASO re
| [FlexibleServer](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServer) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserver.yaml) |
| [FlexibleServersDatabase](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServersDatabase) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserversdatabase.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServersFirewallRule) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserversfirewallrule.yaml) |
| [User](https://azure.github.io/azure-service-operator/reference/dbformysql/v1/#dbformysql.azure.com/v1.User) | v1 | v1 | v2.0.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1api/v1_user.yaml) |

## DBforPostgreSQL

Expand Down Expand Up @@ -313,6 +314,7 @@ These resource versions are deprecated and will be removed in an upcoming ASO re
| [FlexibleServersDatabase](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20210601/#dbforpostgresql.azure.com/v1beta20210601.FlexibleServersDatabase) | 2021-06-01 | v1beta20210601 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20210601/v1beta20210601_flexibleserversdatabase.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20220120preview/#dbforpostgresql.azure.com/v1beta20220120preview.FlexibleServersFirewallRule) | 2022-01-20-preview | v1beta20220120preview | v2.0.0-beta.4 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20220120preview/v1beta20220120preview_flexibleserversfirewallrule.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20210601/#dbforpostgresql.azure.com/v1beta20210601.FlexibleServersFirewallRule) | 2021-06-01 | v1beta20210601 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20210601/v1beta20210601_flexibleserversfirewallrule.yaml) |
| [User](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1/#dbforpostgresql.azure.com/v1.User) | v1 | v1 | v2.0.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1api/v1_user.yaml) |

## Devices

Expand All @@ -321,9 +323,9 @@ These resource versions are deprecated and will be removed in an upcoming ASO re
These resource(s) are available for use in the current release of ASO. Different versions of a given resource reflect different versions of the Azure ARM API.


| Resource | ARM Version | CRD Version | Supported From | Sample |
|----------|-------------|---------------|----------------|----------------------------------------------------------------------------------------------------------------------|
| IotHub | 2021-07-02 | v1api20210702 | v2.1.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/devices/v1api/v1api20210702_iothub.yaml) |
| Resource | ARM Version | CRD Version | Supported From | Sample |
|----------------------------------------------------------------------------------------------------------------------------------|-------------|---------------|----------------|----------------------------------------------------------------------------------------------------------------------|
| [IotHub](https://azure.github.io/azure-service-operator/reference/devices/v1api20210702/#devices.azure.com/v1api20210702.IotHub) | 2021-07-02 | v1api20210702 | v2.1.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/devices/v1api/v1api20210702_iothub.yaml) |

## DocumentDB

Expand Down
1 change: 1 addition & 0 deletions docs/hugo/content/reference/dbformysql/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ These resource versions are deprecated and will be removed in an upcoming ASO re
| [FlexibleServer](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServer) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserver.yaml) |
| [FlexibleServersDatabase](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServersDatabase) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserversdatabase.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbformysql/v1beta20210501/#dbformysql.azure.com/v1beta20210501.FlexibleServersFirewallRule) | 2021-05-01 | v1beta20210501 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1beta/v1beta20210501_flexibleserversfirewallrule.yaml) |
| [User](https://azure.github.io/azure-service-operator/reference/dbformysql/v1/#dbformysql.azure.com/v1.User) | v1 | v1 | v2.0.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbformysql/v1api/v1_user.yaml) |

1 change: 1 addition & 0 deletions docs/hugo/content/reference/dbforpostgresql/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ These resource versions are deprecated and will be removed in an upcoming ASO re
| [FlexibleServersDatabase](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20210601/#dbforpostgresql.azure.com/v1beta20210601.FlexibleServersDatabase) | 2021-06-01 | v1beta20210601 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20210601/v1beta20210601_flexibleserversdatabase.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20220120preview/#dbforpostgresql.azure.com/v1beta20220120preview.FlexibleServersFirewallRule) | 2022-01-20-preview | v1beta20220120preview | v2.0.0-beta.4 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20220120preview/v1beta20220120preview_flexibleserversfirewallrule.yaml) |
| [FlexibleServersFirewallRule](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1beta20210601/#dbforpostgresql.azure.com/v1beta20210601.FlexibleServersFirewallRule) | 2021-06-01 | v1beta20210601 | v2.0.0-beta.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1beta20210601/v1beta20210601_flexibleserversfirewallrule.yaml) |
| [User](https://azure.github.io/azure-service-operator/reference/dbforpostgresql/v1/#dbforpostgresql.azure.com/v1.User) | v1 | v1 | v2.0.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/dbforpostgresql/v1api/v1_user.yaml) |

6 changes: 3 additions & 3 deletions docs/hugo/content/reference/devices/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ no_list: true
These resource(s) are available for use in the current release of ASO. Different versions of a given resource reflect different versions of the Azure ARM API.


| Resource | ARM Version | CRD Version | Supported From | Sample |
|----------|-------------|---------------|----------------|----------------------------------------------------------------------------------------------------------------------|
| IotHub | 2021-07-02 | v1api20210702 | v2.1.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/devices/v1api/v1api20210702_iothub.yaml) |
| Resource | ARM Version | CRD Version | Supported From | Sample |
|----------------------------------------------------------------------------------------------------------------------------------|-------------|---------------|----------------|----------------------------------------------------------------------------------------------------------------------|
| [IotHub](https://azure.github.io/azure-service-operator/reference/devices/v1api20210702/#devices.azure.com/v1api20210702.IotHub) | 2021-07-02 | v1api20210702 | v2.1.0 | [View](https://github.com/Azure/azure-service-operator/tree/main/v2/samples/devices/v1api/v1api20210702_iothub.yaml) |

6 changes: 6 additions & 0 deletions v2/azure-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,9 @@ objectModelConfiguration:
$exportAs: Database
$supportedFrom: v2.0.0-beta.1
dbformysql:
v1: # Handcrafted
User:
$supportedFrom: v2.0.0
2021-05-01:
DataEncryption:
GeoBackupUserAssignedIdentityId:
Expand Down Expand Up @@ -970,6 +973,9 @@ objectModelConfiguration:
$exportAs: FlexibleServersConfiguration
$supportedFrom: v2.1.0
dbforpostgresql:
v1: # Handcrafted
User:
$supportedFrom: v2.0.0
2021-06-01:
FlexibleServer:
$export: true
Expand Down
26 changes: 26 additions & 0 deletions v2/internal/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,32 @@ func (set Set[T]) Values() []T {
return maps.Keys(set)
}

// Where returns a new set with only the set of values which match the predicate
func (set Set[T]) Where(predicate func(T) bool) Set[T] {
result := make(Set[T], len(set))

for val := range set {
if predicate(val) {
result.Add(val)
}
}

return result
}

// Except returns a new set with only the set of values which are not in the other set
func (set Set[T]) Except(other Set[T]) Set[T] {
result := make(Set[T], len(set))

for val := range set {
if !other.Contains(val) {
result.Add(val)
}
}

return result
}

// AsSortedSlice returns a sorted slice of values from this set
func AsSortedSlice[T constraints.Ordered](set Set[T]) []T {
result := maps.Keys(set)
Expand Down
20 changes: 20 additions & 0 deletions v2/internal/set/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,23 @@ func TestSet_WhenGettingSortedSlice_ReturnsSortedValues(t *testing.T) {
sortedValues := AsSortedSlice(set)
g.Expect(sortedValues).To(Equal([]int{1, 2, 3}))
}

func TestSet_Where_GivenPredicate_ReturnsSetOfMatchingItems(t *testing.T) {
t.Parallel()
g := NewGomegaWithT(t)

set := Make(1, 2, 3, 4, 5)
evenSet := set.Where(func(x int) bool {
return x%2 == 0
})
g.Expect(evenSet).To(Equal(Make(2, 4)))
}

func TestSet_Except_GivenSetOfVues_ReturnsRemainingValues(t *testing.T) {
t.Parallel()
g := NewGomegaWithT(t)

set := Make(1, 2, 3, 4, 5)
remainingSet := set.Except(Make(2, 4))
g.Expect(remainingSet).To(Equal(Make(1, 3, 5)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ func CreateTypesForBackwardCompatibility(
return nil, err
}

err = configuration.VerifySupportedFromConsumed()
if err != nil {
return nil, err
}

compatibilityDefs, err := createBackwardCompatibleDefinitions(resources, state.Definitions())
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit b9c36cb

Please sign in to comment.