Skip to content

Commit

Permalink
Upgrade to cert-manager v1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pearj committed Dec 2, 2021
1 parent 9e065e8 commit cdc7657
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Create a certificate using selfsigned issuer from cert-manager in order to get t
cat <<EOF | kubectl -n adcs-issuer-system apply -f -

``` YAML
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert
Expand Down Expand Up @@ -100,7 +100,7 @@ Apply a certificate resource, that will make a certificaterequest with the issue
cat <<EOF | kubectl -n adcs-issuer-system apply -f -
``` YAML
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The secret used by the `ClusterAdcsIssuer` to authenticate (`credentialsRef`), m
To request a certificate with `AdcsIssuer` the standard `certificate.cert-manager.io` object needs to be created. The `issuerRef` must be set to point to `AdcsIssuer` or `ClusterAdcsIssuer` object
from group `adcs.certmanager.csf.nokie.com` e.g.:
```
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations:
Expand Down Expand Up @@ -107,7 +107,7 @@ metadata:
name: adcs-cert-3831834799
namespace: c1
ownerReferences:
- apiVersion: cert-manager.io/v1alpha2
- apiVersion: cert-manager.io/v1
blockOwnerDeletion: true
controller: true
kind: CertificateRequest
Expand Down
3 changes: 2 additions & 1 deletion api/v1/adcsissuer_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

//validationutils "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"

ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/jetstack/cert-manager/pkg/util/pki"
Expand Down
3 changes: 1 addition & 2 deletions controllers/adcsissuer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ type AdcsIssuerReconciler struct {
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=adcsissuers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=adcsissuers/status,verbs=get;update;patch

func (r *AdcsIssuerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
func (r *AdcsIssuerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("adcsissuer", req.NamespacedName)

// your logic here
Expand Down
5 changes: 2 additions & 3 deletions controllers/adcsrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"

api "github.com/chojnack/adcs-issuer/api/v1"
Expand All @@ -46,8 +46,7 @@ type AdcsRequestReconciler struct {
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=adcsrequests,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=adcsrequests/status,verbs=get;update;patch

func (r *AdcsRequestReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
func (r *AdcsRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("adcsrequest", req.NamespacedName)

// your logic here
Expand Down
9 changes: 4 additions & 5 deletions controllers/certificaterequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

api "github.com/chojnack/adcs-issuer/api/v1"
cmapiutil "github.com/jetstack/cert-manager/pkg/api/util"
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
core "k8s.io/api/core/v1"
apimacherrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -49,8 +49,7 @@ var (
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificaterequests/status,verbs=get;update;patch
// +kubebuilder:rbac:groups="",resources=events,verbs=patch

func (r *CertificateRequestReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("certificaterequest", req.NamespacedName)

// your logic here
Expand Down Expand Up @@ -118,7 +117,7 @@ func (r *CertificateRequestReconciler) Reconcile(req ctrl.Request) (ctrl.Result,

func (r *CertificateRequestReconciler) createAdcsRequest(ctx context.Context, cmRequest *cmapi.CertificateRequest) error {
spec := api.AdcsRequestSpec{
CSRPEM: cmRequest.Spec.CSRPEM,
CSRPEM: cmRequest.Spec.Request,
IssuerRef: cmRequest.Spec.IssuerRef,
}
return r.Create(ctx, &api.AdcsRequest{
Expand All @@ -139,7 +138,7 @@ func (r *CertificateRequestReconciler) SetupWithManager(mgr ctrl.Manager) error

func RequestDiffers(adcsReq *api.AdcsRequest, certReq *cmapi.CertificateRequest) bool {
a := adcsReq.Spec.CSRPEM
b := certReq.Spec.CSRPEM
b := certReq.Spec.Request
if len(a) != len(b) {
return true
}
Expand Down
3 changes: 1 addition & 2 deletions controllers/clusteradcsissuer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ type ClusterAdcsIssuerReconciler struct {
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=clusteradcsissuers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=adcs.certmanager.csf.nokia.com,resources=clusteradcsissuers/status,verbs=get;update;patch

func (r *ClusterAdcsIssuerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
func (r *ClusterAdcsIssuerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("clusteradcsissuer", req.NamespacedName)

// your logic here
Expand Down
5 changes: 3 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
// +kubebuilder:scaffold:imports
Expand All @@ -44,11 +45,11 @@ func TestAPIs(t *testing.T) {

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{envtest.NewlineReporter{}})
[]Reporter{printer.NewlineReporter{}})
}

var _ = BeforeSuite(func(done Done) {
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
logf.SetLogger(zap.New(zap.UseDevMode(true)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
Expand Down
2 changes: 1 addition & 1 deletion issuers/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"time"

//cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
//cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
//cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
//metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
adcsv1 "github.com/chojnack/adcs-issuer/api/v1"
"github.com/chojnack/adcs-issuer/controllers"
"github.com/chojnack/adcs-issuer/issuers"
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand Down

0 comments on commit cdc7657

Please sign in to comment.