Merge pull request #4731 from DiptoChakrabarty/lint

add go linters fixes within codebase
This commit is contained in:
jetstack-bot 2022-01-18 12:52:57 +00:00 committed by GitHub
commit e2aede44c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 14 deletions

View File

@ -39,6 +39,7 @@ import (
"github.com/jetstack/cert-manager/pkg/util/profiling"
)
// InjectorControllerOptions is a struct having injector controller options values
type InjectorControllerOptions struct {
Namespace string
LeaderElect bool
@ -60,6 +61,7 @@ type InjectorControllerOptions struct {
log logr.Logger
}
// AddFlags adds the various flags for injector controller options
func (o *InjectorControllerOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Namespace, "namespace", "", ""+
"If set, this limits the scope of cainjector to a single namespace. "+
@ -88,6 +90,7 @@ func (o *InjectorControllerOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.PprofAddr, "profiler-address", cmdutil.DefaultProfilerAddr, "Address of the Go profiler (pprof) if enabled. This should never be exposed on a public interface.")
}
// NewInjectorControllerOptions returns a new InjectorControllerOptions
func NewInjectorControllerOptions(out, errOut io.Writer) *InjectorControllerOptions {
o := &InjectorControllerOptions{
StdOut: out,

View File

@ -32,7 +32,7 @@ func NewCmdCreate(ctx context.Context, ioStreams genericclioptions.IOStreams) *c
return cmds
}
// Create a bare Create Command, without any subcommands
// NewCmdCreateBare creates a bare Create Command, without any subcommands
func NewCmdCreateBare() *cobra.Command {
return &cobra.Command{
Use: "create",

View File

@ -23,7 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ValidArgsCertificates returns a cobra ValidArgsFunction for listing Certificates.
// ValidArgsListCertificates returns a cobra ValidArgsFunction for listing Certificates.
func ValidArgsListCertificates(ctx context.Context, factory **Factory) func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
return func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
if len(args) > 0 {
@ -49,7 +49,7 @@ func ValidArgsListCertificates(ctx context.Context, factory **Factory) func(_ *c
}
}
// ValidArgsSecrets returns a cobra ValidArgsFunction for listing Secrets.
// ValidArgsListSecrets returns a cobra ValidArgsFunction for listing Secrets.
func ValidArgsListSecrets(ctx context.Context, factory **Factory) func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
return func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
if len(args) > 0 {
@ -75,7 +75,7 @@ func ValidArgsListSecrets(ctx context.Context, factory **Factory) func(_ *cobra.
}
}
// ValidArgsCertificateSigningRequests returns a cobra ValidArgsFunction for
// ValidArgsListCertificateSigningRequests returns a cobra ValidArgsFunction for
// listing CertificateSigningRequests.
func ValidArgsListCertificateSigningRequests(ctx context.Context, factory **Factory) func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
return func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
@ -102,7 +102,7 @@ func ValidArgsListCertificateSigningRequests(ctx context.Context, factory **Fact
}
}
// ValidArgsCertificateRequests returns a cobra ValidArgsFunction for listing
// ValidArgsListCertificateRequests returns a cobra ValidArgsFunction for listing
// CertificateRequests.
func ValidArgsListCertificateRequests(ctx context.Context, factory **Factory) func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
return func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {

View File

@ -78,7 +78,7 @@ func KubeKeyUsageStrings(usage x509.KeyUsage) []certificatesv1.KeyUsage {
return usageStr
}
// ExtKeyUsageStrings returns the certificatesv1.KeyUsage and "unknown" if not found
// KubeExtKeyUsageStrings returns the certificatesv1.KeyUsage and "unknown" if not found
func KubeExtKeyUsageStrings(usage []x509.ExtKeyUsage) []certificatesv1.KeyUsage {
var usageStr []certificatesv1.KeyUsage

View File

@ -57,15 +57,15 @@ const (
)
const (
// issuerNameAnnotation can be used to override the issuer specified on the
// created Certificate resource.
// IngressIssuerNameAnnotationKey holds the issuerNameAnnotation value which can be
// used to override the issuer specified on the created Certificate resource.
IngressIssuerNameAnnotationKey = "cert-manager.io/issuer"
// clusterIssuerNameAnnotation can be used to override the issuer specified on the
// created Certificate resource. The Certificate will reference the
// specified *ClusterIssuer* instead of normal issuer.
// IngressClusterIssuerNameAnnotationKey holds the clusterIssuerNameAnnotation value which
// can be used to override the issuer specified on the created Certificate resource. The Certificate
// will reference the specified *ClusterIssuer* instead of normal issuer.
IngressClusterIssuerNameAnnotationKey = "cert-manager.io/cluster-issuer"
// acmeIssuerHTTP01IngressClassAnnotation can be used to override the http01 ingressClass
// if the challenge type is set to http01
// IngressACMEIssuerHTTP01IngressClassAnnotationKey holds the acmeIssuerHTTP01IngressClassAnnotation value
// which can be used to override the http01 ingressClass if the challenge type is set to http01
IngressACMEIssuerHTTP01IngressClassAnnotationKey = "acme.cert-manager.io/http01-ingress-class"
// IngressClassAnnotationKey picks a specific "class" for the Ingress. The
@ -110,7 +110,7 @@ const (
// as namespace/name. The certificate is expected to have the is-serving-for annotations.
WantInjectAnnotation = "cert-manager.io/inject-ca-from"
// WantInjectAPIServerCAAnnotation, if set to "true", will make the cainjector
// WantInjectAPIServerCAAnnotation will - if set to "true" - make the cainjector
// inject the CA certificate for the Kubernetes apiserver into the resource.
// It discovers the apiserver's CA by inspecting the service account credentials
// mounted into the cainjector pod.

View File

@ -44,6 +44,7 @@ import (
)
const (
// CSRControllerName holds the controller name
CSRControllerName = "certificatesigningrequests-issuer-selfsigned"
)
@ -72,6 +73,7 @@ func init() {
})
}
// NewSelfSigned returns a new instance of SelfSigned type
func NewSelfSigned(ctx *controllerpkg.Context) *SelfSigned {
return &SelfSigned{
issuerOptions: ctx.IssuerOptions,

View File

@ -36,6 +36,7 @@ type DNSProvider struct {
log logr.Logger
}
// NewDNSProvider returns a new DNSProvider Instance with configuration
func NewDNSProvider(project string, saBytes []byte, dns01Nameservers []string, ambient bool, hostedZoneName string) (*DNSProvider, error) {
// project is a required field
if project == "" {

View File

@ -25,6 +25,7 @@ import (
"github.com/jetstack/cert-manager/pkg/issuer"
)
// Vault Issuer for the certificate authority of Vault
type Vault struct {
*controller.Context
issuer v1.GenericIssuer
@ -37,6 +38,7 @@ type Vault struct {
resourceNamespace string
}
// NewVault returns a new Vault
func NewVault(ctx *controller.Context, issuer v1.GenericIssuer) (issuer.Interface, error) {
secretsLister := ctx.KubeSharedInformerFactory.Core().V1().Secrets().Lister()

View File

@ -68,6 +68,7 @@ func DurationFromCertificateSigningRequest(csr *certificatesv1.CertificateSignin
return duration, nil
}
// BuildKeyUsagesKube returns a key usage and extended key usage of the x509 certificate
func BuildKeyUsagesKube(usages []certificatesv1.KeyUsage) (x509.KeyUsage, []x509.ExtKeyUsage, error) {
var unk []certificatesv1.KeyUsage
if len(usages) == 0 {