proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java
LeaderElectorBuilder
validate
class LeaderElectorBuilder { private final KubernetesClient client; private final Executor executor; private LeaderElectionConfig leaderElectionConfig; public LeaderElectorBuilder(KubernetesClient client, Executor executor) { this.client = client; this.executor = executor; } public LeaderElectorB...
Objects.requireNonNull(leaderElectionConfig, "LeaderElectionConfig is required"); Objects.requireNonNull(leaderElectionConfig.getName(), "name is required"); Objects.requireNonNull(leaderElectionConfig.getLeaseDuration(), "leaseDuration is required"); Objects.requireNonNull(leaderElectionConfig.getRene...
203
506
709
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java
ConfigMapLock
toRecord
class ConfigMapLock extends ResourceLock<ConfigMap> { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigMapLock.class); public ConfigMapLock(String configMapNamespace, String configMapName, String identity) { super(configMapNamespace, configMapName, identity); } public ConfigMapLock(Obje...
return Optional.ofNullable(resource.getMetadata().getAnnotations()) .map(annotations -> annotations.get(LEADER_ELECTION_RECORD_ANNOTATION_KEY)) .map(annotation -> { try { return Serialization.unmarshal(annotation, LeaderElectionRecord.class); } catch (KubernetesClien...
259
140
399
<methods>public void <init>(java.lang.String, java.lang.String, java.lang.String) ,public void <init>(ObjectMeta, java.lang.String) ,public synchronized void create(io.fabric8.kubernetes.client.KubernetesClient, io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.LeaderElectionRecord) ,public java.lang.St...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java
LeaderElectionRecord
equals
class LeaderElectionRecord { private final String holderIdentity; private final Duration leaseDuration; @JsonFormat(timezone = "UTC", pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'") private final ZonedDateTime acquireTime; @JsonFormat(timezone = "UTC", pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'") private fina...
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LeaderElectionRecord that = (LeaderElectionRecord) o; return leaderTransitions == that.leaderTransitions && Objects.equals(holderIdentity, that.holderIdentity) && Objects.equals(leaseDurat...
498
138
636
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java
LeaseLock
toRecord
class LeaseLock extends ResourceLock<Lease> { public LeaseLock(String leaseNamespace, String leaseName, String identity) { super(leaseNamespace, leaseName, identity); } public LeaseLock(ObjectMeta meta, String identity) { super(meta, identity); } @Override protected Class<Lease> getKind() { r...
return Optional.ofNullable(resource.getSpec()).map(spec -> new LeaderElectionRecord( spec.getHolderIdentity(), Duration.ofSeconds(spec.getLeaseDurationSeconds()), spec.getAcquireTime(), spec.getRenewTime(), Optional.ofNullable(spec.getLeaseTransitions()).orElse(0))).orElse(n...
315
101
416
<methods>public void <init>(java.lang.String, java.lang.String, java.lang.String) ,public void <init>(ObjectMeta, java.lang.String) ,public synchronized void create(io.fabric8.kubernetes.client.KubernetesClient, io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.LeaderElectionRecord) ,public java.lang.St...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ResourceLock.java
ResourceLock
get
class ResourceLock<T extends HasMetadata> implements Lock { private final ObjectMeta meta; private final String identity; private T resource; public ResourceLock(String namespace, String name, String identity) { this(new ObjectMetaBuilder().withNamespace(namespace).withName(name).build(), identity); } ...
resource = client.resources(getKind()).inNamespace(meta.getNamespace()).withName(meta.getName()).get(); if (resource != null) { return toRecord(resource); } return null;
608
57
665
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java
RunConfigUtil
argsFromConfig
class RunConfigUtil { private static final String DEFAULT_RESTART_POLICY = "Always"; private RunConfigUtil() { } public static ObjectMeta getObjectMetadataFromRunConfig(RunConfig generatorRunConfig) { ObjectMetaBuilder objectMetaBuilder = new ObjectMetaBuilder(); if (generatorRunConfig.getName() != nu...
if (isNullOrEmpty(runConfig.getCommand()) && runConfig.getArgs() != null) { return runConfig.getArgs().toArray(new String[0]); } return new String[0];
818
58
876
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ExtensibleResourceAdapter.java
ExtensibleResourceAdapter
init
class ExtensibleResourceAdapter<T> extends ResourceAdapter<T> implements ExtensibleResource<T> { protected ExtensibleResource<T> resource; protected Client client; public ExtensibleResourceAdapter() { } public abstract ExtensibleResourceAdapter<T> newInstance(); public ExtensibleResourceAdapter<T> init...
super.resource = resource; this.resource = resource; this.client = client; return this;
912
32
944
<methods>public void <init>() ,public void <init>(Resource<T>) ,public T accept(Consumer<T>) ,public T create() ,public T create(T) ,public T createOr(Function<NonDeletingOperation<T>,T>) ,public T createOrReplace() ,public T createOrReplace(T) ,public List<StatusDetails> delete() ,public List<StatusDetails> delete(T) ...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/AbstractBasicBuilder.java
AbstractBasicBuilder
header
class AbstractBasicBuilder<T extends BasicBuilder> implements BasicBuilder { private URI uri; private final Map<String, List<String>> headers = new HashMap<>(); @Override public T uri(URI uri) { this.uri = uri; return (T) this; } @Override public T header(String name, String value) {<FILL_FUNCT...
headers.compute(name, (k, v) -> { if (v == null) { v = new ArrayList<>(); } v.add(value); return v; }); return (T) this;
256
63
319
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/BufferUtil.java
BufferUtil
copy
class BufferUtil { private BufferUtil() { // utils class } /** * Convert a ByteBuffer to a byte array. * * @param buffer The buffer to convert in flush mode. The buffer is not altered. * @return An array of bytes duplicated from the buffer. */ public static byte[] toArray(ByteBuffer buffer)...
if (buffer == null) { return null; } final int position = buffer.position(); ByteBuffer clone = ByteBuffer.allocate(buffer.remaining()); clone.put(buffer); clone.flip(); buffer.position(position); return clone;
523
75
598
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/ByteArrayBodyHandler.java
ByteArrayBodyHandler
onBodyDone
class ByteArrayBodyHandler implements AsyncBody.Consumer<List<ByteBuffer>> { private final List<ByteBuffer> buffers = Collections.synchronizedList(new LinkedList<>()); private final CompletableFuture<byte[]> result = new CompletableFuture<>(); @Override public void consume(List<ByteBuffer> value, AsyncBody as...
if (t != null) { result.completeExceptionally(t); } else { byte[] bytes = null; synchronized (buffers) { bytes = toArray(buffers); } result.complete(bytes); } buffers.clear();
227
76
303
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClientReadableByteChannel.java
HttpClientReadableByteChannel
onResponse
class HttpClientReadableByteChannel implements ReadableByteChannel, AsyncBody.Consumer<List<ByteBuffer>> { private final LinkedList<ByteBuffer> buffers = new LinkedList<>(); private Throwable failed; private boolean closed; private boolean done; private CompletableFuture<AsyncBody> asyncBodyFuture = new Comp...
AsyncBody asyncBody = response.body(); asyncBodyFuture.complete(asyncBody); asyncBody.done().whenComplete(this::onBodyDone); asyncBody.consume(); // pre-fetch the first results doLockedAndSignal(() -> null);
839
70
909
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpLoggingInterceptor.java
DeferredLoggingConsumer
processAsyncBody
class DeferredLoggingConsumer implements AsyncBody.Consumer<List<ByteBuffer>> { private static final long MAX_BODY_SIZE = 2097152L; // 2MiB private final HttpLogger httpLogger; private final HttpRequest originalRequest; private final AsyncBody.Consumer<List<ByteBuffer>> originalConsumer; pri...
asyncBody.done().whenComplete((Void v, Throwable throwable) -> { httpLogger.logStart(); // TODO: we also have access to the response.request, which may be different than originalRequest httpLogger.logRequest(originalRequest); httpLogger.logResponse(response); httpLogger.lo...
518
120
638
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/SendAsyncUtils.java
SendAsyncUtils
inputStream
class SendAsyncUtils { private SendAsyncUtils() { // just utils } static CompletableFuture<HttpResponse<Reader>> reader(HttpRequest request, HttpClient client) { return inputStream(request, client) .thenApply(res -> new HttpResponseAdapter<>(res, new InputStreamReader(res.body(), StandardCharset...
HttpClientReadableByteChannel byteChannel = new HttpClientReadableByteChannel(); CompletableFuture<HttpResponse<AsyncBody>> futureResponse = client.consumeBytes(request, byteChannel); return futureResponse.thenApply(res -> { byteChannel.onResponse(res); return new HttpResponseAdapter<>(res, Cha...
335
94
429
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/StandardHttpClientBuilder.java
StandardHttpClientBuilder
sslContext
class StandardHttpClientBuilder<C extends HttpClient, F extends HttpClient.Factory, T extends StandardHttpClientBuilder<C, F, ?>> implements HttpClient.Builder { protected LinkedHashMap<String, Interceptor> interceptors = new LinkedHashMap<>(); protected Duration connectTimeout; protected SSLContext sslConte...
this.sslContext = SSLUtils.sslContext(keyManagers, trustManagers); this.keyManagers = keyManagers; this.trustManagers = trustManagers; return (T) this;
1,199
56
1,255
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/StandardHttpRequest.java
Builder
build
class Builder extends AbstractBasicBuilder<Builder> implements HttpRequest.Builder { private String method = "GET"; private BodyContent body; private String bodyAsString; private boolean expectContinue; private String contentType; protected Duration timeout; protected boolean forStreaming; ...
return new StandardHttpRequest(getHeaders(), Objects.requireNonNull(getUri()), method, bodyAsString, body, expectContinue, contentType, timeout, forStreaming);
664
47
711
<methods>public void <init>() ,public void <init>(Map<java.lang.String,List<java.lang.String>>) ,public List<java.lang.String> headers(java.lang.String) ,public Map<java.lang.String,List<java.lang.String>> headers() <variables>public static final java.lang.String CONTENT_LENGTH,public static final java.lang.String CONT...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java
Lister
get
class Lister<T> { private final String namespace; private final String indexName; private final Indexer<T> indexer; public Lister(Indexer<T> indexer) { this(indexer, null, Cache.NAMESPACE_INDEX); } public Lister(Indexer<T> indexer, String namespace) { this(indexer, namespace, Cache.NAMESPACE_IND...
String key = name; if (namespace != null && !namespace.isEmpty()) { key = namespace + "/" + name; } return indexer.getByKey(key);
294
51
345
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/ReducedStateItemStore.java
KeyState
restore
class KeyState { final Function<HasMetadata, String> keyFunction; final Function<String, String[]> keyFieldFunction; final List<String[]> keyFields; /** * The key function must decompose a given key into the given fields - in field order * * @param keyFieldFunction to convert a key into...
if (values == null) { return null; } Map<String, Object> raw = new HashMap<>(); applyFields(values, raw, this.fields); String[] keyParts = this.keyState.keyFieldFunction.apply(key); applyFields(keyParts, raw, this.keyState.keyFields); return serialization.convertValue(raw, typeClass)...
904
103
1,007
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java
KubeConfigUtils
getNamedUserIndexFromConfig
class KubeConfigUtils { private KubeConfigUtils() { } public static Config parseConfig(File file) throws IOException { return Serialization.unmarshal(new FileInputStream(file), Config.class); } public static Config parseConfigFromString(String contents) { return Serialization.unmarshal(contents, Con...
for (int i = 0; i < config.getUsers().size(); i++) { if (config.getUsers().get(i).getName().equals(userName)) { return i; } } return -1;
1,043
63
1,106
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java
Asn1Object
validateSequence
class Asn1Object { private final int type; private final byte[] value; private final int tag; public Asn1Object(int tag, byte[] value) { this.tag = tag; this.type = tag & 0x1F; this.value = value; } public byte[] getValue() { return value; } BigInteger getInte...
if (type != 0x10) { throw new IOException("Invalid DER: not a sequence"); } if ((tag & 0x20) != 0x20) { throw new IOException("Invalid DER: can't parse primitive entity"); }
187
73
260
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java
SSLUtils
keyManagers
class SSLUtils { private static final Logger LOG = LoggerFactory.getLogger(SSLUtils.class); private SSLUtils() { //Utility } public static boolean isHttpsAvailable(Config config) { HttpsURLConnection conn = null; try { URL url = new URL(Config.HTTPS_PROTOCOL_PREFIX + config.getMasterUrl());...
KeyManager[] keyManagers = null; if ((Utils.isNotNullOrEmpty(certData) || Utils.isNotNullOrEmpty(certFile)) && (Utils.isNotNullOrEmpty(keyData) || Utils.isNotNullOrEmpty(keyFile))) { KeyStore keyStore = createKeyStore(certData, certFile, keyData, keyFile, algo, passphrase, keyStoreFile, ...
1,564
170
1,734
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/readiness/Readiness.java
ReadinessHolder
isReadinessApplicable
class ReadinessHolder { public static final Readiness INSTANCE = new Readiness(); } public static Readiness getInstance() { return ReadinessHolder.INSTANCE; } /** * Checks if the provided {@link HasMetadata} is marked as ready by the cluster. * * <p> * A "Readiable" resources is a subjecti...
return (item instanceof Deployment || item instanceof io.fabric8.kubernetes.api.model.extensions.Deployment || item instanceof ReplicaSet || item instanceof Pod || item instanceof ReplicationController || item instanceof Endpoints || item instanceof Node || i...
415
78
493
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java
ApiVersionUtil
apiGroup
class ApiVersionUtil { private ApiVersionUtil() { throw new IllegalStateException("Utility class"); } /** * Extracts apiGroupName from apiGroupVersion when in resource for apiGroupName/apiGroupVersion combination * * @param <T> Template argument provided * @param item resource which is being us...
if (item instanceof HasMetadata && Utils.isNotNullOrEmpty(((HasMetadata) item).getApiVersion())) { return trimGroupOrNull(((HasMetadata) item).getApiVersion()); } else if (apiGroup != null && !apiGroup.isEmpty()) { return trimGroup(apiGroup); } return null;
850
85
935
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/AsyncUtils.java
AsyncUtils
retryWithExponentialBackoff
class AsyncUtils { private AsyncUtils() { } /** * Returns the provided {@link CompletableFuture} that will complete exceptionally with a {@link TimeoutException} * if the provided {@link Duration} timeout period is exceeded. * * @param future the future to add a timeout to. * @param timeout the t...
withTimeout(action.get(), timeout).whenComplete((r, t) -> { if (retryIntervalCalculator.shouldRetry() && !result.isDone()) { final long retryInterval = retryIntervalCalculator.nextReconnectInterval(); if (shouldRetry.shouldRetry(r, t, retryInterval)) { if (r != null) { o...
742
227
969
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java
ResourceKey
afterFailure
class ResourceKey { private final String kind; private final String path; private final String group; private final String version; public ResourceKey(String kind, String path, String group, String version) { this.kind = kind; this.path = path; this.group = group; this.versi...
ResourceKey target = findNewTarget(builder, response); if (target == null) { return CompletableFuture.completedFuture(false); } HttpRequest request = response.request(); if (request.bodyString() != null && !request.method().equalsIgnoreCase(PATCH)) { JsonNode object = Serialization.unm...
1,618
270
1,888
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java
CachedSingleThreadScheduler
startExecutor
class CachedSingleThreadScheduler { public static final long DEFAULT_TTL_MILLIS = TimeUnit.SECONDS.toMillis(10); private final long ttlMillis; private ScheduledThreadPoolExecutor executor; public CachedSingleThreadScheduler() { this(DEFAULT_TTL_MILLIS); } public CachedSingleThreadScheduler(long ttlM...
if (executor == null) { // start the executor and add a ttl task executor = new ScheduledThreadPoolExecutor(1, Utils.daemonThreadFactory(this)); executor.setRemoveOnCancelPolicy(true); executor.scheduleWithFixedDelay(this::shutdownCheck, ttlMillis, ttlMillis, TimeUnit.MILLISECONDS); } ...
398
102
500
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ExponentialBackoffIntervalCalculator.java
ExponentialBackoffIntervalCalculator
from
class ExponentialBackoffIntervalCalculator { //we were using the same default in multiple places, so it has been moved here for now private static final int MAX_RETRY_INTERVAL_EXPONENT = 5; public static final int UNLIMITED_RETRIES = -1; private final int initialInterval; // other calculators express this ...
final int requestRetryBackoffInterval = Optional.ofNullable(requestConfig) .map(RequestConfig::getRequestRetryBackoffInterval) .orElse(Config.DEFAULT_REQUEST_RETRY_BACKOFFINTERVAL); final int requestRetryBackoffLimit = Optional.ofNullable(requestConfig) .map(RequestConfig::getRequestRet...
447
141
588
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java
HeaderInterceptor
createApplicableInterceptors
class HeaderInterceptor implements Interceptor { private final Config config; private HeaderInterceptor(Config config) { this.config = config; } @Override public void before(BasicBuilder builder, HttpRequest request, RequestTags tags) { if (config.getCustomHeaders() != null && !config....
Map<String, io.fabric8.kubernetes.client.http.Interceptor> interceptors = new LinkedHashMap<>(); // Header Interceptor interceptors.put(HEADER_INTERCEPTOR, new HeaderInterceptor(config)); // Impersonator Interceptor interceptors.put(ImpersonatorInterceptor.NAME, new ImpersonatorInterceptor(config....
669
293
962
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java
IOHelpers
copy
class IOHelpers { private IOHelpers() { throw new IllegalStateException("Utility class"); } public static String readFully(InputStream in, Charset charset) throws IOException { Reader r = new BufferedReader(new InputStreamReader(in, charset)); return readFully(r); } public static String readFull...
char[] buffer = new char[8192]; int len; for (;;) { len = reader.read(buffer); if (len > 0) { writer.write(buffer, 0, len); } else { writer.flush(); break; } }
437
81
518
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java
ImpersonatorInterceptor
before
class ImpersonatorInterceptor implements Interceptor { public static final String IMPERSONATE_USER = "Impersonate-User"; public static final String NAME = "IMPERSONATOR"; private final RequestConfig requestConfig; public ImpersonatorInterceptor(RequestConfig requestConfig) { this.requestConfig = request...
RequestConfig config = Optional.ofNullable(tags.getTag(RequestConfig.class)).orElse(requestConfig); if (isNotNullOrEmpty(config.getImpersonateUsername())) { builder.header(IMPERSONATE_USER, config.getImpersonateUsername()); String[] impersonateGroups = config.getImpersonateGroups(); if (isN...
129
284
413
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java
InputStreamPumper
asInterruptible
class InputStreamPumper { private static final int DEFAULT_BUFFER_SIZE = 8192; private InputStreamPumper() { } private static final Logger LOGGER = LoggerFactory.getLogger(InputStreamPumper.class); public interface Writable { void write(byte[] b, int off, int len) throws IOException; } /** *...
return new InputStream() { @Override public int read() { throw new UnsupportedOperationException(); } @Override public int read(byte[] b, int off, int len) throws IOException { while (!Thread.currentThread().isInterrupted()) { if (is.available() > 0) { ...
716
204
920
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java
IpAddressMatcher
matches
class IpAddressMatcher { private static final Logger logger = LoggerFactory.getLogger(IpAddressMatcher.class); private final int nMaskBits; private final InetAddress requiredAddress; /** * Takes a specific IP address or a range specified using the IP/Netmask (e.g. * 192.168.1.0/24 or 202.24.0.0/14). ...
InetAddress remoteAddress = parseAddress(address); if (remoteAddress == null || requiredAddress == null) { return false; } if (!this.requiredAddress.getClass().equals(remoteAddress.getClass())) { return false; } if (this.nMaskBits < 0) { return remoteAddress.equals(this.requir...
389
271
660
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java
KubernetesVersion
compareTo
class KubernetesVersion extends Version { public static final VersionFactory<KubernetesVersion> FACTORY = new VersionFactory<KubernetesVersion>() { private final Pattern versionPattern = Pattern.compile("v([0-9]+)((alpha|beta)([0-9]+)?)*"); @Override public KubernetesVersion create(String versi...
if (other == this) { return 0; } if (other instanceof NonKubernetesVersion) { return 1; } if (!(other instanceof KubernetesVersion)) { return 1; } KubernetesVersion otherKube = (KubernetesVersion) other; if (qualifier.isPresent()) { if (!o...
1,084
261
1,345
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java
KubernetesVersionPriority
sortByPriority
class KubernetesVersionPriority { private KubernetesVersionPriority() { } /** * Returns the version with the highest priority for the given list of versions. * * @param versions the versions to pick the version with the highest priority from * @return the version with the highest priority * @see ...
Utils.checkNotNull(versionProvider, "versionProvider function can't be null"); if (resources == null || resources.isEmpty()) { return Collections.emptyList(); } return resources.stream() .sorted(Comparator.comparing(o -> KubernetesVersionFactory.create(versionProvider.apply(o)), Comparat...
438
107
545
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java
PodStatusUtil
getContainerStatus
class PodStatusUtil { private static final String POD_RUNNING = "Running"; private static final String POD_INITIALIZING = "PodInitializing"; private static final String CONTAINER_COMPLETED = "Completed"; private PodStatusUtil() { } /** * Returns {@code true} if the given pod is running. Returns {@code...
if (pod == null || pod.getStatus() == null) { return Collections.emptyList(); } return pod.getStatus().getContainerStatuses();
1,518
47
1,565
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java
ReflectUtils
objectMetadata
class ReflectUtils { private ReflectUtils() { throw new IllegalStateException("Utility class"); } public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException {<FILL_FUNCTION_BODY>} public static String namespace(Object obj) throws ReflectiveOperationException { if (obj == n...
if (obj == null) { return null; } if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessExceptio...
387
116
503
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java
Serialization
yamlMapper
class Serialization { private Serialization() { } /** * Create an instance that mimics the old behavior * - scans the classpath for KubernetesResources, and provides a static mapper / UnmatchedFieldTypeModule * * Future versions will further override the KubernetesDeserializer initialization as * ...
if (YAML_MAPPER == null) { synchronized (Serialization.class) { if (YAML_MAPPER == null) { YAML_MAPPER = new ObjectMapper( new YAMLFactory().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID)); YAML_MAPPER.registerModules(UNMATCHED_FIELD_TYPE_MODULE); } ...
1,848
125
1,973
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java
TokenRefreshInterceptor
before
class TokenRefreshInterceptor implements Interceptor { public static final String AUTHORIZATION = "Authorization"; public static final String NAME = "TOKEN"; protected final Config config; private final Function<Config, CompletableFuture<String>> remoteRefresh; private static final int REFRESH_INTERVAL_MI...
if (useBasicAuth()) { headerBuilder.header(AUTHORIZATION, HttpClientUtils.basicCredentials(config.getUsername(), config.getPassword())); return; } String token = getEffectiveOauthToken(config); if (Utils.isNotNullOrEmpty(token)) { headerBuilder.header(AUTHORIZATION, "Bearer " + toke...
1,160
177
1,337
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java
URLBuilder
addQueryParameter
class URLBuilder { private final StringBuilder url; public URLBuilder(String url) { this.url = new StringBuilder(url); } public URLBuilder(URL url) { this(url.toString()); } public URLBuilder addQueryParameter(String key, String value) {<FILL_FUNCTION_BODY>} public URL build...
if (url.indexOf("?") == -1) { url.append("?"); } else { url.append("&"); } url.append(encodeToUTF(key).replaceAll("[+]", "%20")).append("=").append(encodeToUTF(value).replaceAll("[+]", "%20")); return this;
171
94
265
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CreateOnlyResourceOperation.java
CreateOnlyResourceOperation
create
class CreateOnlyResourceOperation<I, O> extends OperationSupport implements InOutCreateable<I, O> { protected Class<O> type; protected CreateOnlyResourceOperation(OperationContext ctx) { super(ctx); } public Class<O> getType() { return type; } protected O handleCreate(I resource) throws Execution...
try { return handleCreate(item); } catch (ExecutionException | IOException e) { throw KubernetesClientException.launderThrowable(e); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw KubernetesClientException.launderThrowable(ie); }
143
84
227
<methods>public void <init>(io.fabric8.kubernetes.client.Client) ,public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext) ,public static Status createStatus(HttpResponse<?>, io.fabric8.kubernetes.client.utils.KubernetesSerialization) ,public static Status createStatus(int, java.lang.String) ,publ...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/DefaultOperationInfo.java
DefaultOperationInfo
forOperationType
class DefaultOperationInfo implements OperationInfo { private final String kind; private final String operationType; private final String name; private final String namespace; private final String group; private final String plural; private final String version; public DefaultOperationInfo(String kind...
return new DefaultOperationInfo(kind, type, name, namespace, group, plural, version);
337
25
362
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/ExecWatchInputStream.java
ExecWatchInputStream
consume
class ExecWatchInputStream extends InputStream { private static final int BUFFER_SIZE = 1 << 15; private final LinkedList<ByteBuffer> buffers = new LinkedList<>(); private boolean complete; private boolean closed; private Throwable failed; private ByteBuffer currentBuffer; private final Runnable reques...
synchronized (buffers) { if (closed) { // even if closed there may be other streams // so keep pulling request.run(); return; } assert !complete || failed == null; buffers.addAll(value); buffers.notifyAll(); if ((currentBuffer != null ? currentBuf...
888
134
1,022
<methods>public void <init>() ,public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public static java.io.InputStream nullInputStream() ,public abstract int read() throws java.io.IOException,public int read(b...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/LogWatchCallback.java
LogWatchCallback
callAndWait
class LogWatchCallback implements LogWatch, AutoCloseable { private static final Logger LOGGER = LoggerFactory.getLogger(LogWatchCallback.class); private final OutputStream out; private WritableByteChannel outChannel; private volatile InputStream output; private final AtomicBoolean closed = new AtomicBoole...
HttpRequest request = client.newHttpRequestBuilder().url(url).build(); if (out == null) { // we can pass the input stream directly to the consumer client.sendAsync(request, InputStream.class).whenComplete((r, e) -> { if (e != null) { onFailure(e); } if (r != null)...
377
459
836
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/MetricOperationsImpl.java
MetricOperationsImpl
metrics
class MetricOperationsImpl<T, L> extends OperationSupport implements MetricOperation<T, L> { public static final String METRIC_ENDPOINT_URL = "apis/metrics.k8s.io/v1beta1/"; private final Class<L> apiTypeListClass; private final Class<T> apiTypeClass; public MetricOperationsImpl(OperationContext operationConte...
try { return handleMetric(getMetricEndpointUrl(), apiTypeListClass); } catch (IOException exception) { throw KubernetesClientException.launderThrowable(exception); } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); throw KubernetesClientExcepti...
792
93
885
<methods>public void <init>(io.fabric8.kubernetes.client.Client) ,public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext) ,public static Status createStatus(HttpResponse<?>, io.fabric8.kubernetes.client.utils.KubernetesSerialization) ,public static Status createStatus(int, java.lang.String) ,publ...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NodeMetricOperationsImpl.java
NodeMetricOperationsImpl
isResourceNamespaced
class NodeMetricOperationsImpl extends MetricOperationsImpl<NodeMetrics, NodeMetricsList> implements NodeMetricOperation { public NodeMetricOperationsImpl(Client client) { this(HasMetadataOperationsImpl.defaultContext(client)); } public NodeMetricOperationsImpl(OperationContext context) { super(cont...
return false; // workaround until the class metadata is fixed
253
16
269
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<NodeMetrics>, Class<NodeMetricsList>) ,public NodeMetrics metric() ,public NodeMetricsList metrics() ,public NodeMetricsList metrics(Map<java.lang.String,java.lang.Object>) <variables>public static final java.lang.String METRI...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PatchUtils.java
PatchUtils
withoutRuntimeState
class PatchUtils { public enum Format { YAML, JSON } private PatchUtils() { } public static String withoutRuntimeState(Object object, Format format, boolean omitStatus, KubernetesSerialization serialization) { Function<Object, String> mapper = format == Format.JSON ? serialization::asJson...
ObjectNode raw = serialization.convertValue(object, ObjectNode.class); // it makes the diffs more compact to not have empty arrays removeEmptyArrays(raw); Optional.ofNullable(raw.get("metadata")).filter(ObjectNode.class::isInstance).map(ObjectNode.class::cast).ifPresent(m -> { m.remove("creatio...
378
163
541
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PodOperationContext.java
StreamContext
getLogParameters
class StreamContext { private OutputStream outputStream; public StreamContext(OutputStream outputStream) { this.outputStream = outputStream; } public StreamContext() { } } private String containerId; private StreamContext output; private StreamContext error; private StreamContext...
StringBuilder sb = new StringBuilder(); sb.append("log?pretty=").append(prettyOutput); if (containerId != null && !containerId.isEmpty()) { sb.append("&container=").append(containerId); } if (terminatedStatus) { sb.append("&previous=true"); } if (sinceSeconds != null) { s...
772
247
1,019
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PortForwarderWebsocket.java
PortForwarderWebsocket
forward
class PortForwarderWebsocket { private static final Logger LOG = LoggerFactory.getLogger(PortForwarderWebsocket.class); private final HttpClient client; private final Executor executor; private final long connectTimeoutMills; public PortForwarderWebsocket(HttpClient client, Executor executor, long connectT...
try { InetSocketAddress inetSocketAddress = createNewInetSocketAddress(localHost, localPort); final ServerSocketChannel server = ServerSocketChannel.open().bind(inetSocketAddress); final AtomicBoolean alive = new AtomicBoolean(true); final CopyOnWriteArrayList<PortForward> handles = new Co...
681
766
1,447
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PortForwarderWebsocketListener.java
PortForwarderWebsocketListener
onMessage
class PortForwarderWebsocketListener implements WebSocket.Listener { private static final Logger logger = LoggerFactory.getLogger(PortForwarderWebsocketListener.class); private static final String LOG_PREFIX = "FWD"; private static final String PROTOCOL_ERROR = "Protocol error"; private static final int BUFFER...
messagesRead++; if (messagesRead <= 2) { // skip the first two messages, containing the ports used internally webSocket.request(); return; } if (!buffer.hasRemaining()) { KubernetesClientException e = new KubernetesClientException("Received an empty message"); serverThrow...
1,214
538
1,752
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/VersionUsageUtils.java
VersionUsageUtils
log
class VersionUsageUtils { private static final Logger LOG = LoggerFactory.getLogger(VersionUsageUtils.class); private static final ConcurrentHashMap<String, Boolean> UNSTABLE_TYPES = new ConcurrentHashMap<>(); private static final boolean LOG_EACH_USAGE = false; private VersionUsageUtils() { } public s...
if (type == null || version == null) { return; } if (isUnstable(version)) { if (LOG_EACH_USAGE || UNSTABLE_TYPES.putIfAbsent(type + "-" + version, true) == null) { alert(type, version); } }
273
87
360
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java
WatchConnectionManager
start
class WatchConnectionManager<T extends HasMetadata, L extends KubernetesResourceList<T>> extends AbstractWatchManager<T> { private final long connectTimeoutMillis; protected WatcherWebSocketListener<T> listener; private volatile CompletableFuture<WebSocket> websocketFuture; volatile boolean ready; publ...
this.listener = new WatcherWebSocketListener<>(this, state); Builder builder = client.newWebSocketBuilder(); headers.forEach(builder::header); builder.uri(URI.create(url.toString())).connectTimeout(connectTimeoutMillis, TimeUnit.MILLISECONDS); this.websocketFuture = builder.buildAsync(this.listene...
337
391
728
<methods>public void close() ,public synchronized void closeRequest() ,public void setWatchEndCheckMs(int) <variables>private static final int INFO_LOG_CONNECTION_ERRORS,protected BaseOperation<T,?,?> baseOperation,protected final non-sealed io.fabric8.kubernetes.client.http.HttpClient client,private final Map<Class<?>...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchHTTPManager.java
WatchHTTPManager
start
class WatchHTTPManager<T extends HasMetadata, L extends KubernetesResourceList<T>> extends AbstractWatchManager<T> { private CompletableFuture<HttpResponse<AsyncBody>> call; private volatile AsyncBody body; public WatchHTTPManager(final HttpClient client, final BaseOperation<T, L, ?> baseOperation, f...
HttpRequest.Builder builder = client.newHttpRequestBuilder().url(url).forStreaming(); headers.forEach(builder::header); StringBuffer buffer = new StringBuffer(); call = client.consumeBytes(builder.build(), (b, a) -> { for (ByteBuffer content : b) { for (char c : StandardCharsets.UTF_8.dec...
255
344
599
<methods>public void close() ,public synchronized void closeRequest() ,public void setWatchEndCheckMs(int) <variables>private static final int INFO_LOG_CONNECTION_ERRORS,protected BaseOperation<T,?,?> baseOperation,protected final non-sealed io.fabric8.kubernetes.client.http.HttpClient client,private final Map<Class<?>...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatcherWebSocketListener.java
WatcherWebSocketListener
onMessage
class WatcherWebSocketListener<T extends HasMetadata> implements WebSocket.Listener { protected static final Logger logger = LoggerFactory.getLogger(WatcherWebSocketListener.class); protected final WatchRequestState state; protected final AbstractWatchManager<T> manager; protected WatcherWebSocketListener(Abs...
try { manager.onMessage(text, state); } finally { webSocket.request(); }
361
33
394
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetOperationsImpl.java
ReplicaSetOperationsImpl
rollback
class ReplicaSetOperationsImpl extends RollableScalableResourceOperation<ReplicaSet, ReplicaSetList, RollableScalableResource<ReplicaSet>> implements TimeoutImageEditReplacePatchable<ReplicaSet> { public ReplicaSetOperationsImpl(Client client) { this(new PodOperationContext(), HasMetadataOperationsImpl.d...
throw new KubernetesClientException("rollback not supported in case of ReplicaSets");
1,194
25
1,219
<methods>public ReplicaSet edit(UnaryOperator<ReplicaSet>) ,public java.lang.String getLog() ,public io.fabric8.kubernetes.client.dsl.Loggable inContainer(java.lang.String) ,public abstract RollableScalableResourceOperation<ReplicaSet,ReplicaSetList,RollableScalableResource<ReplicaSet>> newInstance(io.fabric8.kubernete...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetRollingUpdater.java
ReplicaSetRollingUpdater
updateDeploymentKey
class ReplicaSetRollingUpdater extends RollingUpdater<ReplicaSet, ReplicaSetList> { ReplicaSetRollingUpdater(Client client, String namespace, long rollingTimeoutMillis, long loggingIntervalMillis) { super(client, namespace, rollingTimeoutMillis, loggingIntervalMillis); } @Override protected ReplicaSet cre...
return resources().inNamespace(namespace).withName(name).edit(old -> new ReplicaSetBuilder(old).editSpec() .editSelector().addToMatchLabels(DEPLOYMENT_KEY, hash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, hash).endMetadata().endTemplate() .endSpec() .bu...
595
100
695
<methods>public static T pause(RollableScalableResourceOperation<T,?,?>) ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutPause() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutRestart() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRo...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollableScalableResourceOperation.java
RollableScalableResourceOperation
undo
class RollableScalableResourceOperation<T extends HasMetadata, L extends KubernetesResourceList<T>, R extends Resource<T>> extends HasMetadataOperation<T, L, R> implements RollableScalableResource<T>, TimeoutImageEditReplacePatchable<T> { protected final PodOperationContext rollingOperationContext; protected ...
throw new KubernetesClientException(context.getPlural() + " undo is not supported");
1,243
27
1,270
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<T>, Class<L>) ,public T accept(Consumer<T>) ,public T edit(UnaryOperator<T>) ,public transient T edit(Visitor[]) ,public T editStatus(UnaryOperator<T>) ,public HasMetadataOperation<T,L,R> newInstance(io.fabric8.kubernetes.clie...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/StatefulSetOperationsImpl.java
StatefulSetOperationsImpl
undo
class StatefulSetOperationsImpl extends RollableScalableResourceOperation<StatefulSet, StatefulSetList, RollableScalableResource<StatefulSet>> implements TimeoutImageEditReplacePatchable<StatefulSet> { public StatefulSetOperationsImpl(Client client) { this(new PodOperationContext(), HasMetadataOperationsI...
List<ControllerRevision> controllerRevisions = getControllerRevisionListForStatefulSet(get()).getItems(); if (controllerRevisions.size() < 2) { throw new IllegalStateException("No revision to rollback to!"); } // Sort list of replicaSets based on revision annotation controllerRevisions.sort(...
1,336
280
1,616
<methods>public StatefulSet edit(UnaryOperator<StatefulSet>) ,public java.lang.String getLog() ,public io.fabric8.kubernetes.client.dsl.Loggable inContainer(java.lang.String) ,public abstract RollableScalableResourceOperation<StatefulSet,StatefulSetList,RollableScalableResource<StatefulSet>> newInstance(io.fabric8.kube...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/batch/v1/JobOperationsImpl.java
JobOperationsImpl
waitUntilJobIsScaled
class JobOperationsImpl extends HasMetadataOperation<Job, JobList, ScalableResource<Job>> implements ScalableResource<Job> { static final transient Logger LOG = LoggerFactory.getLogger(JobOperationsImpl.class); private final PodOperationContext podControllerOperationContext; public JobOperationsImpl(Client ...
final AtomicReference<Job> atomicJob = new AtomicReference<>(); waitUntilCondition(job -> { atomicJob.set(job); Integer activeJobs = job.getStatus().getActive(); if (activeJobs == null) { activeJobs = 0; } if (Objects.equals(job.getSpec().getParallelism(), activeJobs)) { ...
1,468
182
1,650
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<Job>, Class<JobList>) ,public Job accept(Consumer<Job>) ,public Job edit(UnaryOperator<Job>) ,public transient Job edit(Visitor[]) ,public Job editStatus(UnaryOperator<Job>) ,public HasMetadataOperation<Job,JobList,ScalableRes...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ReplicationControllerOperationsImpl.java
ReplicationControllerOperationsImpl
getReplicationControllerPodLabels
class ReplicationControllerOperationsImpl extends RollableScalableResourceOperation<ReplicationController, ReplicationControllerList, RollableScalableResource<ReplicationController>> implements TimeoutImageEditReplacePatchable<ReplicationController> { public ReplicationControllerOperationsImpl(Client client)...
Map<String, String> labels = new HashMap<>(); if (replicationController != null && replicationController.getSpec() != null && replicationController.getSpec().getSelector() != null) { labels.putAll(replicationController.getSpec().getSelector()); } return labels;
1,120
80
1,200
<methods>public ReplicationController edit(UnaryOperator<ReplicationController>) ,public java.lang.String getLog() ,public io.fabric8.kubernetes.client.dsl.Loggable inContainer(java.lang.String) ,public abstract RollableScalableResourceOperation<ReplicationController,ReplicationControllerList,RollableScalableResource<R...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ReplicationControllerRollingUpdater.java
ReplicationControllerRollingUpdater
createClone
class ReplicationControllerRollingUpdater extends RollingUpdater<ReplicationController, ReplicationControllerList> { ReplicationControllerRollingUpdater(Client client, String namespace, long rollingTimeoutMillis, long loggingIntervalMillis) { super(client, namespace, rollingTimeoutMillis, loggingIntervalMillis);...
return new ReplicationControllerBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0).addToSelector(DEPLOYMENT_KEY, newDeploymentHash) .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, ...
608
121
729
<methods>public static T pause(RollableScalableResourceOperation<T,?,?>) ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutPause() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutRestart() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRo...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceAccountOperationsImpl.java
ServiceAccountOperationsImpl
handleTokenRequest
class ServiceAccountOperationsImpl extends HasMetadataOperation<ServiceAccount, ServiceAccountList, ServiceAccountResource> implements ServiceAccountResource { public ServiceAccountOperationsImpl(Client client) { this(HasMetadataOperationsImpl.defaultContext(client)); } private ServiceAccountOperationsIm...
try { URL requestUrl = new URL(URLUtils.join(getResourceUrl().toString(), "token")); HttpRequest.Builder requestBuilder = httpClient.newHttpRequestBuilder() .post(JSON, getKubernetesSerialization().asJson(tokenRequest)).url(requestUrl); return handleResponse(requestBuilder, TokenReques...
204
123
327
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<ServiceAccount>, Class<ServiceAccountList>) ,public ServiceAccount accept(Consumer<ServiceAccount>) ,public ServiceAccount edit(UnaryOperator<ServiceAccount>) ,public transient ServiceAccount edit(Visitor[]) ,public ServiceAcc...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceOperationsImpl.java
ServiceOperationsImpl
getUrlHelper
class ServiceOperationsImpl extends HasMetadataOperation<Service, ServiceList, ServiceResource<Service>> implements ServiceResource<Service> { public static final String EXTERNAL_NAME = "ExternalName"; public ServiceOperationsImpl(Client client) { this(HasMetadataOperationsImpl.defaultContext(client)); ...
List<ServiceToURLProvider> servicesList = getServiceToURLProviders(Thread.currentThread().getContextClassLoader()); if (servicesList.isEmpty()) { servicesList = getServiceToURLProviders(getClass().getClassLoader()); } // Sort all loaded implementations according to priority Collections.sort(...
1,326
189
1,515
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<Service>, Class<ServiceList>) ,public Service accept(Consumer<Service>) ,public Service edit(UnaryOperator<Service>) ,public transient Service edit(Visitor[]) ,public Service editStatus(UnaryOperator<Service>) ,public HasMetad...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/LegacyRollableScalableResourceOperation.java
LegacyRollableScalableResourceOperation
scale
class LegacyRollableScalableResourceOperation<T extends HasMetadata, L extends KubernetesResourceList<T>, R extends Resource<T>> extends RollableScalableResourceOperation<T, L, R> { protected LegacyRollableScalableResourceOperation(PodOperationContext context, OperationContext superContext, Class<T> type, ...
// handles the conversion back in forth between v1beta1.scale and v1.scale // the sticking point is mostly the conversion of the selector from a map to a single string GenericKubernetesResource scale = operation.handleScale( Optional.ofNullable(scaleParam) .map(s -> operation.getKuberne...
178
357
535
<methods>public T edit(UnaryOperator<T>) ,public java.lang.String getLog() ,public io.fabric8.kubernetes.client.dsl.Loggable inContainer(java.lang.String) ,public abstract RollableScalableResourceOperation<T,L,R> newInstance(io.fabric8.kubernetes.client.dsl.internal.PodOperationContext, io.fabric8.kubernetes.client.dsl...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/ReplicaSetOperationsImpl.java
ReplicaSetOperationsImpl
rollback
class ReplicaSetOperationsImpl extends LegacyRollableScalableResourceOperation<ReplicaSet, ReplicaSetList, RollableScalableResource<ReplicaSet>> implements TimeoutImageEditReplacePatchable<ReplicaSet> { public ReplicaSetOperationsImpl(Client client) { this(new PodOperationContext(), HasMetadataOperations...
throw new KubernetesClientException("rollback not supported in case of ReplicaSets");
1,249
25
1,274
<methods>public Scale scale(Scale) ,public static Scale scale(Scale, HasMetadataOperation<?,?,?>) <variables>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/ReplicaSetRollingUpdater.java
ReplicaSetRollingUpdater
createClone
class ReplicaSetRollingUpdater extends RollingUpdater<ReplicaSet, ReplicaSetList> { ReplicaSetRollingUpdater(Client client, String namespace, long rollingTimeoutMillis, long loggingIntervalMillis) { super(client, namespace, rollingTimeoutMillis, loggingIntervalMillis); } @Override protected ReplicaSet cre...
return new ReplicaSetBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0) .editSelector().addToMatchLabels(DEPLOYMENT_KEY, newDeploymentHash).endSelector() .editTemplate().editMetadata(...
567
132
699
<methods>public static T pause(RollableScalableResourceOperation<T,?,?>) ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutPause() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRolloutRestart() ,public static Map<java.lang.String,java.lang.Object> requestPayLoadForRo...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUpload.java
PodUpload
upload
class PodUpload { private static final Logger LOG = LoggerFactory.getLogger(PodUpload.class); private static final String TAR_PATH_DELIMITER = "/"; private PodUpload() { } public static boolean upload(PodOperationsImpl operation, Path pathToUpload) throws IOException { final File toUpload = pat...
String command = createExecCommandForUpload(file); CompletableFuture<Integer> exitFuture; int uploadRequestTimeout = operation.getRequestConfig().getUploadRequestTimeout(); long uploadRequestTimeoutEnd = uploadRequestTimeout < 0 ? Long.MAX_VALUE : uploadRequestTimeout + System.currentTimeMil...
1,264
614
1,878
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/Adapters.java
Adapters
registerClient
class Adapters { private final Set<ClassLoader> classLoaders = Collections.newSetFromMap(new ConcurrentHashMap<>()); private final Map<Class<?>, ExtensionAdapter<?>> extensionAdapters = new ConcurrentHashMap<>(); private final Handlers handlers; public Adapters(Handlers handlers) { this.handlers = handler...
if (!type.isAssignableFrom(target.getClass())) { throw new IllegalArgumentException("The adapter should implement the type"); } if (target.getClient() != null) { throw new IllegalArgumentException("The client adapter should already be initialized"); } ExtensionAdapter<C> adapter = new E...
605
231
836
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/Handlers.java
Handlers
get
class Handlers { private final Map<Class<?>, ResourceHandler<?, ?>> resourceHandlers = new ConcurrentHashMap<>(); private final Map<List<String>, ResourceDefinitionContext> genericDefinitions = new ConcurrentHashMap<>(); public <T extends HasMetadata, L extends KubernetesResourceList<T>, R extends Resource<T>> ...
if (type.equals(GenericKubernetesResource.class)) { return null; } return (ResourceHandler<T, V>) resourceHandlers.computeIfAbsent(type, k -> new ResourceHandlerImpl<>(type, null));
1,269
64
1,333
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/ResourceHandlerImpl.java
ResourceHandlerImpl
edit
class ResourceHandlerImpl<T extends HasMetadata, V extends VisitableBuilder<T, V>> implements ResourceHandler<T, V> { private final ResourceDefinitionContext context; private final Class<T> type; private final Class<V> builderClass; private final Class<? extends KubernetesResourceList<T>> defaultListClass; p...
if (this.builderClass == null) { throw new KubernetesClientException(String.format("Cannot edit %s with visitors, no builder was found", type.getName())); } try { return this.builderClass.getDeclaredConstructor(item.getClass()).newInstance(item); } catch (InstantiationException | IllegalAcc...
569
127
696
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/URLFromClusterIPImpl.java
URLFromClusterIPImpl
getURL
class URLFromClusterIPImpl implements ServiceToURLProvider { @Override public int getPriority() { return ServiceToUrlImplPriority.FIFTH.getValue(); } @Override public String getURL(Service service, String portName, String namespace, KubernetesClient client) {<FILL_FUNCTION_BODY>} }
ServicePort port = URLFromServiceUtil.getServicePortByName(service, portName); if (port != null && service.getSpec().getType().equals("ClusterIP")) { return port.getProtocol().toLowerCase() + "://" + service.getSpec().getClusterIP() + ":" + port.getPort(); } return null;
86
91
177
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/URLFromEnvVarsImpl.java
URLFromEnvVarsImpl
getURL
class URLFromEnvVarsImpl implements ServiceToURLProvider { public static final Logger logger = LoggerFactory.getLogger(URLFromEnvVarsImpl.class); public static final String ANNOTATION_EXPOSE_URL = "fabric8.io/exposeUrl"; @Override public String getURL(Service service, String portName, String namespace, Kubern...
String serviceHost = URLFromServiceUtil.resolveHostFromEnvVarOrSystemProperty(service.getMetadata().getName()); String servicePort = URLFromServiceUtil.resolvePortFromEnvVarOrSystemProperty(service.getMetadata().getName(), ""); String serviceProtocol = URLFromServiceUtil .resolveProtocolFromEnvVarO...
142
204
346
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/URLFromIngressImpl.java
URLFromIngressImpl
getURL
class URLFromIngressImpl implements ServiceToURLProvider { @Override public String getURL(Service service, String portName, String namespace, KubernetesClient client) {<FILL_FUNCTION_BODY>} @Override public int getPriority() { return ServiceToUrlImplPriority.FIRST.getValue(); } }
ServicePort port = URLFromServiceUtil.getServicePortByName(service, portName); String serviceName = service.getMetadata().getName(); if (port == null) { throw new RuntimeException("Couldn't find port: " + portName + " for service " + service.getMetadata().getName()); } if (client.supports(io...
86
353
439
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/URLFromNodePortImpl.java
URLFromNodePortImpl
getURL
class URLFromNodePortImpl implements ServiceToURLProvider { public static final Logger logger = LoggerFactory.getLogger(URLFromNodePortImpl.class); public String getURL(Service service, String portName, String namespace, KubernetesClient client) {<FILL_FUNCTION_BODY>} private NodePortUrlComponents getUrlCompone...
ServicePort port = URLFromServiceUtil.getServicePortByName(service, portName); String serviceProto = port.getProtocol(); NodePortUrlComponents urlComponents = null; Integer nodePort = port.getNodePort(); if (nodePort != null) { try { NodeList nodeList = client.nodes().list(); ...
333
261
594
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/V1CertificatesAPIGroupClient.java
V1CertificatesAPIGroupClient
certificateSigningRequests
class V1CertificatesAPIGroupClient extends ClientAdapter<V1CertificatesAPIGroupClient> implements V1CertificatesAPIGroupDSL { @Override public NonNamespaceOperation<CertificateSigningRequest, CertificateSigningRequestList, CertificateSigningRequestResource<CertificateSigningRequest>> certificateSigningRequests...
// we need the cast to satisfy java 8 return (NonNamespaceOperation<CertificateSigningRequest, CertificateSigningRequestList, CertificateSigningRequestResource<CertificateSigningRequest>>) resources( CertificateSigningRequest.class, CertificateSigningRequestList.class, CertificateSigningRequest...
132
82
214
<methods>public non-sealed void <init>() ,public A adapt(Class<A>) ,public void close() ,public APIGroup getApiGroup(java.lang.String) ,public APIGroupList getApiGroups() ,public APIResourceList getApiResources(java.lang.String) ,public java.lang.String getApiVersion() ,public io.fabric8.kubernetes.client.Client getCli...
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/SharedInformerFactoryImpl.java
SharedInformerFactoryImpl
sharedIndexInformerFor
class SharedInformerFactoryImpl implements SharedInformerFactory { private static final Logger log = LoggerFactory.getLogger(SharedInformerFactoryImpl.class); private final List<SharedIndexInformer<?>> informers = new ArrayList<>(); private final ConcurrentLinkedQueue<SharedInformerEventListener> eventListeners...
MixedOperation<T, KubernetesResourceList<T>, Resource<T>> resources = client.resources(apiTypeClass); Informable<T> informable = null; if (namespace != null) { NonNamespaceOperation<T, KubernetesResourceList<T>, Resource<T>> nonNamespaceOp = resources.inNamespace(namespace); informable = nonN...
703
217
920
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorStore.java
ProcessorStore
update
class ProcessorStore<T extends HasMetadata> implements SyncableStore<T> { private CacheImpl<T> cache; private SharedProcessor<T> processor; private AtomicBoolean synced = new AtomicBoolean(); private List<String> deferredAdd = new ArrayList<>(); public ProcessorStore(CacheImpl<T> cache, SharedProcessor<T> p...
Notification<T> notification = updateInternal(obj); if (notification != null) { this.processor.distribute(notification, false); }
909
45
954
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessor.java
SharedProcessor
shouldResync
class SharedProcessor<T> { private static final Logger log = LoggerFactory.getLogger(SharedProcessor.class); private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final List<ProcessorListener<T>> listeners = new ArrayList<>(); private final List<ProcessorListener<T>> syncingListeners = new ...
lock.writeLock().lock(); boolean resyncNeeded = false; try { this.syncingListeners.clear(); ZonedDateTime now = ZonedDateTime.now(); for (ProcessorListener<T> listener : this.listeners) { if (listener.shouldResync(now)) { resyncNeeded = true; this.syncingListe...
963
148
1,111
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/internal/CreateOrReplaceHelper.java
CreateOrReplaceHelper
createOrReplace
class CreateOrReplaceHelper<T extends HasMetadata> { public static final int CREATE_OR_REPLACE_RETRIES = 3; private final UnaryOperator<T> createTask; private final UnaryOperator<T> replaceTask; private final UnaryOperator<T> waitTask; private final UnaryOperator<T> reloadTask; private final KubernetesSeria...
String resourceVersion = KubernetesResourceUtil.getResourceVersion(item); final CompletableFuture<T> future = new CompletableFuture<>(); int nTries = 0; item = serialization.clone(item); while (!future.isDone() && nTries < CREATE_OR_REPLACE_RETRIES) { try { // Create Kubernete...
310
256
566
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/internal/OptionalDependencyWrapper.java
OptionalDependencyWrapper
wrapRunWithOptionalDependency
class OptionalDependencyWrapper { private OptionalDependencyWrapper() { } /** * Runs the provided {@link Supplier} implementation and catches any {@link NoClassDefFoundError} * * @param supplier implementation to safely run * @param message to display for caught exceptions (e.g. "Base64InputStream c...
try { return supplier.get(); } catch (NoClassDefFoundError ex) { throw new KubernetesClientException(String.format( "%s, an optional dependency. To use this functionality you must explicitly add this dependency to the classpath.", message), ex); }
154
75
229
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/internal/PodOperationUtil.java
PodOperationUtil
waitUntilReadyOrTerminal
class PodOperationUtil { private static final Logger LOG = LoggerFactory.getLogger(PodOperationUtil.class); private PodOperationUtil() { } /** * Gets PodOperations for Pods specific to a controller * * @param podOperations {@link PodOperationsImpl} generic PodOperations class without any pod configur...
AtomicReference<Pod> podRef = new AtomicReference<>(); try { // Wait for Pod to become ready or succeeded podOperation.waitUntilCondition(p -> { podRef.set(p); return isReadyOrTerminal(p); }, logWaitTimeoutMs, TimeUnit.MILLISECONDS); } catch (Kubernetes...
1,035
169
1,204
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/internal/SerialExecutor.java
SerialExecutor
execute
class SerialExecutor implements Executor { final Queue<Runnable> tasks = new LinkedBlockingDeque<>(); final Executor executor; Runnable active; private volatile boolean shutdown; private Thread thread; private final Object threadLock = new Object(); public SerialExecutor(Executor executor) { this.exe...
if (shutdown) { throw new RejectedExecutionException(); } tasks.offer(() -> { try { if (shutdown) { return; } synchronized (threadLock) { thread = Thread.currentThread(); } r.run(); } catch (Throwable t) { thread.getUncau...
304
167
471
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/AttachExample.java
AttachExample
main
class AttachExample { public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} private static ExecWatch attach(KubernetesClient client, String namespace, String podName, CompletableFuture<Void> sessionFuture) { return client.pods().inNamespace(namespace).withName(podName) ...
if (args.length < 1) { System.out.println("Usage: podName [namespace]"); return; } String podName = args[0]; String namespace = "default"; if (args.length > 1) { namespace = args[1]; } CompletableFuture<Void> sessionFuture = new CompletableFuture<>(); try ( ...
210
279
489
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/BindingExample.java
BindingExample
main
class BindingExample { @SuppressWarnings("java:S106") public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
final String podName = "binding-example-" + generateId(); try (final KubernetesClient client = new KubernetesClientBuilder().build()) { final String namespace; if (client.getConfiguration().getNamespace() != null) { namespace = client.getConfiguration().getNamespace(); } else if (clie...
49
444
493
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java
CRDExample
main
class CRDExample { private static final Logger logger = LoggerFactory.getLogger(CRDExample.class); private static final boolean LOG_ROOT_PATHS = false; /** * Example of Cluster and Namespaced scoped K8S Custom Resources. * To test Cluster scoped resource use "--cluster" as first argument. * To test Na...
boolean resourceNamespaced = true; String namespace = null; if (args.length > 0) { if ("--cluster".equals(args[0])) { resourceNamespaced = false; } else { namespace = args[0]; } } try (final KubernetesClient client = new KubernetesClientBuilder().build()) { i...
159
1,407
1,566
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDLoadExample.java
CRDLoadExample
main
class CRDLoadExample { private static final Logger logger = LoggerFactory.getLogger(CRDLoadExample.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
try (final KubernetesClient client = new KubernetesClientBuilder().build()) { // List all Custom resources. logger.info("Listing all current Custom Resource Definitions :"); CustomResourceDefinitionList crdList = client.apiextensions().v1().customResourceDefinitions().list(); crdList.getIte...
58
270
328
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ConfigMapExample.java
ConfigMapExample
main
class ConfigMapExample { private static final Logger logger = LoggerFactory.getLogger(ConfigMapExample.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
Config config = new ConfigBuilder().build(); try (KubernetesClient client = new KubernetesClientBuilder().withConfig(config).build()) { String namespace = null; if (args.length > 0) { namespace = args[0]; } if (namespace == null) { namespace = client.getNamespace(); ...
55
246
301
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CreatePod.java
CreatePod
main
class CreatePod { private static final Logger logger = LoggerFactory.getLogger(CreatePod.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
if (args.length == 0) { logger.warn("Usage: podJsonFileName <token> <namespace>"); return; } String fileName = args[0]; String namespace = null; if (args.length > 2) { namespace = args[2]; } File file = new File(fileName); if (!file.exists() || !file.isFile()) { ...
55
432
487
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CredentialsExample.java
CredentialsExample
main
class CredentialsExample { private static final Logger logger = LoggerFactory.getLogger(CredentialsExample.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
final ConfigBuilder configBuilder = new ConfigBuilder(); if (args.length > 0) { configBuilder.withMasterUrl(args[0]); } Config config = configBuilder .withTrustCerts(true) .withUsername("developer") .withPassword("developer") .withNamespace("myproject") .bu...
57
219
276
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CronJobExample.java
CronJobExample
main
class CronJobExample { private static final Logger logger = LoggerFactory.getLogger(CronJobExample.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} private static void log(String action, Object obj) { logger.info("{}: {}", action, obj); } private static void log(String action) { ...
String master = "https://localhost:8443/"; if (args.length == 1) { master = args[0]; } log("Using master with url ", master); Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new KubernetesClientBuilder().withConfig(config).build()) ...
112
731
843
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceInformerExample.java
CustomResourceInformerExample
main
class CustomResourceInformerExample { private static final Logger logger = LoggerFactory.getLogger(CustomResourceInformerExample.class); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
try (KubernetesClient client = new KubernetesClientBuilder().build()) { SharedInformerFactory sharedInformerFactory = client.informers(); SharedIndexInformer<Dummy> podInformer = sharedInformerFactory.sharedIndexInformerFor(Dummy.class, 60 * 1000L); logger.info("Informer factory initialized."); ...
59
714
773
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java
CustomResourceV1Example
main
class CustomResourceV1Example { @SuppressWarnings("java:S106") public static void main(String... args) {<FILL_FUNCTION_BODY>} @Group("example.com") @Version("v1") public static final class Show extends CustomResource<ShowSpec, Void> implements Namespaced { @SuppressWarnings("unused") public Show() ...
try (KubernetesClient kc = new KubernetesClientBuilder().build()) { // @formatter:off final CustomResourceDefinition crd = CustomResourceDefinitionContext.v1CRDFromCustomResourceType(Show.class) .editSpec().editVersion(0) .withNewSchema().withNewOpenAPIV3Schema() .withTitl...
389
502
891
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/DeleteExamples.java
DeleteExamples
main
class DeleteExamples { private static final Logger logger = LoggerFactory.getLogger(DeleteExamples.class); private static final String NAMESPACE = "this-is-a-test"; public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
try (KubernetesClient client = new KubernetesClientBuilder().build()) { try { logger.info("Create namespace: {}", client.namespaces() .resource(new NamespaceBuilder().withNewMetadata().withName(NAMESPACE).endMetadata().build()) .create()); logger.info("Deleted namespac...
78
219
297
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/DeploymentExamples.java
DeploymentExamples
main
class DeploymentExamples { private static final Logger logger = LoggerFactory.getLogger(DeploymentExamples.class); private static final String NAMESPACE = "this-is-a-test"; public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
try (KubernetesClient client = new KubernetesClientBuilder().build()) { // Create a namespace for all our stuff Namespace ns = new NamespaceBuilder().withNewMetadata().withName(NAMESPACE).addToLabels("this", "rocks").endMetadata() .build(); logger.info("Created namespace: {}", client.na...
79
546
625
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/DynamicSharedIndexInformerExample.java
DynamicSharedIndexInformerExample
main
class DynamicSharedIndexInformerExample { private static final Logger logger = LoggerFactory.getLogger(DynamicSharedIndexInformerExample.class.getSimpleName()); public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
ResourceDefinitionContext context = new ResourceDefinitionContext.Builder() .withGroup("demo.fabric8.io") .withVersion("v1") .withPlural("dummies") .withKind("Dummy") .withNamespaced(true) .build(); try (KubernetesClient client = new KubernetesClientBuilder().bu...
66
430
496
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/EndpointsExample.java
EndpointsExample
main
class EndpointsExample { private static final Logger logger = LoggerFactory.getLogger(EndpointsExample.class); private static final String NAMESPACE = "endpoints-example"; public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
try (KubernetesClient client = new KubernetesClientBuilder().build()) { Namespace ns = new NamespaceBuilder().withNewMetadata().withName(NAMESPACE).addToLabels("this", "rocks").endMetadata() .build(); logger.info("Created namespace: {}", client.namespaces().resource(ns).createOrReplace()); ...
75
522
597
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ExecExample.java
ExecExample
newExecWatch
class ExecExample { public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: podName [namespace]"); return; } String podName = args[0]; String namespace = "default"; if (args.length > 1) { namespace = args[1]; } try ( Kubernet...
return client.pods().inNamespace(namespace).withName(podName) .writingOutput(System.out) .writingError(System.err) .withTTY() .usingListener(new SimpleListener()) .exec("sh", "-c", "echo 'Hello world!'");
312
76
388
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ExecExampleWithTerminalSize.java
ExecExampleWithTerminalSize
main
class ExecExampleWithTerminalSize { public static void main(String[] args) throws InterruptedException {<FILL_FUNCTION_BODY>} private static ExecWatch newExecWatch(KubernetesClient client, String namespace, String podName, String columns, String lines) { return client.pods().inNamespace(namespace).withN...
if (args.length < 1) { System.out.println("Usage: podName [namespace] [columns] [lines]\n" + "Use env variable COLUMNS & LINES to initialize terminal size."); return; } String podName = args[0]; String namespace = "default"; String columns = "80"; String lines = "24"; ...
298
224
522
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ExecLoopExample.java
FutureChecker
run
class FutureChecker implements Runnable { private final String name; private final Future<?> future; private FutureChecker(String name, Future<?> future) { this.name = name; this.future = future; } @Override public void run() {<FILL_FUNCTION_BODY>} }
if (!future.isDone()) { System.out.println("Future:[" + name + "] is not done yet"); }
91
37
128
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ExecStdInExample.java
ExecStdInExample
main
class ExecStdInExample { public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
String master = "https://localhost:8443/"; String podName = null; if (args.length == 2) { master = args[0]; podName = args[1]; } if (args.length == 1) { podName = args[0]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); try ( KubernetesCl...
35
283
318
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ExecuteCommandOnPodExample.java
SimpleListener
onClose
class SimpleListener implements ExecListener { private CompletableFuture<String> data; private ByteArrayOutputStream baos; public SimpleListener(CompletableFuture<String> data, ByteArrayOutputStream baos) { this.data = data; this.baos = baos; } @Override public void onOpen() { ...
System.out.println("Exit with: " + code + " and with reason: " + reason); data.complete(baos.toString());
180
38
218
<no_super_class>
fabric8io_kubernetes-client
kubernetes-client/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/GenericKubernetesResourceExample.java
GenericKubernetesResourceExample
main
class GenericKubernetesResourceExample { private static final Logger logger = LoggerFactory.getLogger(GenericKubernetesResourceExample.class); public static void main(String[] args) throws Exception {<FILL_FUNCTION_BODY>} }
final ConfigBuilder configBuilder = new ConfigBuilder(); configBuilder.withWatchReconnectInterval(500); configBuilder.withWatchReconnectLimit(5); try (KubernetesClient client = new KubernetesClientBuilder().withConfig(configBuilder.build()).build()) { String namespace = "default"; CustomR...
65
758
823
<no_super_class>