Skip to content

Commit

Permalink
update kubernetes client to 6.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Tuček committed Sep 7, 2023
1 parent 2c2ecdd commit 71ea7a3
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import io.fabric8.kubernetes.api.model.Quantity;
import io.fabric8.openshift.api.model.BinaryBuildSource;
import io.fabric8.openshift.api.model.BuildConfig;
import io.fabric8.openshift.api.model.BuildConfigFluent.SpecNested;
import io.fabric8.openshift.api.model.BuildConfigFluent;
import io.fabric8.openshift.api.model.BuildConfigSpecFluent;
import io.fabric8.openshift.api.model.BuildSourceBuilder;
import io.fabric8.openshift.api.model.BuildTriggerPolicy;
import io.fabric8.openshift.api.model.BuildTriggerPolicyBuilder;
import io.fabric8.openshift.api.model.GitBuildSourceBuilder;
import io.fabric8.openshift.api.model.ImageSourceBuilder;
import io.fabric8.openshift.api.model.ImageSourceFluent.FromNested;
import io.fabric8.openshift.api.model.ImageSourceFluent;
import io.fabric8.openshift.api.model.SecretBuildSourceBuilder;

public class BuildConfigBuilder extends AbstractBuilder<BuildConfig, BuildConfigBuilder> implements ResourceLimitBuilder {
Expand Down Expand Up @@ -183,7 +184,7 @@ public BuildConfig build() {

if (imageSource != null) {
final ImageSourceBuilder isb = new ImageSourceBuilder();
FromNested<ImageSourceBuilder> from = isb.withNewFrom()
ImageSourceFluent<ImageSourceBuilder>.FromNested<ImageSourceBuilder> from = isb.withNewFrom()
.withName(imageSource.getName())
.withKind(imageSource.getKind());
if (imageSource.getNamespace() != null) {
Expand All @@ -200,15 +201,16 @@ public BuildConfig build() {
.withMetadata(metadataBuilder().build());

// spec
final SpecNested<io.fabric8.openshift.api.model.BuildConfigBuilder> spec = builder.withNewSpec();
final BuildConfigFluent<io.fabric8.openshift.api.model.BuildConfigBuilder>.SpecNested<io.fabric8.openshift.api.model.BuildConfigBuilder> spec = builder
.withNewSpec();

// limits
final List<ComputingResource> requests = computingResources.values().stream().filter(x -> x.getRequests() != null)
.collect(Collectors.toList());
final List<ComputingResource> limits = computingResources.values().stream().filter(x -> x.getLimits() != null)
.collect(Collectors.toList());
if (!requests.isEmpty() || !limits.isEmpty()) {
io.fabric8.openshift.api.model.BuildConfigSpecFluent.ResourcesNested<SpecNested<io.fabric8.openshift.api.model.BuildConfigBuilder>> resources = spec
BuildConfigSpecFluent<BuildConfigFluent<io.fabric8.openshift.api.model.BuildConfigBuilder>.SpecNested<io.fabric8.openshift.api.model.BuildConfigBuilder>>.ResourcesNested<BuildConfigFluent<io.fabric8.openshift.api.model.BuildConfigBuilder>.SpecNested<io.fabric8.openshift.api.model.BuildConfigBuilder>> resources = spec
.withNewResources();
if (!requests.isEmpty()) {
resources.withRequests(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public ImageStreamBuilder addTag(String tag, String sourceUrl, boolean insecure,
.withName(tag);

if (StringUtils.isNotBlank(sourceUrl)) {
trb.withImportPolicy(new TagImportPolicy(insecure, SCHEDULED));
trb.withImportPolicy(new TagImportPolicy("Legacy", insecure, SCHEDULED));

trb.withNewFrom()
.withKind("DockerImage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public RoleBindingBuilder roleRefNamespace(String roleRefNamespace) {

@Override
public RoleBinding build() {
RoleBindingFluent.SubjectsNested<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder> subject = new io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder()
RoleBindingFluent<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder>.SubjectsNested<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder> subject = new io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder()
.withNewMetadata()
.withName(this.getName())
.endMetadata()
Expand All @@ -105,7 +105,7 @@ public RoleBinding build() {
if (subjectNamespace != null && !subjectNamespace.isEmpty())
subject.withNamespace(subjectNamespace);

RoleBindingFluent.RoleRefNested<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder> roleRef = subject
RoleBindingFluent<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder>.RoleRefNested<io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder> roleRef = subject
.endSubject()
.withNewRoleRef()
.withKind(roleRefKind)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void buildStrategy(BuildStrategyBuilder builder) {
.endFrom();
}
if (StringUtils.isNotBlank(imageStreamNamespace)) {
strategyBuilder.getFrom().setNamespace(imageStreamNamespace);
strategyBuilder.buildFrom().setNamespace(imageStreamNamespace);
}
} else if (StringUtils.isNotBlank(dockerImageUrl)) {
strategyBuilder.withNewFrom()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public Probe build() {
private IntOrString getPort() {
IntOrStringBuilder builder = new IntOrStringBuilder();
if (StringUtils.isNumeric(port)) {
builder.withIntVal(Integer.valueOf(port));
builder.withValue(Integer.valueOf(port));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
} else {
builder.withStrVal(port);
builder.withValue(port);
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ConfigMapVolume(String name, String configMapName, String defaultMode) {

@Override
protected void addVolumeParameters(VolumeBuilder builder) {
VolumeFluent.ConfigMapNested<VolumeBuilder> cfm = builder.withNewConfigMap();
VolumeFluent<VolumeBuilder>.ConfigMapNested<VolumeBuilder> cfm = builder.withNewConfigMap();
cfm.withName(configMapName);
if (defaultMode != null) {
int defaultModeIntVal = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import cz.xtf.builder.builders.route.TransportProtocol;
import io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder;
import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.ContainerFluent.ResourcesNested;
import io.fabric8.kubernetes.api.model.ContainerFluent;
import io.fabric8.kubernetes.api.model.ContainerPortBuilder;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.EnvVarSource;
Expand Down Expand Up @@ -251,7 +251,8 @@ public Container build() {
final List<ComputingResource> limits = computingResources.values().stream().filter(x -> x.getLimits() != null)
.collect(Collectors.toList());
if (!requests.isEmpty() || !limits.isEmpty()) {
ResourcesNested<io.fabric8.kubernetes.api.model.ContainerBuilder> resources = builder.withNewResources();
ContainerFluent<io.fabric8.kubernetes.api.model.ContainerBuilder>.ResourcesNested<io.fabric8.kubernetes.api.model.ContainerBuilder> resources = builder
.withNewResources();
if (!requests.isEmpty()) {
resources.withRequests(
requests.stream().collect(Collectors.toMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String getSecretName() {
@Override
protected void addVolumeParameters(VolumeBuilder builder) {

final VolumeFluent.SecretNested<VolumeBuilder> volumeBuilderSecretNested = builder.withNewSecret()
final VolumeFluent<VolumeBuilder>.SecretNested<VolumeBuilder> volumeBuilderSecretNested = builder.withNewSecret()
.withSecretName(getSecretName());

if (items != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
import cz.xtf.core.http.Https;
import cz.xtf.core.http.HttpsException;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.openshift.api.model.ClusterVersion;
import io.fabric8.openshift.api.model.ClusterVersionList;
import io.fabric8.openshift.client.OpenShiftHandlers;
import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand Down Expand Up @@ -136,9 +131,7 @@ private String detectClusterVersionFromCluster() {
// it is OpenShift 4+
// admin is required for operation
try {
NonNamespaceOperation<ClusterVersion, ClusterVersionList, Resource<ClusterVersion>> op = OpenShiftHandlers
.getOperation(ClusterVersion.class, ClusterVersionList.class, OpenShifts.admin());
openshiftVersion = op.withName("version").get().getStatus().getDesired().getVersion();
openshiftVersion = OpenShifts.admin().getOpenShiftV4Version();
} catch (KubernetesClientException kce) {
log.warn("xtf.openshift.version isn't configured and automatic version detection failed.", kce);
}
Expand Down
Loading

0 comments on commit 71ea7a3

Please sign in to comment.