Skip to content

Commit

Permalink
Fix fabric8io#2565: add cert-manager support
Browse files Browse the repository at this point in the history
  • Loading branch information
matthyx authored and rohanKanojia committed Apr 21, 2021
1 parent b0282d8 commit 533ba96
Show file tree
Hide file tree
Showing 27 changed files with 4,228 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Fix #2980: Add DSL Support for `apps/v1#ControllerRevision` resource
* Fix #2981: Add DSL support for `storage.k8s.io/v1beta1` CSIDriver, CSINode and VolumeAttachment
* Fix #2912: Add DSL support for `storage.k8s.io/v1beta1` CSIStorageCapacity
* Fix #2565: Add support for CertManager extension

#### _**Note**_: Breaking changes in the API
##### DSL Changes:
Expand Down
196 changes: 196 additions & 0 deletions extensions/certmanager/client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<?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>certmanager</artifactId>
<version>5.3-SNAPSHOT</version>
</parent>

<artifactId>certmanager-client</artifactId>
<packaging>bundle</packaging>
<name>Fabric8 :: Cert Manager :: Client</name>

<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.ResourceHandler
</osgi.provide-capability>
<osgi.import>
io.fabric8.kubernetes.api.builder,
!io.fabric8.certmanager.client.*,
*
</osgi.import>
<osgi.export>
io.fabric8.certmanager.client.*
</osgi.export>
<!-- <osgi.include.resources>-->
<!-- /META-INF/services/io.fabric8.kubernetes.client.ExtensionAdapter=target/classes/META-INF/services/io.fabric8.kubernetes.client.ExtensionAdapter,-->
<!-- /META-INF/services/io.fabric8.kubernetes.client.ResourceHandler=target/classes/META-INF/services/io.fabric8.kubernetes.client.ResourceHandler-->
<!-- </osgi.include.resources>-->
</properties>

<dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>certmanager-model</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<exclusions>
<exclusion>
<groupId>io.sundr</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</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-migrationsupport</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<passphrase>4uds0n</passphrase>
<useAgent>true</useAgent>
</configuration>
</plugin>

<plugin>
<groupId>io.sundr</groupId>
<artifactId>sundr-maven-plugin</artifactId>
<version>${sundrio.version}</version>
<configuration>
<boms>
<bom>
<artifactId>certmanager-java-api-bom</artifactId>
<name>Fabric8 :: Cert Manager ::Bom</name>
<properties>
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
</properties>
</bom>
<bom>
<artifactId>certmanager-java-api-bom-with-deps</artifactId>
<name>Fabric8 :: Cert Manager ::Bom with Dependencies</name>
<dependencies>
<includes>
<include>com.squareup*:*</include>
<include>com.fasterxml.jackson*:*</include>
</includes>
</dependencies>
<properties>
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
</properties>
</bom>
</boms>
</configuration>
<executions>
<execution>
<goals>
<goal>generate-bom</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>${buildnumber.plugin.version}</version>
<executions>
<execution>
<id>get-build-timestamp</id>
<phase>initialize</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<!-- Example date: Wed, 4 Jul 2001 12:08:56 -0700 -->
<timestampFormat>EEE, d MMM yyyy HH:mm:ss Z</timestampFormat>
<timestampPropertyName>build.datetime</timestampPropertyName>
</configuration>
</execution>
<execution>
<id>get-scm-revision</id>
<phase>initialize</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>zip</nonFilteredFileExtension>
<nonFilteredFileExtension>gz</nonFilteredFileExtension>
<nonFilteredFileExtension>jar</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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.certmanager.client;


import io.fabric8.certmanager.api.model.acme.v1.Challenge;
import io.fabric8.certmanager.api.model.acme.v1.ChallengeList;
import io.fabric8.certmanager.api.model.acme.v1.Order;
import io.fabric8.certmanager.api.model.acme.v1.OrderList;
import io.fabric8.certmanager.api.model.v1.Certificate;
import io.fabric8.certmanager.api.model.v1.CertificateList;
import io.fabric8.certmanager.api.model.v1.CertificateRequest;
import io.fabric8.certmanager.api.model.v1.CertificateRequestList;
import io.fabric8.certmanager.api.model.v1.ClusterIssuer;
import io.fabric8.certmanager.api.model.v1.ClusterIssuerList;
import io.fabric8.certmanager.api.model.v1.Issuer;
import io.fabric8.certmanager.api.model.v1.IssuerList;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;

/**
* Main interface for CertManager Client library.
*/
public interface CertManagerClient extends Client {
MixedOperation<Certificate, CertificateList, Resource<Certificate>> certificates();
MixedOperation<CertificateRequest, CertificateRequestList, Resource<CertificateRequest>> certificateRequests();
MixedOperation<Issuer, IssuerList, Resource<Issuer>> issuers();
NonNamespaceOperation<ClusterIssuer, ClusterIssuerList, Resource<ClusterIssuer>> clusterIssuers();
MixedOperation<Challenge, ChallengeList, Resource<Challenge>> challenges();
MixedOperation<Order, OrderList, Resource<Order>> orders();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* 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.certmanager.client;

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.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class CertManagerExtensionAdapter extends ExtensionAdapterSupport implements ExtensionAdapter<CertManagerClient> {

static final ConcurrentMap<URL, Boolean> IS_VOLUME_SNAPSHOT = new ConcurrentHashMap<>();
static final ConcurrentMap<URL, Boolean> USES_VOLUME_SNAPSHOT_APIGROUPS = new ConcurrentHashMap<>();
public static final String API_GROUP = "snapshot.storage.k8s.io";

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

@Override
public Boolean isAdaptable(Client client) {
return isAdaptable(client, IS_VOLUME_SNAPSHOT, USES_VOLUME_SNAPSHOT_APIGROUPS, API_GROUP);
}

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.certmanager.client;

import io.sundr.codegen.annotations.ResourceSelector;
import io.sundr.transform.annotations.VelocityTransformation;
import io.sundr.transform.annotations.VelocityTransformations;

@VelocityTransformations(
value = {
@VelocityTransformation("/resource-operation.vm"),
@VelocityTransformation("/resource-handler.vm"),
@VelocityTransformation(value = "/resource-handler-services.vm", gather = true, outputPath = "META-INF/services/io.fabric8.kubernetes.client.ResourceHandler")
},
resources = {
@ResourceSelector("model.properties")
}

)
public class CodeGen {
}
Loading

0 comments on commit 533ba96

Please sign in to comment.