func NewCommand(ctx context.Context) *cobra.Command {
	opts := options.New()
	cmd := &cobra.Command{
		Use:   "cert-manager-csi-driver",
		Short: helpOutput,
		Long:  helpOutput,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			return opts.Complete()
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			log := opts.Logr.WithName("main")
			log.Info("building driver")
			store, err := storage.NewFilesystem(opts.Logr.WithName("storage"), opts.DataRoot)
			if err != nil {
				return fmt.Errorf("failed to setup filesystem: %w", err)
			}
			store.FSGroupVolumeAttributeKey = csiapi.FSGroupKey
			keyGenerator := keygen.Generator{Store: store}
			writer := filestore.Writer{Store: store}
			var clientForMeta manager.ClientForMetadataFunc
			if opts.UseTokenRequest {
				clientForMeta = util.ClientForMetadataTokenRequestEmptyAud(opts.RestConfig)
			}
			d, err := driver.New(opts.Endpoint, opts.Logr.WithName("driver"), driver.Options{
				DriverName:    opts.DriverName,
				DriverVersion: "v0.1.1",
				NodeID:        opts.NodeID,
				Store:         store,
				Manager: manager.NewManagerOrDie(manager.Options{
					Client:             opts.CMClient,
					ClientForMetadata:  clientForMeta,
					MetadataReader:     store,
					Clock:              clock.RealClock{},
					Log:                opts.Logr.WithName("manager"),
					NodeID:             opts.NodeID,
					GeneratePrivateKey: keyGenerator.KeyForMetadata,
					GenerateRequest:    requestgen.RequestForMetadata,
					SignRequest:        signRequest,
					WriteKeypair:       writer.WriteKeypair,
				}),
			})
			if err != nil {
				return fmt.Errorf("failed to setup driver: " + err.Error())
			}
			go func() {
				<-ctx.Done()
				log.Info("shutting down driver", "context", ctx.Err())
				d.Stop()
			}()
			log.Info("running driver")
			if err := d.Run(); err != nil {
				return fmt.Errorf("failed running driver: " + err.Error())
			}
			return nil
		},
	}
	opts = opts.Prepare(cmd)
	return cmd
}
NewCommand will return a new command instance for the cert-manager CSI driver.
package app
import (
	"context"
	"crypto"
	"crypto/rand"
	"crypto/x509"
	"encoding/pem"
	"fmt"
	"github.com/cert-manager/csi-lib/driver"
	"github.com/cert-manager/csi-lib/manager"
	"github.com/cert-manager/csi-lib/manager/util"
	"github.com/cert-manager/csi-lib/metadata"
	"github.com/cert-manager/csi-lib/storage"
	"github.com/spf13/cobra"
	"k8s.io/utils/clock"
	"github.com/cert-manager/csi-driver/cmd/app/options"
	csiapi "github.com/cert-manager/csi-driver/pkg/apis/v1alpha1"
	"github.com/cert-manager/csi-driver/pkg/filestore"
	"github.com/cert-manager/csi-driver/pkg/keygen"
	"github.com/cert-manager/csi-driver/pkg/requestgen"
)
const (
	helpOutput = "Container Storage Interface driver to issue certificates from cert-manager"
)