Skip to content

Commit

Permalink
feat (extensions) : Add DSL for Open Virtual Networking k8s.ovn.org
Browse files Browse the repository at this point in the history
… API group resources

Add client module to provide DSL for resources in `k8s.ovn.org` API
group

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Feb 1, 2024
1 parent 0d8fc44 commit 9b67391
Show file tree
Hide file tree
Showing 19 changed files with 1,158 additions and 0 deletions.
112 changes: 112 additions & 0 deletions extensions/open-virtual-networking/client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-project</artifactId>
<version>6.11-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>

<artifactId>open-virtual-networking-client</artifactId>

<properties>
<useIncrementalCompilation>false</useIncrementalCompilation>
<osgi.require-capability>
osgi.extender;
filter:="(osgi.extender=osgi.serviceloader.registrar)"
</osgi.require-capability>
<osgi.provide-capability>
osgi.serviceloader;
osgi.serviceloader=io.fabric8.kubernetes.client.extension.ExtensionAdapter
</osgi.provide-capability>
<osgi.import>
io.fabric8.kubernetes.api.builder,
!io.fabric8.ovn.client.*,
*
</osgi.import>
<osgi.export>
io.fabric8.ovn.client.*
</osgi.export>
<osgi.include.resources>
${osgi.include.resources.default},
/META-INF/services/io.fabric8.kubernetes.client.extension.ExtensionAdapter=target/classes/META-INF/services/io.fabric8.kubernetes.client.extension.ExtensionAdapter
</osgi.include.resources>
</properties>

<dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>open-virtual-networking-model-v1</artifactId>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-api</artifactId>
<exclusions>
<exclusion>
<groupId>io.sundr</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.sundr</groupId>
<artifactId>builder-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* 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.ovn.client;

import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.RequestConfig;
import io.fabric8.kubernetes.client.WithRequestCallable;
import io.fabric8.kubernetes.client.dsl.FunctionCallable;
import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter;
import io.fabric8.ovn.client.dsl.V1OpenVirtualNetworkingAPIGroupDSL;

public class DefaultOpenVirtualNetworkingClient extends ExtensionRootClientAdapter<DefaultOpenVirtualNetworkingClient>
implements NamespacedOpenVirtualNetworkingClient {
public DefaultOpenVirtualNetworkingClient() {
super();
}

public DefaultOpenVirtualNetworkingClient(Client client) {
super(client);
}

@Override
public V1OpenVirtualNetworkingAPIGroupDSL v1() {
return adapt(V1OpenVirtualNetworkingAPIGroupClient.class);
}

@Override
protected DefaultOpenVirtualNetworkingClient newInstance(Client client) {
return new DefaultOpenVirtualNetworkingClient(client);
}

@Override
public FunctionCallable<NamespacedOpenVirtualNetworkingClient> withRequestConfig(RequestConfig requestConfig) {
return new WithRequestCallable<>(this, requestConfig);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.ovn.client;

import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.dsl.AnyNamespaceable;
import io.fabric8.kubernetes.client.dsl.Namespaceable;
import io.fabric8.kubernetes.client.dsl.RequestConfigurable;

public interface GenericOpenVirtualNetworkingClient<C extends Client> extends Client, OpenVirtualNetworkingClient,
Namespaceable<C>,
AnyNamespaceable<C>,
RequestConfigurable<C> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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.ovn.client;

public interface NamespacedOpenVirtualNetworkingClient extends OpenVirtualNetworkingClient,
GenericOpenVirtualNetworkingClient<NamespacedOpenVirtualNetworkingClient> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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.ovn.client;

import io.fabric8.kubernetes.client.Client;
import io.fabric8.ovn.client.dsl.V1OpenVirtualNetworkingAPIGroupDSL;

public interface OpenVirtualNetworkingClient extends Client {
/**
* DSL entrypoint for entrypoint for k8s.ovn.org/v1 resources
*
* @return {@link V1OpenVirtualNetworkingAPIGroupDSL}
*/
V1OpenVirtualNetworkingAPIGroupDSL v1();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* 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.ovn.client;

import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.extension.ExtensionAdapter;
import io.fabric8.ovn.client.dsl.V1OpenVirtualNetworkingAPIGroupDSL;

public class OpenVirtualNetworkingExtensionAdapter implements ExtensionAdapter<OpenVirtualNetworkingClient> {

@Override
public Class<OpenVirtualNetworkingClient> getExtensionType() {
return OpenVirtualNetworkingClient.class;
}

@Override
public OpenVirtualNetworkingClient adapt(Client client) {
if (client.hasApiGroup("k8s.ovn.org", false)) {
return new DefaultOpenVirtualNetworkingClient(client);
}
return null;
}

@Override
public void registerClients(ClientFactory factory) {
factory.register(V1OpenVirtualNetworkingAPIGroupDSL.class, new V1OpenVirtualNetworkingAPIGroupClient());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* 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.ovn.client;

import io.fabric8.kubernetes.api.model.ovn.v1.AdminPolicyBasedExternalRoute;
import io.fabric8.kubernetes.api.model.ovn.v1.AdminPolicyBasedExternalRouteList;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressFirewall;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressFirewallList;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressIP;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressIPList;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressQoS;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressQoSList;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressService;
import io.fabric8.kubernetes.api.model.ovn.v1.EgressServiceList;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.extension.ClientAdapter;
import io.fabric8.ovn.client.dsl.V1OpenVirtualNetworkingAPIGroupDSL;

public class V1OpenVirtualNetworkingAPIGroupClient extends ClientAdapter<V1OpenVirtualNetworkingAPIGroupClient>
implements V1OpenVirtualNetworkingAPIGroupDSL {
@Override
public NonNamespaceOperation<EgressIP, EgressIPList, Resource<EgressIP>> egressIps() {
return resources(EgressIP.class, EgressIPList.class);
}

@Override
public NonNamespaceOperation<AdminPolicyBasedExternalRoute, AdminPolicyBasedExternalRouteList, Resource<AdminPolicyBasedExternalRoute>> adminPolicyBasedExternalRoutes() {
return resources(AdminPolicyBasedExternalRoute.class, AdminPolicyBasedExternalRouteList.class);
}

@Override
public MixedOperation<EgressFirewall, EgressFirewallList, Resource<EgressFirewall>> egressFirewalls() {
return resources(EgressFirewall.class, EgressFirewallList.class);
}

@Override
public MixedOperation<EgressQoS, EgressQoSList, Resource<EgressQoS>> egressQoses() {
return resources(EgressQoS.class, EgressQoSList.class);
}

@Override
public MixedOperation<EgressService, EgressServiceList, Resource<EgressService>> egressServices() {
return resources(EgressService.class, EgressServiceList.class);
}

@Override
public V1OpenVirtualNetworkingAPIGroupClient newInstance() {
return new V1OpenVirtualNetworkingAPIGroupClient();
}
}
Loading

0 comments on commit 9b67391

Please sign in to comment.