From 6a49e3d25b80c053a356191a53dc1edf0a0b436c Mon Sep 17 00:00:00 2001 From: Adam Janikowski <12255597+ajanikow@users.noreply.github.com> Date: Mon, 24 Jul 2023 17:10:59 +0200 Subject: [PATCH] [Feature] Generate feature list (#1362) --- README.md | 98 +++++---- docs/design/features/rebalancer.md | 10 + docs/design/features/rebalancer_v2.md | 2 +- internal/features.yaml | 215 +++++++++++++++++++ internal/limits.yaml | 5 + internal/platforms.yaml | 14 +- internal/readme.go | 284 ++++++++++++++++++++++---- pkg/util/refs.go | 16 ++ 8 files changed, 559 insertions(+), 85 deletions(-) create mode 100644 docs/design/features/rebalancer.md create mode 100644 internal/features.yaml create mode 100644 internal/limits.yaml diff --git a/README.md b/README.md index c206caff2..adfa1a95d 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,15 @@ The ArangoDB Kubernetes Operator is Production ready. [Documentation](https://www.arangodb.com/docs/stable/deployment-kubernetes.html) +### Limits + + +| Limit | Description | Community | Enterprise | +|:-------------------|:-----------------------------------------------------------------------------|:----------|:-----------| +| Cluster size limit | Limits of the nodes (DBServers & Coordinators) supported in the Cluster mode | 64 | 1024 | + + + ### Production readiness state Beginning with Version 0.3.11 we maintain a production readiness @@ -29,52 +38,67 @@ Kubernetes versions starting from 1.18 are supported and tested, charts and mani The following table has the general readiness state, the table below covers individual newer features separately. - + | Platform | Kubernetes Version | ArangoDB Version | State | Remarks | Provider Remarks | |:--------------------|:-------------------|:-----------------|:-----------|:------------------------------------------|:-----------------------------------| -| Google GKE | 1.21-1.25 | >= 3.6.0 | Production | Don't use micro nodes | | -| Azure AKS | 1.21-1.24 | >= 3.6.0 | Production | | | -| Amazon EKS | 1.21-1.24 | >= 3.6.0 | Production | | [Amazon EKS](./docs/providers/eks) | +| Google GKE | 1.21-1.26 | >= 3.6.0 | Production | Don't use micro nodes | | +| Azure AKS | 1.21-1.26 | >= 3.6.0 | Production | | | +| Amazon EKS | 1.21-1.26 | >= 3.6.0 | Production | | [Amazon EKS](./docs/providers/eks) | | IBM Cloud | 1.17 | >= 3.6.0 | Deprecated | Support will be dropped in Operator 1.5.0 | | | IBM Cloud | 1.18-1.21 | >= 3.6.0 | Production | | | | OpenShift | 3.11 | >= 3.6.0 | Deprecated | Support will be dropped in Operator 1.5.0 | | -| OpenShift | 4.2-4.11 | >= 3.6.0 | Production | | | +| OpenShift | 4.2-4.13 | >= 3.6.0 | Production | | | | BareMetal (kubeadm) | <= 1.20 | >= 3.6.0 | Deprecated | Support will be dropped in Operator 1.5.0 | | -| BareMetal (kubeadm) | 1.21-1.25 | >= 3.6.0 | Production | | | -| Minikube | 1.21-1.25 | >= 3.6.0 | Devel Only | | | -| Other | 1.21-1.25 | >= 3.6.0 | Devel Only | | | +| BareMetal (kubeadm) | 1.21-1.27 | >= 3.6.0 | Production | | | +| Minikube | 1.21-1.27 | >= 3.6.0 | Devel Only | | | +| Other | 1.21-1.27 | >= 3.6.0 | Devel Only | | | - + -#### Feature-wise production readiness table: +#### Operator Features -| Feature | Operator Version | ArangoDB Version | ArangoDB Edition | Introduced | State | Enabled | Flag | Remarks | -|--------------------------------------------------------------------------------------|------------------|------------------|-----------------------|------------|--------------|---------|-------------------------------------------------------|--------------------------------------------------------------------------| -| Pod Disruption Budgets | 0.3.11 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | N/A | -| Volume Resizing | 0.3.11 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | N/A | -| Disabling of liveness probes | 0.3.11 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | N/A | -| Volume Claim Templates | 1.0.0 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | N/A | -| Prometheus Metrics Exporter | 1.0.0 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | Prometheus required | -| Sidecar Containers | 1.0.0 | Any | Community, Enterprise | 0.3.10 | Production | True | N/A | N/A | -| Operator Single Mode | 1.0.4 | Any | Community, Enterprise | 1.0.4 | Production | False | --mode.single | Only 1 instance of Operator allowed in namespace when feature is enabled | -| TLS SNI Support | 1.0.3 | >= 3.7.0 | Enterprise | 1.0.3 | Production | True | --deployment.feature.tls-sni | N/A | -| TLS Runtime Rotation Support | 1.1.0 | > 3.7.0 | Enterprise | 1.0.4 | Production | True | --deployment.feature.tls-rotation | N/A | -| JWT Rotation Support | 1.1.0 | > 3.7.0 | Enterprise | 1.0.3 | Production | True | --deployment.feature.jwt-rotation | N/A | -| Encryption Key Rotation Support | 1.2.0 | > 3.7.0 | Enterprise | 1.0.3 | NotSupported | False | --deployment.feature.encryption-rotation | N/A | -| Version Check | 1.1.4 | >= 3.6.0 | Community, Enterprise | 1.1.4 | Alpha | False | --deployment.feature.upgrade-version-check | N/A | -| Version Check | 1.2.23 | >= 3.6.0 | Community, Enterprise | 1.1.4 | Production | True | --deployment.feature.upgrade-version-check | N/A | -| Version Check V2 | 1.2.31 | >= 3.6.0 | Community, Enterprise | 1.2.31 | Alpha | False | --deployment.feature.upgrade-version-check-v2 | N/A | -| Operator Maintenance Management Support | 1.2.0 | >= 3.6.0 | Community, Enterprise | 1.0.7 | Production | True | --deployment.feature.maintenance | N/A | -| Graceful Restart | 1.2.5 | >= 3.6.0 | Community, Enterprise | 1.0.7 | Production | True | --deployment.feature.graceful-shutdown | N/A | -| Optional Graceful Restart | 1.2.25 | >= 3.6.0 | Community, Enterprise | 1.2.5 | Beta | True | --deployment.feature.optional-graceful-shutdown | N/A | -| Operator Internal Metrics Exporter | 1.2.0 | >= 3.6.0 | Community, Enterprise | 1.2.0 | Production | True | --deployment.feature.metrics-exporter | N/A | -| [Operator Ephemeral Volumes](docs/design/features/ephemeral_volumes.md) | 1.2.2 | >= 3.7.0 | Community, Enterprise | 1.2.2 | Alpha | False | --deployment.feature.ephemeral-volumes | N/A | -| [Operator Ephemeral Volumes](docs/design/features/ephemeral_volumes.md) | 1.2.2 | >= 3.7.0 | Community, Enterprise | 1.2.31 | Beta | False | --deployment.feature.ephemeral-volumes | N/A | -| [Failover Leader service](docs/design/features/failover_leader_service.md) | 1.2.13 | >= 3.7.0 | Community, Enterprise | 1.2.13 | Production | False | --deployment.feature.failover-leadership | N/A | -| [Spec Default Restore](docs/design/features/deployment_spec_defaults.md) | 1.2.21 | >= 3.7.0 | Community, Enterprise | 1.2.21 | Beta | True | --deployment.feature.deployment-spec-defaults-restore | If set to False Operator will not change ArangoDeployment Spec | -| [Force Rebuild Out Synced Shards](docs/design/features/rebuild_out_synced_shards.md) | 1.2.27 | >= 3.8.0 | Community, Enterprise | 1.2.27 | Beta | False | --deployment.feature.force-rebuild-out-synced-shards | It should be used only if user is aware of the risks. | -| [Rebalancer V2](docs/design/features/rebalancer_v2.md) | 1.2.31 | >= 3.10.0 | Community, Enterprise | 1.2.31 | Alpha | False | --deployment.feature.rebalancer-v2 | N/A | -| [Secured containers](docs/design/features/secured_containers.md) | 1.2.31 | >= 3.7.0 | Community, Enterprise | 1.2.31 | Alpha | False | --deployment.feature.secured-containers | If set to True Operator will run containers in secure mode | + +| Feature | Operator Version | Introduced | ArangoDB Version | ArangoDB Edition | State | Enabled | Flag | Remarks | +|:-------------------------------------------------------------------------------------|:-----------------|:-----------|:-----------------|:----------------------|:-------------|:--------|:------------------------------------------------------|:-------------------------------------------------------------------------| +| [Rebalancer V2](docs/design/features/rebalancer_v2.md) | 1.2.31 | 1.2.31 | >= 3.10.0 | Community, Enterprise | Alpha | False | --deployment.feature.rebalancer-v2 | N/A | +| [Secured containers](docs/design/features/secured_containers.md) | 1.2.31 | 1.2.31 | >= 3.8.0 | Community, Enterprise | Alpha | False | --deployment.feature.secured-containers | If set to True Operator will run containers in secure mode | +| Version Check V2 | 1.2.31 | 1.2.31 | >= 3.8.0 | Community, Enterprise | Alpha | False | --deployment.feature.upgrade-version-check-V2 | N/A | +| [Operator Ephemeral Volumes](docs/design/features/ephemeral_volumes.md) | 1.2.31 | 1.2.2 | >= 3.8.0 | Community, Enterprise | Beta | False | --deployment.feature.ephemeral-volumes | N/A | +| [Force Rebuild Out Synced Shards](docs/design/features/rebuild_out_synced_shards.md) | 1.2.27 | 1.2.27 | >= 3.8.0 | Community, Enterprise | Production | False | --deployment.feature.force-rebuild-out-synced-shards | It should be used only if user is aware of the risks. | +| [Spec Default Restore](docs/design/features/deployment_spec_defaults.md) | 1.2.25 | 1.2.21 | >= 3.8.0 | Community, Enterprise | Beta | True | --deployment.feature.deployment-spec-defaults-restore | If set to False Operator will not change ArangoDeployment Spec | +| Version Check | 1.2.23 | 1.1.4 | >= 3.8.0 | Community, Enterprise | Production | True | --deployment.feature.upgrade-version-check | N/A | +| [Failover Leader service](docs/design/features/failover_leader_service.md) | 1.2.13 | 1.2.13 | >= 3.8.0 | Community, Enterprise | Production | False | --deployment.feature.failover-leadership | N/A | +| Graceful Restart | 1.2.5 | 1.0.7 | >= 3.8.0 | Community, Enterprise | Production | True | ---deployment.feature.graceful-shutdown | N/A | +| Optional Graceful Restart | 1.2.0 | 1.2.5 | >= 3.8.0 | Community, Enterprise | Production | False | --deployment.feature.optional-graceful-shutdown | N/A | +| Operator Internal Metrics Exporter | 1.2.0 | 1.2.0 | >= 3.8.0 | Community, Enterprise | Production | True | --deployment.feature.metrics-exporter | N/A | +| Operator Maintenance Management Support | 1.2.0 | 1.0.7 | >= 3.8.0 | Community, Enterprise | Production | True | --deployment.feature.maintenance | N/A | +| Encryption Key Rotation Support | 1.2.0 | 1.0.3 | >= 3.8.0 | Enterprise | NotSupported | False | --deployment.feature.encryption-rotation | N/A | +| TLS Runtime Rotation Support | 1.1.0 | 1.0.4 | >= 3.8.0 | Enterprise | Production | True | --deployment.feature.tls-rotation | N/A | +| JWT Rotation Support | 1.1.0 | 1.0.3 | >= 3.8.0 | Enterprise | Production | True | --deployment.feature.jwt-rotation | N/A | +| Operator Single Mode | 1.0.4 | 1.0.4 | >= 3.8.0 | Community, Enterprise | Production | False | --mode.single | Only 1 instance of Operator allowed in namespace when feature is enabled | +| TLS SNI Support | 1.0.3 | 1.0.3 | >= 3.8.0 | Enterprise | Production | True | --deployment.feature.tls-sni | N/A | +| Disabling of liveness probes | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | N/A | +| Pod Disruption Budgets | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | N/A | +| Prometheus Metrics Exporter | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | Prometheus required | +| Sidecar Containers | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | N/A | +| Volume Claim Templates | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | N/A | +| Volume Resizing | 0.3.11 | 0.3.10 | >= 3.8.0 | Community, Enterprise | Production | True | N/A | N/A | + + + +#### Operator Enterprise Only Features + +To upgrade to the Enterprise Edition, you need to get in touch with the ArangoDB team. [Contact us](https://www.arangodb.com/contact/) for more details. + + +| Feature | Operator Version | Introduced | ArangoDB Version | ArangoDB Edition | State | Enabled | Flag | Remarks | +|:-------------------------------------------------------|:-----------------|:-----------|:-----------------|:-----------------|:-----------|:--------|:-----|:----------------------------------------------------------------------------| +| AgencyCache | 1.2.30 | 1.2.30 | >= 3.8.0 | Enterprise | Production | True | N/A | Enable Agency Cache mechanism in the Operator (Increase limit of the nodes) | +| Member Maintenance Support | 1.2.25 | 1.2.16 | >= 3.8.0 | Enterprise | Production | True | N/A | Enable Member Maintenance during planned restarts | +| [Rebalancer](docs/design/features/rebalancer.md) | 1.2.15 | 1.2.5 | >= 3.8.0 | Enterprise | Production | True | N/A | N/A | +| [TopologyAwareness](docs/design/topology_awareness.md) | 1.2.4 | 1.2.4 | >= 3.8.0 | Enterprise | Production | True | N/A | N/A | + + ## Operator Community Edition (CE) diff --git a/docs/design/features/rebalancer.md b/docs/design/features/rebalancer.md new file mode 100644 index 000000000..4c1cdfca5 --- /dev/null +++ b/docs/design/features/rebalancer.md @@ -0,0 +1,10 @@ +# ArangoDB Rebalancer Support + +## How to use + +To enable Rebalancer in ArangoDeployment: +```yaml +spec: + rebalancer: + enabled: true +``` \ No newline at end of file diff --git a/docs/design/features/rebalancer_v2.md b/docs/design/features/rebalancer_v2.md index 1ef0c0568..b29fdda73 100644 --- a/docs/design/features/rebalancer_v2.md +++ b/docs/design/features/rebalancer_v2.md @@ -1,4 +1,4 @@ -# ArangoDB Rebalancer Support +# ArangoDB Rebalancer V2 Support ## Overview diff --git a/internal/features.yaml b/internal/features.yaml new file mode 100644 index 000000000..f956f3d23 --- /dev/null +++ b/internal/features.yaml @@ -0,0 +1,215 @@ +features: + - name: Pod Disruption Budgets + enabled: true + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Volume Resizing + enabled: true + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Disabling of liveness probes + enabled: true + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Volume Claim Templates + enabled: true + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Prometheus Metrics Exporter + enabled: true + remarks: Prometheus required + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Sidecar Containers + enabled: true + releases: + - operatorVersion: 0.3.10 + state: Alpha + - operatorVersion: 0.3.11 + state: Production + - name: Operator Single Mode + enabled: False + flag: --mode.single + remarks: Only 1 instance of Operator allowed in namespace when feature is enabled + releases: + - operatorVersion: 1.0.4 + state: Production + - name: TLS SNI Support + arangoDBEditions: Enterprise + enabled: true + flag: --deployment.feature.tls-sni + releases: + - operatorVersion: 1.0.3 + state: Production + - name: TLS Runtime Rotation Support + arangoDBEditions: Enterprise + enabled: true + flag: --deployment.feature.tls-rotation + releases: + - operatorVersion: 1.0.4 + state: Alpha + - operatorVersion: 1.1.0 + state: Production + - name: JWT Rotation Support + arangoDBEditions: Enterprise + enabled: true + flag: --deployment.feature.jwt-rotation + releases: + - operatorVersion: 1.0.3 + state: Alpha + - operatorVersion: 1.1.0 + state: Production + - name: Encryption Key Rotation Support + arangoDBEditions: Enterprise + flag: --deployment.feature.encryption-rotation + enabled: false + releases: + - operatorVersion: 1.0.3 + state: Alpha + - operatorVersion: 1.2.0 + state: NotSupported + - name: Version Check + flag: --deployment.feature.upgrade-version-check + enabled: true + releases: + - operatorVersion: 1.1.4 + state: Alpha + - operatorVersion: 1.2.23 + state: Production + - name: Version Check V2 + flag: --deployment.feature.upgrade-version-check-V2 + enabled: false + releases: + - operatorVersion: 1.2.31 + state: Alpha + - name: Operator Maintenance Management Support + flag: --deployment.feature.maintenance + enabled: true + releases: + - operatorVersion: 1.0.7 + state: Alpha + - operatorVersion: 1.2.0 + state: Production + - name: Graceful Restart + flag: '---deployment.feature.graceful-shutdown' + enabled: true + releases: + - operatorVersion: 1.0.7 + state: Alpha + - operatorVersion: 1.2.5 + state: Production + - name: Optional Graceful Restart + flag: --deployment.feature.optional-graceful-shutdown + enabled: false + releases: + - operatorVersion: 1.2.5 + state: Beta + - operatorVersion: 1.2.0 + state: Production + - name: Operator Internal Metrics Exporter + flag: --deployment.feature.metrics-exporter + enabled: true + releases: + - operatorVersion: 1.2.0 + state: Production + - name: Operator Ephemeral Volumes + doc: docs/design/features/ephemeral_volumes.md + flag: --deployment.feature.ephemeral-volumes + enabled: false + releases: + - operatorVersion: 1.2.2 + state: Alpha + - operatorVersion: 1.2.31 + state: Beta + - name: Failover Leader service + doc: docs/design/features/failover_leader_service.md + flag: --deployment.feature.failover-leadership + enabled: false + releases: + - operatorVersion: 1.2.13 + state: Production + - name: Spec Default Restore + doc: docs/design/features/deployment_spec_defaults.md + flag: --deployment.feature.deployment-spec-defaults-restore + enabled: true + remarks: If set to False Operator will not change ArangoDeployment Spec + releases: + - operatorVersion: 1.2.21 + state: Alpha + - operatorVersion: 1.2.25 + state: Beta + - name: Force Rebuild Out Synced Shards + doc: docs/design/features/rebuild_out_synced_shards.md + flag: --deployment.feature.force-rebuild-out-synced-shards + enabled: false + remarks: It should be used only if user is aware of the risks. + releases: + - operatorVersion: 1.2.27 + state: Production + - name: Rebalancer + doc: docs/design/features/rebalancer.md + enabled: true + operatorEditions: Enterprise + arangoDBEditions: Enterprise + releases: + - operatorVersion: 1.2.5 + state: Alpha + - operatorVersion: 1.2.15 + state: Production + - name: Rebalancer V2 + doc: docs/design/features/rebalancer_v2.md + arangoDBVersion: ">= 3.10.0" + flag: --deployment.feature.rebalancer-v2 + enabled: false + releases: + - operatorVersion: 1.2.31 + state: Alpha + - name: Secured containers + doc: docs/design/features/secured_containers.md + flag: --deployment.feature.secured-containers + enabled: false + remarks: If set to True Operator will run containers in secure mode + releases: + - operatorVersion: 1.2.31 + state: Alpha + - name: TopologyAwareness + doc: docs/design/topology_awareness.md + enabled: true + operatorEditions: Enterprise + arangoDBEditions: Enterprise + releases: + - operatorVersion: 1.2.4 + state: Production + - name: AgencyCache + enabled: true + operatorEditions: Enterprise + arangoDBEditions: Enterprise + remarks: Enable Agency Cache mechanism in the Operator (Increase limit of the nodes) + releases: + - operatorVersion: 1.2.30 + state: Production + - name: Member Maintenance Support + enabled: true + operatorEditions: Enterprise + arangoDBEditions: Enterprise + remarks: Enable Member Maintenance during planned restarts + releases: + - operatorVersion: 1.2.16 + state: Alpha + - operatorVersion: 1.2.25 + state: Production diff --git a/internal/limits.yaml b/internal/limits.yaml new file mode 100644 index 000000000..9b20da035 --- /dev/null +++ b/internal/limits.yaml @@ -0,0 +1,5 @@ +limits: + - name: "Cluster size limit" + description: "Limits of the nodes (DBServers & Coordinators) supported in the Cluster mode" + community: "64" + enterprise: "1024" diff --git a/internal/platforms.yaml b/internal/platforms.yaml index 86640864d..b6fa21587 100644 --- a/internal/platforms.yaml +++ b/internal/platforms.yaml @@ -1,18 +1,18 @@ platforms: - name: "Google GKE" versions: - - kubernetesVersion: "1.21-1.25" + - kubernetesVersion: "1.21-1.26" arangoDBVersion: ">= 3.6.0" state: "Production" remarks: "Don't use micro nodes " - name: "Azure AKS" versions: - - kubernetesVersion: "1.21-1.24" + - kubernetesVersion: "1.21-1.26" arangoDBVersion: ">= 3.6.0" state: "Production" - name: "Amazon EKS" versions: - - kubernetesVersion: "1.21-1.24" + - kubernetesVersion: "1.21-1.26" arangoDBVersion: ">= 3.6.0" state: "Production" providerRemarks: "[Amazon EKS](./docs/providers/eks)" @@ -31,7 +31,7 @@ platforms: arangoDBVersion: ">= 3.6.0" state: "Deprecated" remarks: "Support will be dropped in Operator 1.5.0" - - kubernetesVersion: "4.2-4.11" + - kubernetesVersion: "4.2-4.13" arangoDBVersion: ">= 3.6.0" state: "Production" - name: "BareMetal (kubeadm)" @@ -40,16 +40,16 @@ platforms: arangoDBVersion: ">= 3.6.0" state: "Deprecated" remarks: "Support will be dropped in Operator 1.5.0" - - kubernetesVersion: "1.21-1.25" + - kubernetesVersion: "1.21-1.27" arangoDBVersion: ">= 3.6.0" state: "Production" - name: "Minikube" versions: - - kubernetesVersion: "1.21-1.25" + - kubernetesVersion: "1.21-1.27" arangoDBVersion: ">= 3.6.0" state: "Devel Only" - name: "Other" versions: - - kubernetesVersion: "1.21-1.25" + - kubernetesVersion: "1.21-1.27" arangoDBVersion: ">= 3.6.0" state: "Devel Only" diff --git a/internal/readme.go b/internal/readme.go index f751963df..cfc48d5a3 100644 --- a/internal/readme.go +++ b/internal/readme.go @@ -21,15 +21,22 @@ package internal import ( + "fmt" "os" "path" + "sort" + "strings" "gopkg.in/yaml.v3" + "github.com/arangodb/go-driver" + "github.com/arangodb/kube-arangodb/internal/md" "github.com/arangodb/kube-arangodb/pkg/util" ) +const minSupportedArangoDBVersion = ">= 3.8.0" + type PlatformsDoc struct { Platforms Platforms `json:"platforms,omitempty" yaml:"platforms,omitempty"` } @@ -49,52 +56,75 @@ type PlatformVersion struct { ProviderRemarks *string `json:"providerRemarks,omitempty" yaml:"providerRemarks,omitempty"` } +type FeaturesDoc struct { + Features Features `json:"features,omitempty" yaml:"features,omitempty"` +} + +type Features []Feature + +type Feature struct { + Name string `json:"name,omitempty" yaml:"name,omitempty"` + Releases FeatureReleases `json:"releases,omitempty" yaml:"releases,omitempty"` + + FeatureRelease `json:",inline" yaml:",inline"` +} + +type FeatureReleases []FeatureRelease + +type FeatureRelease struct { + Doc *string `json:"doc,omitempty" yaml:"doc,omitempty"` + + OperatorVersion *string `json:"operatorVersion,omitempty" yaml:"operatorVersion,omitempty"` + ArangoDBVersion *string `json:"arangoDBVersion,omitempty" yaml:"arangoDBVersion,omitempty"` + + OperatorEdition *string `json:"operatorEditions,omitempty" yaml:"operatorEditions,omitempty"` + ArangoDBEdition *string `json:"arangoDBEditions,omitempty" yaml:"arangoDBEditions,omitempty"` + + State *string `json:"state,omitempty" yaml:"state,omitempty"` + Flag *string `json:"flag,omitempty" yaml:"flag,omitempty"` + Remarks *string `json:"remarks,omitempty" yaml:"remarks,omitempty"` + + Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` +} + +type LimitsDoc struct { + Limits Limits `json:"limits,omitempty" yaml:"limits,omitempty"` +} + +type Limits []Limit + +type Limit struct { + Name string `json:"name" yaml:"name"` + Description string `json:"description" yaml:"description"` + Community *string `json:"community,omitempty" yaml:"community,omitempty"` + Enterprise *string `json:"enterprise,omitempty" yaml:"enterprise,omitempty"` +} + func GenerateReadme(root string) error { readmeSections := map[string]string{} - { - platform := md.NewColumn("Platform", md.ColumnLeftAlign) - kVersion := md.NewColumn("Kubernetes Version", md.ColumnLeftAlign) - aVersion := md.NewColumn("ArangoDB Version", md.ColumnLeftAlign) - state := md.NewColumn("State", md.ColumnLeftAlign) - remarks := md.NewColumn("Remarks", md.ColumnLeftAlign) - pRemarks := md.NewColumn("Provider Remarks", md.ColumnLeftAlign) - t := md.NewTable( - platform, - kVersion, - aVersion, - state, - remarks, - pRemarks, - ) + if section, err := GenerateReadmePlatforms(root); err != nil { + return err + } else { + readmeSections["kubernetesVersionsTable"] = section + } - var d PlatformsDoc + if section, err := GenerateReadmeFeatures(root, true); err != nil { + return err + } else { + readmeSections["featuresEnterpriseTable"] = section + } - data, err := os.ReadFile(path.Join(root, "internal", "platforms.yaml")) - if err != nil { - return err - } + if section, err := GenerateReadmeFeatures(root, false); err != nil { + return err + } else { + readmeSections["featuresCommunityTable"] = section + } - if err := yaml.Unmarshal(data, &d); err != nil { - return err - } - - for _, p := range d.Platforms { - for _, v := range p.Versions { - if err := t.AddRow(map[md.Column]string{ - platform: p.Name, - kVersion: util.TypeOrDefault[string](v.KubernetesVersion, ""), - aVersion: util.TypeOrDefault[string](v.ArangoDBVersion, ""), - state: util.TypeOrDefault[string](v.State, ""), - remarks: util.TypeOrDefault[string](v.Remarks, ""), - pRemarks: util.TypeOrDefault[string](v.ProviderRemarks, ""), - }); err != nil { - return err - } - } - } - - readmeSections["metricsTable"] = md.WrapWithNewLines(t.Render()) + if section, err := GenerateReadmeLimits(root); err != nil { + return err + } else { + readmeSections["limits"] = section } if err := md.ReplaceSectionsInFile(path.Join(root, "README.md"), readmeSections); err != nil { @@ -103,3 +133,177 @@ func GenerateReadme(root string) error { return nil } + +func GenerateReadmeFeatures(root string, eeOnly bool) (string, error) { + feature := md.NewColumn("Feature", md.ColumnLeftAlign) + introduced := md.NewColumn("Introduced", md.ColumnLeftAlign) + oVersion := md.NewColumn("Operator Version", md.ColumnLeftAlign) + aVersion := md.NewColumn("ArangoDB Version", md.ColumnLeftAlign) + aEdition := md.NewColumn("ArangoDB Edition", md.ColumnLeftAlign) + state := md.NewColumn("State", md.ColumnLeftAlign) + enabled := md.NewColumn("Enabled", md.ColumnLeftAlign) + flag := md.NewColumn("Flag", md.ColumnLeftAlign) + remarks := md.NewColumn("Remarks", md.ColumnLeftAlign) + t := md.NewTable( + feature, + oVersion, + introduced, + aVersion, + aEdition, + state, + enabled, + flag, + remarks, + ) + + var d FeaturesDoc + + data, err := os.ReadFile(path.Join(root, "internal", "features.yaml")) + if err != nil { + return "", err + } + + if err := yaml.Unmarshal(data, &d); err != nil { + return "", err + } + + // Sort list + + sort.Slice(d.Features, func(i, j int) bool { + { + av := util.First(util.LastFromList(d.Features[i].Releases).OperatorVersion, d.Features[i].OperatorVersion) + bv := util.First(util.LastFromList(d.Features[j].Releases).OperatorVersion, d.Features[j].OperatorVersion) + + a := driver.Version(util.TypeOrDefault[string](av, "1.0.0")) + b := driver.Version(util.TypeOrDefault[string](bv, "1.0.0")) + + if c := a.CompareTo(b); c != 0 { + return c > 0 + } + } + + { + a := driver.Version(util.TypeOrDefault[string](d.Features[i].Releases[0].OperatorVersion, "1.0.0")) + b := driver.Version(util.TypeOrDefault[string](d.Features[j].Releases[0].OperatorVersion, "1.0.0")) + + if c := a.CompareTo(b); c != 0 { + return c > 0 + } + } + + return d.Features[i].Name < d.Features[j].Name + }) + + for _, f := range d.Features { + r := f.Releases[len(f.Releases)-1] + + if community := strings.Contains(util.TypeOrDefault(util.First(r.OperatorEdition, f.OperatorEdition), "Community, Enterprise"), "Community"); community == eeOnly { + continue + } + + n := f.Name + + if v := util.First(r.Doc, f.Doc); v != nil { + n = fmt.Sprintf("[%s](%s)", n, *v) + } + + if err := t.AddRow(map[md.Column]string{ + feature: n, + oVersion: util.TypeOrDefault[string](util.First(r.OperatorVersion, f.OperatorVersion), "ANY"), + introduced: util.TypeOrDefault[string](f.Releases[0].OperatorVersion, "ANY"), + aVersion: util.TypeOrDefault[string](util.First(r.ArangoDBVersion, f.ArangoDBVersion), minSupportedArangoDBVersion), + aEdition: util.TypeOrDefault[string](util.First(r.ArangoDBEdition, f.ArangoDBEdition), "Community, Enterprise"), + aEdition: util.TypeOrDefault[string](util.First(r.ArangoDBEdition, f.ArangoDBEdition), "Community, Enterprise"), + state: util.TypeOrDefault[string](util.First(r.State, f.State), "Alpha"), + enabled: util.BoolSwitch[string](util.TypeOrDefault[bool](util.First(r.Enabled, f.Enabled), true), "True", "False"), + flag: util.TypeOrDefault[string](util.First(r.Flag, f.Flag), "N/A"), + remarks: util.TypeOrDefault[string](util.First(r.Remarks, f.Remarks), "N/A"), + }); err != nil { + return "", err + } + } + + return md.WrapWithNewLines(t.Render()), nil +} + +func GenerateReadmeLimits(root string) (string, error) { + limit := md.NewColumn("Limit", md.ColumnLeftAlign) + description := md.NewColumn("Description", md.ColumnLeftAlign) + community := md.NewColumn("Community", md.ColumnLeftAlign) + enterprise := md.NewColumn("Enterprise", md.ColumnLeftAlign) + t := md.NewTable( + limit, + description, + community, + enterprise, + ) + + var d LimitsDoc + + data, err := os.ReadFile(path.Join(root, "internal", "limits.yaml")) + if err != nil { + return "", err + } + + if err := yaml.Unmarshal(data, &d); err != nil { + return "", err + } + + for _, l := range d.Limits { + if err := t.AddRow(map[md.Column]string{ + limit: l.Name, + description: l.Description, + community: util.TypeOrDefault[string](l.Community, "N/A"), + enterprise: util.TypeOrDefault[string](l.Enterprise, "N/A"), + }); err != nil { + return "", err + } + } + + return md.WrapWithNewLines(t.Render()), nil +} + +func GenerateReadmePlatforms(root string) (string, error) { + platform := md.NewColumn("Platform", md.ColumnLeftAlign) + kVersion := md.NewColumn("Kubernetes Version", md.ColumnLeftAlign) + aVersion := md.NewColumn("ArangoDB Version", md.ColumnLeftAlign) + state := md.NewColumn("State", md.ColumnLeftAlign) + remarks := md.NewColumn("Remarks", md.ColumnLeftAlign) + pRemarks := md.NewColumn("Provider Remarks", md.ColumnLeftAlign) + t := md.NewTable( + platform, + kVersion, + aVersion, + state, + remarks, + pRemarks, + ) + + var d PlatformsDoc + + data, err := os.ReadFile(path.Join(root, "internal", "platforms.yaml")) + if err != nil { + return "", err + } + + if err := yaml.Unmarshal(data, &d); err != nil { + return "", err + } + + for _, p := range d.Platforms { + for _, v := range p.Versions { + if err := t.AddRow(map[md.Column]string{ + platform: p.Name, + kVersion: util.TypeOrDefault[string](v.KubernetesVersion, ""), + aVersion: util.TypeOrDefault[string](v.ArangoDBVersion, ""), + state: util.TypeOrDefault[string](v.State, ""), + remarks: util.TypeOrDefault[string](v.Remarks, ""), + pRemarks: util.TypeOrDefault[string](v.ProviderRemarks, ""), + }); err != nil { + return "", err + } + } + } + + return md.WrapWithNewLines(t.Render()), nil +} diff --git a/pkg/util/refs.go b/pkg/util/refs.go index bc4be4fb2..7ab963bd6 100644 --- a/pkg/util/refs.go +++ b/pkg/util/refs.go @@ -46,6 +46,22 @@ func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T { return *input } +// First returns first not nil value +func First[T interface{}](input ...*T) *T { + for _, i := range input { + if i != nil { + return i + } + } + + return nil +} + +// LastFromList returns last element on the list +func LastFromList[T interface{}](in []T) T { + return in[len(in)-1] +} + // BoolSwitch define bool switch for defined types - in case of true t T is returned, in case of false f T func BoolSwitch[T interface{}](s bool, t, f T) T { if s {