Skip to content

Commit

Permalink
Fix fabric8io#2712: Add Support for watching logs in multi-container …
Browse files Browse the repository at this point in the history
…Controllers

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Jun 25, 2021
1 parent 1f5061f commit fc7c0d1
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 93 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* Add DSL support for OpenShift Whereabouts CNI Model `whereabouts.cni.cncf.io` to OpenShiftClient DSL
* Add DSL support for OpenShift Kube Storage Version Migrator resources in OpenShiftClient DSL
* Fix #3228: Add support for Dynamic informers for custom resources in KubernetesClient
* Fix #2712: Add support for watching logs in multi-container Controller resources (Deployments, StatefulSets, ReplicaSet etc)

#### _**Note**_: Breaking changes in the API
##### DSL Changes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
package io.fabric8.kubernetes.client.dsl;

public interface ScalableResource<T> extends Resource<T>,
Scaleable<T> , Loggable<LogWatch> {
Scaleable<T> , Loggable<LogWatch>,
Containerable<String, Loggable<LogWatch>> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* 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.kubernetes.client.dsl.internal;

import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.dsl.Operation;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import java.util.Map;
import java.util.Objects;

public class PodControllerOperationContext extends OperationContext {
protected String containerId;

public PodControllerOperationContext() { }

public PodControllerOperationContext(OkHttpClient client, Config config, String plural, String namespace, String name, String containerId, String apiGroupName, String apiGroupVersion, boolean cascading, Object item, Map<String, String> labels, Map<String, String[]> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Map<String, String[]> fieldsNot, String resourceVersion, boolean reloadingFromServer, long gracePeriodSeconds, DeletionPropagation propagationPolicy, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier, boolean isNamespaceFromGlobalConfig, boolean dryRun) {
super(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading, item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot, resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, isNamespaceFromGlobalConfig, dryRun);
this.containerId = containerId;
}

public String getContainerId() {
return containerId;
}

public PodControllerOperationContext withContainerId(String containerId) {
return new PodControllerOperationContext(client, config, plural, namespace, name, containerId, apiGroupName, apiGroupVersion, cascading, item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot, resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, namespaceFromGlobalConfig, dryRun);
}

public PodControllerOperationContext withOkhttpClient(OkHttpClient client) {
if (this.client == client) {
return this;
}
return new PodControllerOperationContext(client, this.config, this.plural, this.namespace, this.name, this.containerId, this.apiGroupName,
this.apiGroupVersion, this.cascading, this.item, this.labels, this.labelsNot, this.labelsIn, this.labelsNotIn,
this.fields, this.fieldsNot, this.resourceVersion, this.reloadingFromServer, this.gracePeriodSeconds,
this.propagationPolicy, this.watchRetryInitialBackoffMillis, this.watchRetryBackoffMultiplier,
this.namespaceFromGlobalConfig, this.dryRun);
}

public PodControllerOperationContext withConfig(Config config) {
if (this.config == config) {
return this;
}
return new PodControllerOperationContext(this.client, config, this.plural, this.namespace, this.name, this.containerId, this.apiGroupName,
this.apiGroupVersion, this.cascading, this.item, this.labels, this.labelsNot, this.labelsIn, this.labelsNotIn,
this.fields, this.fieldsNot, this.resourceVersion, this.reloadingFromServer, this.gracePeriodSeconds,
this.propagationPolicy, this.watchRetryInitialBackoffMillis, this.watchRetryBackoffMultiplier,
this.namespaceFromGlobalConfig, this.dryRun);
}

public PodControllerOperationContext withNamespace(String namespace) {
if (Objects.equals(this.namespace, namespace)) {
return this;
}
return new PodControllerOperationContext(this.client, this.config, this.plural, namespace, this.name, this.containerId, this.apiGroupName,
this.apiGroupVersion, this.cascading, this.item, this.labels, this.labelsNot, this.labelsIn, this.labelsNotIn,
this.fields, this.fieldsNot, this.resourceVersion, this.reloadingFromServer, this.gracePeriodSeconds,
this.propagationPolicy, this.watchRetryInitialBackoffMillis, this.watchRetryBackoffMultiplier,
this.namespaceFromGlobalConfig, this.dryRun);
}

public PodControllerOperationContext withPropagationPolicy(DeletionPropagation propagationPolicy) {
if (this.propagationPolicy == propagationPolicy) {
return this;
}
return new PodControllerOperationContext(this.client, this.config, this.plural, this.namespace, this.name, this.containerId, this.apiGroupName,
this.apiGroupVersion, this.cascading, this.item, this.labels, this.labelsNot, this.labelsIn, this.labelsNotIn,
this.fields, this.fieldsNot, this.resourceVersion, this.reloadingFromServer, this.gracePeriodSeconds,
propagationPolicy, this.watchRetryInitialBackoffMillis, this.watchRetryBackoffMultiplier,
this.namespaceFromGlobalConfig, this.dryRun);
}
}
Loading

0 comments on commit fc7c0d1

Please sign in to comment.