Skip to content

Commit

Permalink
Merge branch 'main' into fabric8io#5781
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Mar 21, 2024
2 parents 39b557f + 464e32e commit 46e23a9
Show file tree
Hide file tree
Showing 26 changed files with 996 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-chaos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
distribution: "temurin"
cache: maven
- name: Setup Kubectl # Chaos-Mesh setup requires a functional kubectl version for all cluster versiones
uses: azure/setup-kubectl@v3
uses: azure/setup-kubectl@v4
with:
version: ${{ matrix.kubernetes }}
- name: Install Chaos Mesh
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
* Fix #3032: JUnit5 Kubernetes Extension works with Nested tests
* Fix #5759: Don't annotate KubeSchema and ValidationSchema classes
* Fix #5781: Use UTF-8 for basic authentication
* Fix #5508: (crd-generator) Ensure deterministic ordering of CustomResourceDefinitionVersions

#### Improvements
* Fix #5701: Owner reference validity check regarding scope and namespace
* Fix #5353: added KubernetesClientBuilder.editOrNewConfig
* Fix #5357: adding additional Quantity methods
* Fix #5635: refined LeaderElector lifecycle and logging

* Fix #5787: (crd-generator) add support for deprecated versions for generated CRDs

#### Dependency Upgrade

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class CustomResourceInfo {
private final String[] shortNames;
private final boolean storage;
private final boolean served;
private final boolean deprecated;
private final String deprecationWarning;
private final Scope scope;
private final TypeDef definition;
private final String crClassName;
Expand All @@ -54,7 +56,7 @@ public class CustomResourceInfo {
private final String[] labels;

public CustomResourceInfo(String group, String version, String kind, String singular,
String plural, String[] shortNames, boolean storage, boolean served,
String plural, String[] shortNames, boolean storage, boolean served, boolean deprecated, String deprecationWarning,
Scope scope, TypeDef definition, String crClassName,
String specClassName, String statusClassName, String[] annotations, String[] labels) {
this.group = group;
Expand All @@ -65,6 +67,8 @@ public CustomResourceInfo(String group, String version, String kind, String sing
this.shortNames = shortNames;
this.storage = storage;
this.served = served;
this.deprecated = deprecated;
this.deprecationWarning = deprecationWarning;
this.scope = scope;
this.definition = definition;
this.crClassName = crClassName;
Expand All @@ -84,6 +88,14 @@ public boolean served() {
return served;
}

public boolean deprecated() {
return deprecated;
}

public String deprecationWarning() {
return deprecationWarning;
}

public String key() {
return crdName();
}
Expand Down Expand Up @@ -165,8 +177,9 @@ public static CustomResourceInfo fromClass(Class<? extends CustomResource<?, ?>>
}

return new CustomResourceInfo(instance.getGroup(), instance.getVersion(), instance.getKind(),
instance.getSingular(), instance.getPlural(), shortNames, instance.isStorage(), instance.isServed(), scope,
definition,
instance.getSingular(), instance.getPlural(), shortNames, instance.isStorage(), instance.isServed(),
instance.isDeprecated(), instance.getDeprecationWarning(),
scope, definition,
customResource.getCanonicalName(), specAndStatus.getSpecClassName(),
specAndStatus.getStatusClassName(), toStringArray(instance.getMetadata().getAnnotations()),
toStringArray(instance.getMetadata().getLabels()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import io.fabric8.crd.generator.v1.decorator.AddStatusSubresourceDecorator;
import io.fabric8.crd.generator.v1.decorator.AddSubresourcesDecorator;
import io.fabric8.crd.generator.v1.decorator.EnsureSingleStorageVersionDecorator;
import io.fabric8.crd.generator.v1.decorator.SetDeprecatedVersionDecorator;
import io.fabric8.crd.generator.v1.decorator.SetServedVersionDecorator;
import io.fabric8.crd.generator.v1.decorator.SetStorageVersionDecorator;
import io.fabric8.crd.generator.v1.decorator.SortCustomResourceDefinitionVersionDecorator;
import io.fabric8.crd.generator.v1.decorator.SortPrinterColumnsDecorator;
import io.sundr.model.TypeDef;

Expand Down Expand Up @@ -89,7 +91,9 @@ protected void addDecorators(CustomResourceInfo config, TypeDef def, Optional<St

resources.decorate(new SetServedVersionDecorator(name, version, config.served()));
resources.decorate(new SetStorageVersionDecorator(name, version, config.storage()));
resources.decorate(new SetDeprecatedVersionDecorator(name, version, config.deprecated(), config.deprecationWarning()));
resources.decorate(new EnsureSingleStorageVersionDecorator(name));
resources.decorate(new SortCustomResourceDefinitionVersionDecorator(name));
resources.decorate(new SortPrinterColumnsDecorator(name, version));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.v1.decorator;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersionFluent;

public class SetDeprecatedVersionDecorator
extends CustomResourceDefinitionVersionDecorator<CustomResourceDefinitionVersionFluent<?>> {

private final boolean deprecated;
private final String deprecationWarning;

public SetDeprecatedVersionDecorator(String name, String version, boolean deprecated, String deprecationWarning) {
super(name, version);
this.deprecated = deprecated;
this.deprecationWarning = deprecationWarning;
}

@Override
public void andThenVisit(CustomResourceDefinitionVersionFluent<?> version) {
if (deprecated) {
version.withDeprecated(true);
version.withDeprecationWarning(deprecationWarning);
}
}

@Override
public String toString() {
return getClass().getName() + " [name:" + getName() + ", version:" + getVersion()
+ ", deprecated:" + deprecated + ", deprecationWarning:" + deprecationWarning + "]";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.v1.decorator;

import io.fabric8.crd.generator.decorator.Decorator;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionSpecFluent;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion;
import io.fabric8.kubernetes.client.utils.KubernetesVersionPriority;

public class SortCustomResourceDefinitionVersionDecorator
extends CustomResourceDefinitionDecorator<CustomResourceDefinitionSpecFluent<?>> {
public SortCustomResourceDefinitionVersionDecorator(String name) {
super(name);
}

@Override
public void andThenVisit(CustomResourceDefinitionSpecFluent<?> spec, ObjectMeta resourceMeta) {
spec.withVersions(KubernetesVersionPriority.sortByPriority(spec.buildVersions(), CustomResourceDefinitionVersion::getName));
}

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { EnsureSingleStorageVersionDecorator.class };
}

@Override
public String toString() {
return getClass().getName() + " [name:" + getName() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import io.fabric8.crd.generator.v1beta1.decorator.AddSubresourcesDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.EnsureSingleStorageVersionDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.PromoteSingleVersionAttributesDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.SetDeprecatedVersionDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.SetServedVersionDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.SetStorageVersionDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.SortCustomResourceDefinitionVersionDecorator;
import io.fabric8.crd.generator.v1beta1.decorator.SortPrinterColumnsDecorator;
import io.sundr.model.TypeDef;

Expand Down Expand Up @@ -90,7 +92,9 @@ protected void addDecorators(CustomResourceInfo config, TypeDef def,

resources.decorate(new SetServedVersionDecorator(name, version, config.served()));
resources.decorate(new SetStorageVersionDecorator(name, version, config.storage()));
resources.decorate(new SetDeprecatedVersionDecorator(name, version, config.deprecated(), config.deprecationWarning()));
resources.decorate(new EnsureSingleStorageVersionDecorator(name));
resources.decorate(new SortCustomResourceDefinitionVersionDecorator(name));
resources.decorate(new PromoteSingleVersionAttributesDecorator(name));
resources.decorate(new SortPrinterColumnsDecorator(name, version));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.v1beta1.decorator;

import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionVersionFluent;

public class SetDeprecatedVersionDecorator
extends CustomResourceDefinitionVersionDecorator<CustomResourceDefinitionVersionFluent<?>> {

private final boolean deprecated;
private final String deprecationWarning;

public SetDeprecatedVersionDecorator(String name, String version, boolean deprecated, String deprecationWarning) {
super(name, version);
this.deprecated = deprecated;
this.deprecationWarning = deprecationWarning;
}

@Override
public void andThenVisit(CustomResourceDefinitionVersionFluent<?> version) {
if (deprecated) {
version.withDeprecated(true);
version.withDeprecationWarning(deprecationWarning);
}
}

@Override
public String toString() {
return getClass().getName() + " [name:" + getName() + ", version:" + getVersion()
+ ", deprecated:" + deprecated + ", deprecationWarning:" + deprecationWarning + "]";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.v1beta1.decorator;

import io.fabric8.crd.generator.decorator.Decorator;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionSpecFluent;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionVersion;
import io.fabric8.kubernetes.client.utils.KubernetesVersionPriority;

public class SortCustomResourceDefinitionVersionDecorator
extends CustomResourceDefinitionDecorator<CustomResourceDefinitionSpecFluent<?>> {
public SortCustomResourceDefinitionVersionDecorator(String name) {
super(name);
}

@Override
public void andThenVisit(CustomResourceDefinitionSpecFluent<?> spec, ObjectMeta resourceMeta) {
spec.withVersions(KubernetesVersionPriority.sortByPriority(spec.buildVersions(), CustomResourceDefinitionVersion::getName));
}

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { EnsureSingleStorageVersionDecorator.class };
}

@Override
public String toString() {
return getClass().getName() + " [name:" + getName() + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.example.deprecated.v1;

import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;

@Group("sample.fabric8.io")
@Version(value = "v1", storage = false, deprecated = true)
public class DeprecationExample extends CustomResource<DeprecationExampleSpec, Void> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.example.deprecated.v1;

public class DeprecationExampleSpec {
private String v1;

public String getV1() {
return v1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.example.deprecated.v1beta1;

import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;

@Group("sample.fabric8.io")
@Version(value = "v1beta1", storage = false, deprecated = true, deprecationWarning = "sample.fabric8.io/v1beta1 DeprecationExample is deprecated; Migrate to sample.fabric8.io/v2")
public class DeprecationExample extends CustomResource<DeprecationExampleSpec, Void> {
}

0 comments on commit 46e23a9

Please sign in to comment.