add comments to satisfy linter

Signed-off-by: Krzysztof Ostrowski <kostrows@redhat.com>
Co-authored-by: Irbe Krumina <irbekrm@gmail.com>
This commit is contained in:
Krzysztof Ostrowski
2021-11-04 18:15:46 +01:00
co-authored by Irbe Krumina
parent 922a0a09ff
commit e35cb361c8
10 changed files with 31 additions and 10 deletions
@@ -84,6 +84,7 @@ type IssuerSpec struct {
IssuerConfig
}
// IssuerConfig is a generic wrapper around custom issuer types
type IssuerConfig struct {
// ACME configures this issuer to communicate with a RFC8555 (ACME) server
// to obtain signed x509 certificates.
@@ -240,6 +241,11 @@ type VaultKubernetesAuth struct {
Role string
}
// CAIssuer configures an issuer that can issue certificates from its provided
// CA certificate. It contains the name of the private key to sign certificates,
// holds the location for Certificate Revocation Lists (CRL) distribution
// points and list of URLs of Online Certificate Status Protocol (OCSP)
// responders.
type CAIssuer struct {
// SecretName is the name of the secret used to sign Certificates issued
// by this Issuer.
+1
View File
@@ -26,6 +26,7 @@ import (
v1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
)
// Vault is a mock implementation of the Vault interface
type Vault struct {
NewFn func(string, corelisters.SecretLister, v1.GenericIssuer) (*Vault, error)
SignFn func([]byte, time.Duration) ([]byte, []byte, error)
+5 -3
View File
@@ -24,6 +24,10 @@ import (
"regexp"
)
// ComputeName hashes the given object and prefixes it with prefix.
// The algorithm in use is FowlerNollVo hash function and is not
// cryptographically secure. Using a cryptographically secure hash is
// not necessary.
func ComputeName(prefix string, obj interface{}) (string, error) {
objectBytes, err := json.Marshal(obj)
if err != nil {
@@ -43,11 +47,9 @@ func ComputeName(prefix string, obj interface{}) (string, error) {
return fmt.Sprintf("%s-%d", prefix, hashF.Sum32()), nil
}
// DNSSafeShortenTo52Characters shortens the input string to 52 chars and ensures the last char is an alpha-numeric character.
func DNSSafeShortenTo52Characters(in string) string {
if len(in) >= 52 {
// shorten the cert name to 52 chars to ensure the total length of the name
// also shorten the 52 char string to the last non-symbol character
// is less than or equal to 64 characters
validCharIndexes := regexp.MustCompile(`[a-zA-Z\d]`).FindAllStringIndex(fmt.Sprintf("%.52s", in), -1)
in = in[:validCharIndexes[len(validCharIndexes)-1][1]]
}
@@ -23,6 +23,7 @@ import (
"github.com/jetstack/cert-manager/pkg/issuer"
)
// Issuer is a mock implementation of an Issuer.
type Issuer struct {
FakeSign func(context.Context, *cmapi.CertificateRequest, cmapi.GenericIssuer) (*issuer.IssueResponse, error)
}
+10 -5
View File
@@ -17,7 +17,6 @@ limitations under the License.
// Package akamai implements a DNS provider for solving the DNS-01
// challenge using Akamai Edge DNS.
// See https://developer.akamai.com/api/cloud_security/edge_dns_zone_management/v2.html
package akamai
import (
@@ -34,14 +33,15 @@ import (
logf "github.com/jetstack/cert-manager/pkg/logs"
)
// Interface defined to enable mocking and required functions
// OpenEdgegridDNSService enables mocking and required functions
type OpenEdgegridDNSService interface {
GetRecord(zone string, name string, record_type string) (*dns.RecordBody, error)
GetRecord(zone string, name string, recordType string) (*dns.RecordBody, error)
RecordSave(rec *dns.RecordBody, zone string) error
RecordUpdate(rec *dns.RecordBody, zone string) error
RecordDelete(rec *dns.RecordBody, zone string) error
}
//OpenDNSConfig contains akamai's config to create authorization header.
type OpenDNSConfig struct {
config edgegrid.Config
}
@@ -258,23 +258,28 @@ func makeTxtRecordName(fqdn, hostedDomain string) (string, error) {
return recName, nil
}
func (o OpenDNSConfig) GetRecord(zone string, name string, record_type string) (*dns.RecordBody, error) {
// GetRecord gets a single Recordset as RecordBody. Sets Akamai OPEN Edgegrid API
// global variable.
func (o OpenDNSConfig) GetRecord(zone string, name string, recordType string) (*dns.RecordBody, error) {
dns.Config = o.config
return dns.GetRecord(zone, name, record_type)
return dns.GetRecord(zone, name, recordType)
}
// RecordSave is a function that saves the given zone in the given RecordBody.
func (o OpenDNSConfig) RecordSave(rec *dns.RecordBody, zone string) error {
return rec.Save(zone)
}
// RecordUpdate is a function that updates the given zone in the given RecordBody.
func (o OpenDNSConfig) RecordUpdate(rec *dns.RecordBody, zone string) error {
return rec.Update(zone)
}
// RecordDelete is a function that deletes the given zone in the given RecordBody.
func (o OpenDNSConfig) RecordDelete(rec *dns.RecordBody, zone string) error {
return rec.Delete(zone)
+2 -2
View File
@@ -303,7 +303,7 @@ func TestCleanUpFailDeleteRecord(t *testing.T) {
}
// Stub Get Record
func (o StubOpenDNSConfig) GetRecord(zone string, name string, record_type string) (*dns.RecordBody, error) {
func (o StubOpenDNSConfig) GetRecord(zone string, name string, recordType string) (*dns.RecordBody, error) {
var rec *dns.RecordBody
@@ -322,7 +322,7 @@ func (o StubOpenDNSConfig) GetRecord(zone string, name string, record_type strin
if name != rec.Name {
return nil, fmt.Errorf("GetRecord: expected/actual Name don't match")
}
if record_type != rec.RecordType {
if recordType != rec.RecordType {
return nil, fmt.Errorf("GetRecord: expected/actual Record Type don't match")
}
}
+1
View File
@@ -39,6 +39,7 @@ const (
messageKeyPairVerified = "Signing CA verified"
)
// Setup verifies signing CA.
func (c *CA) Setup(ctx context.Context) error {
log := logf.FromContext(ctx, "setup")
+2
View File
@@ -24,6 +24,8 @@ import (
cmlisters "github.com/jetstack/cert-manager/pkg/client/listers/certmanager/v1"
)
// Helper is an interface that defines a method that returns an issuer for the given
// IssuerRef and namespace.
type Helper interface {
GetGenericIssuer(ref cmmeta.ObjectReference, ns string) (cmapi.GenericIssuer, error)
}
+1
View File
@@ -45,6 +45,7 @@ const (
messageAppRoleAuthFieldsRequired = "Vault AppRole auth requires both roleId and tokenSecretRef.name"
)
// Setup creates a new Vault client and attempts to authenticate with the Vault instance and sets the issuer's conditions to reflect the success of the setup.
func (v *Vault) Setup(ctx context.Context) error {
if v.issuer.GetSpec().Vault == nil {
logf.V(logf.WarnLevel).Infof("%s: %s", v.issuer.GetObjectMeta().Name, messageVaultConfigRequired)
+2
View File
@@ -64,6 +64,7 @@ type Metrics struct {
var readyConditionStatuses = [...]cmmeta.ConditionStatus{cmmeta.ConditionTrue, cmmeta.ConditionFalse, cmmeta.ConditionUnknown}
// New creates a Metrics struct and populates it with prometheus metric types.
func New(log logr.Logger, c clock.Clock) *Metrics {
var (
clockTimeSeconds = prometheus.NewCounterFunc(
@@ -176,6 +177,7 @@ func (m *Metrics) NewServer(ln net.Listener) *http.Server {
MaxHeaderBytes: prometheusMetricsServerMaxHeaderBytes,
Handler: mux,
}
return server
}