Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CSI Volume Snapshot extension #2356

Merged
merged 8 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Fix #2292: Update createOrReplace to do replace when create fails with conflict

#### New Features
* CSI Volume Snapshot extension
* Fix #2311: Add Support for creating bootstrap project template
* Fix #2287: Add support for V1 and V1Beta1 CustomResourceDefinition
* Fix #2319: Create Config without using auto-configure functionality or setting env variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package io.fabric8.knative.client;

import io.fabric8.kubernetes.client.ExtensionAdapterSupport;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.ExtensionAdapter;
import okhttp3.OkHttpClient;

import java.net.URL;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class KnativeExtensionAdapter implements ExtensionAdapter<KnativeClient> {
public class KnativeExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<KnativeClient> {

static final ConcurrentMap<URL, Boolean> IS_TEKTON = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_TEKTON_APIGROUPS = new ConcurrentHashMap<>();
Expand All @@ -37,35 +36,11 @@ public Class<KnativeClient> getExtensionType() {

@Override
public Boolean isAdaptable(Client client) {
return isKnativeAvailable(client);
return isAdaptable(client, IS_TEKTON, USES_TEKTON_APIGROUPS, "knative.dev");
}

@Override
public KnativeClient adapt(Client client) {
return new DefaultKnativeClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}

private boolean isKnativeAvailable(Client client) {
URL masterUrl = client.getMasterUrl();
if (IS_TEKTON.containsKey(masterUrl)) {
return IS_TEKTON.get(masterUrl);
} else {
RootPaths rootPaths = client.rootPaths();
if (rootPaths != null) {
List<String> paths = rootPaths.getPaths();
if (paths != null) {
for (String path : paths) {
// lets detect the new API Groups APIs for OpenShift
if (path.endsWith("knative.dev") || path.contains("knative.dev/")) {
USES_TEKTON_APIGROUPS.putIfAbsent(masterUrl, true);
IS_TEKTON.putIfAbsent(masterUrl, true);
return true;
}
}
}
}
}
IS_TEKTON.putIfAbsent(masterUrl, false);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package io.fabric8.knative.client.serving.v1;

import io.fabric8.kubernetes.client.ExtensionAdapterSupport;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.ExtensionAdapter;
import okhttp3.OkHttpClient;

import java.net.URL;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class ServingV1ExtensionAdapter implements ExtensionAdapter<ServingV1Client> {
public class ServingV1ExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<ServingV1Client> {

static final ConcurrentMap<URL, Boolean> IS_KNATIVE = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_KNATIVE_APIGROUPS = new ConcurrentHashMap<>();
Expand All @@ -37,35 +36,11 @@ public Class<ServingV1Client> getExtensionType() {

@Override
public Boolean isAdaptable(Client client) {
return isServingV1Available(client);
return isAdaptable(client, IS_KNATIVE, USES_KNATIVE_APIGROUPS, "knative.dev");
}

@Override
public ServingV1Client adapt(Client client) {
return new DefaultServingV1Client(client.adapt(OkHttpClient.class), client.getConfiguration());
}

private boolean isServingV1Available(Client client) {
URL masterUrl = client.getMasterUrl();
if (IS_KNATIVE.containsKey(masterUrl)) {
return IS_KNATIVE.get(masterUrl);
} else {
RootPaths rootPaths = client.rootPaths();
if (rootPaths != null) {
List<String> paths = rootPaths.getPaths();
if (paths != null) {
for (String path : paths) {
// lets detect the new API Groups APIs for OpenShift
if (path.endsWith("knative.dev") || path.contains("knative.dev/")) {
USES_KNATIVE_APIGROUPS.putIfAbsent(masterUrl, true);
IS_KNATIVE.putIfAbsent(masterUrl, true);
return true;
}
}
}
}
}
IS_KNATIVE.putIfAbsent(masterUrl, false);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package io.fabric8.knative.client.serving.v1beta1;

import io.fabric8.kubernetes.client.ExtensionAdapterSupport;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.ExtensionAdapter;
import okhttp3.OkHttpClient;

import java.net.URL;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;

public class ServingV1Beta1ExtensionAdapter implements ExtensionAdapter<ServingV1Beta1Client> {
public class ServingV1Beta1ExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<ServingV1Beta1Client> {

static final ConcurrentMap<URL, Boolean> IS_KNATIVE = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_KNATIVE_APIGROUPS = new ConcurrentHashMap<>();
Expand All @@ -37,35 +36,11 @@ public Class<ServingV1Beta1Client> getExtensionType() {

@Override
public Boolean isAdaptable(Client client) {
return isServingV1Beta1Available(client);
return isAdaptable(client, IS_KNATIVE, USES_KNATIVE_APIGROUPS, "knative.dev");
}

@Override
public ServingV1Beta1Client adapt(Client client) {
return new DefaultServingV1Beta1Client(client.adapt(OkHttpClient.class), client.getConfiguration());
}

private boolean isServingV1Beta1Available(Client client) {
URL masterUrl = client.getMasterUrl();
if (IS_KNATIVE.containsKey(masterUrl)) {
return IS_KNATIVE.get(masterUrl);
} else {
RootPaths rootPaths = client.rootPaths();
if (rootPaths != null) {
List<String> paths = rootPaths.getPaths();
if (paths != null) {
for (String path : paths) {
// lets detect the new API Groups APIs for OpenShift
if (path.endsWith("knative.dev") || path.contains("knative.dev/")) {
USES_KNATIVE_APIGROUPS.putIfAbsent(masterUrl, true);
IS_KNATIVE.putIfAbsent(masterUrl, true);
return true;
}
}
}
}
}
IS_KNATIVE.putIfAbsent(masterUrl, false);
return false;
}
}
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<module>knative</module>
<module>tekton</module>
<module>service-catalog</module>
<module>volumesnapshot</module>
</modules>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package io.fabric8.servicecatalog.client;

import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.ExtensionAdapterSupport;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.ExtensionAdapter;
import okhttp3.OkHttpClient;

import java.net.URL;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class ServiceCatalogExtensionAdapter implements ExtensionAdapter<ServiceCatalogClient> {
public class ServiceCatalogExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<ServiceCatalogClient> {

static final ConcurrentMap<URL, Boolean> IS_SERVICE_CATALOG = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_SERVICE_CATALOG_APIGROUPS = new ConcurrentHashMap<>();
Expand All @@ -37,35 +36,11 @@ public Class<ServiceCatalogClient> getExtensionType() {

@Override
public Boolean isAdaptable(Client client) {
return isServiceCatalogAvailable(client);
return isAdaptable(client, IS_SERVICE_CATALOG, USES_SERVICE_CATALOG_APIGROUPS, "servicecatalog.k8s.io");
}

@Override
public ServiceCatalogClient adapt(Client client) {
return new DefaultServiceCatalogClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}

private boolean isServiceCatalogAvailable(Client client) {
URL masterUrl = client.getMasterUrl();
if (IS_SERVICE_CATALOG.containsKey(masterUrl)) {
return IS_SERVICE_CATALOG.get(masterUrl);
} else {
RootPaths rootPaths = client.rootPaths();
if (rootPaths != null) {
List<String> paths = rootPaths.getPaths();
if (paths != null) {
for (String path : paths) {
// lets detect the new API Groups APIs for OpenShift
if (path.endsWith("servicecatalog.k8s.io") || path.contains("servicecatalog.k8s.io/")) {
USES_SERVICE_CATALOG_APIGROUPS.putIfAbsent(masterUrl, true);
IS_SERVICE_CATALOG.putIfAbsent(masterUrl, true);
return true;
}
}
}
}
}
IS_SERVICE_CATALOG.putIfAbsent(masterUrl, false);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package io.fabric8.tekton.client;

import io.fabric8.kubernetes.client.ExtensionAdapterSupport;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.ExtensionAdapter;
import okhttp3.OkHttpClient;

import java.net.URL;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;

public class TektonExtensionAdapter implements ExtensionAdapter<TektonClient> {
public class TektonExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<TektonClient> {

static final ConcurrentMap<URL, Boolean> IS_TEKTON = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_TEKTON_APIGROUPS = new ConcurrentHashMap<>();
Expand All @@ -37,35 +36,11 @@ public Class<TektonClient> getExtensionType() {

@Override
public Boolean isAdaptable(Client client) {
return isTektonAvailable(client);
return isAdaptable(client, IS_TEKTON, USES_TEKTON_APIGROUPS, "tekton.dev");
}

@Override
public TektonClient adapt(Client client) {
return new DefaultTektonClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}

private boolean isTektonAvailable(Client client) {
URL masterUrl = client.getMasterUrl();
if (IS_TEKTON.containsKey(masterUrl)) {
return IS_TEKTON.get(masterUrl);
} else {
RootPaths rootPaths = client.rootPaths();
if (rootPaths != null) {
List<String> paths = rootPaths.getPaths();
if (paths != null) {
for (String path : paths) {
// lets detect the new API Groups APIs for OpenShift
if (path.endsWith("tekton.dev") || path.contains("tekton.dev/")) {
USES_TEKTON_APIGROUPS.putIfAbsent(masterUrl, true);
IS_TEKTON.putIfAbsent(masterUrl, true);
return true;
}
}
}
}
}
IS_TEKTON.putIfAbsent(masterUrl, false);
return false;
}
}
Loading