...

Source file src/github.com/cert-manager/issuer-lib/controllers/request_objecthelper.go

Documentation: github.com/cert-manager/issuer-lib/controllers

     1  /*
     2  Copyright 2023 The cert-manager Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package controllers
    18  
    19  import (
    20  	cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
    21  	certificatesv1 "k8s.io/api/certificates/v1"
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  	"k8s.io/client-go/tools/record"
    24  	"k8s.io/utils/clock"
    25  	"sigs.k8s.io/controller-runtime/pkg/client"
    26  
    27  	"github.com/cert-manager/issuer-lib/controllers/signer"
    28  )
    29  
    30  const (
    31  	eventRequestIssued    = "Issued"
    32  	eventRequestRetryable = "Pending"
    33  
    34  	eventRequestUnexpectedError = "UnexpectedError"
    35  	eventRequestRetryableError  = "RetryableError"
    36  	eventRequestPermanentError  = "PermanentError"
    37  
    38  	eventRequestWaitingForIssuerExist = "WaitingForIssuerExist"
    39  	eventRequestWaitingForIssuerReady = "WaitingForIssuerReady"
    40  )
    41  
    42  type RequestObjectHelper interface {
    43  	IsApproved() bool
    44  	IsDenied() bool
    45  	IsReady() bool
    46  	IsFailed() bool
    47  
    48  	RequestObject() signer.CertificateRequestObject
    49  
    50  	NewPatch(
    51  		clock clock.PassiveClock,
    52  		fieldOwner string,
    53  		eventRecorder record.EventRecorder,
    54  	) RequestPatchHelper
    55  }
    56  
    57  type RequestPatchHelper interface { //nolint:interfacebloat
    58  	RequestPatch
    59  
    60  	SetInitializing() (didInitialise bool)
    61  	SetWaitingForIssuerExist(error)
    62  	SetWaitingForIssuerReadyNoCondition()
    63  	SetWaitingForIssuerReadyOutdated()
    64  	SetWaitingForIssuerReadyNotReady(*cmapi.IssuerCondition)
    65  	SetCustomCondition(
    66  		conditionType string,
    67  		conditionStatus metav1.ConditionStatus,
    68  		conditionReason string, conditionMessage string,
    69  	) (didCustomConditionTransition bool)
    70  	SetPending(reason string)
    71  	SetRetryableError(error)
    72  	SetPermanentError(error)
    73  	SetUnexpectedError(error)
    74  	SetIssued(signer.PEMBundle)
    75  }
    76  
    77  type RequestPatch interface {
    78  	Patch() (client.Object, client.Patch, error)
    79  }
    80  
    81  type CertificateRequestPatch interface {
    82  	CertificateRequestPatch() *cmapi.CertificateRequestStatus
    83  }
    84  
    85  type CertificateSigningRequestPatch interface {
    86  	CertificateSigningRequestPatch() *certificatesv1.CertificateSigningRequestStatus
    87  }
    88  

View as plain text