github.com/argoproj/argo-events@v1.9.1/controllers/eventbus/installer/exotic_nats.go (about)

     1  package installer
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"go.uber.org/zap"
     8  
     9  	"github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1"
    10  )
    11  
    12  // exoticNATSInstaller is an inalleration implementation of exotic nats config.
    13  type exoticNATSInstaller struct {
    14  	eventBus *v1alpha1.EventBus
    15  
    16  	logger *zap.SugaredLogger
    17  }
    18  
    19  // NewExoticNATSInstaller return a new exoticNATSInstaller
    20  func NewExoticNATSInstaller(eventBus *v1alpha1.EventBus, logger *zap.SugaredLogger) Installer {
    21  	return &exoticNATSInstaller{
    22  		eventBus: eventBus,
    23  		logger:   logger.Named("exotic-nats"),
    24  	}
    25  }
    26  
    27  func (i *exoticNATSInstaller) Install(ctx context.Context) (*v1alpha1.BusConfig, error) {
    28  	natsObj := i.eventBus.Spec.NATS
    29  	if natsObj == nil || natsObj.Exotic == nil {
    30  		return nil, fmt.Errorf("invalid request")
    31  	}
    32  	i.eventBus.Status.MarkDeployed("Skipped", "Skip deployment because of using exotic config.")
    33  	i.logger.Info("use exotic config")
    34  	busConfig := &v1alpha1.BusConfig{
    35  		NATS: natsObj.Exotic,
    36  	}
    37  	return busConfig, nil
    38  }
    39  
    40  func (i *exoticNATSInstaller) Uninstall(ctx context.Context) error {
    41  	i.logger.Info("nothing to uninstall")
    42  	return nil
    43  }