-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eventbus): add exotic jetstream support (#2878)
Signed-off-by: gokulav137 <gokulav999@gmail.com> Signed-off-by: gokulav137 <52277763+gokulav137@users.noreply.github.com>
- Loading branch information
1 parent
5b7a0f1
commit 79ea8a6
Showing
22 changed files
with
460 additions
and
132 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package installer | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" | ||
) | ||
|
||
// exoticJetStreamInstaller is an inalleration implementation of exotic jetstream config. | ||
type exoticJetStreamInstaller struct { | ||
eventBus *v1alpha1.EventBus | ||
|
||
logger *zap.SugaredLogger | ||
} | ||
|
||
// NewExoticJetStreamInstaller return a new exoticJetStreamInstaller | ||
func NewExoticJetStreamInstaller(eventBus *v1alpha1.EventBus, logger *zap.SugaredLogger) Installer { | ||
return &exoticJetStreamInstaller{ | ||
eventBus: eventBus, | ||
logger: logger.Named("exotic-jetstream"), | ||
} | ||
} | ||
|
||
func (i *exoticJetStreamInstaller) Install(ctx context.Context) (*v1alpha1.BusConfig, error) { | ||
JetStreamObj := i.eventBus.Spec.JetStreamExotic | ||
if JetStreamObj == nil { | ||
return nil, fmt.Errorf("invalid request") | ||
} | ||
i.eventBus.Status.MarkDeployed("Skipped", "Skip deployment because of using exotic config.") | ||
i.logger.Info("use exotic config") | ||
busConfig := &v1alpha1.BusConfig{ | ||
JetStream: JetStreamObj, | ||
} | ||
return busConfig, nil | ||
} | ||
|
||
func (i *exoticJetStreamInstaller) Uninstall(ctx context.Context) error { | ||
i.logger.Info("nothing to uninstall") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package installer | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/argoproj/argo-events/common/logging" | ||
"github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" | ||
) | ||
|
||
var ( | ||
testJSExoticURL = "nats://nats:4222" | ||
|
||
testJSExoticBus = &v1alpha1.EventBus{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: v1alpha1.SchemeGroupVersion.String(), | ||
Kind: "EventBus", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: testNamespace, | ||
Name: testExoticName, | ||
}, | ||
Spec: v1alpha1.EventBusSpec{ | ||
JetStreamExotic: &v1alpha1.JetStreamConfig{ | ||
URL: testJSExoticURL, | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
func TestInstallationJSExotic(t *testing.T) { | ||
t.Run("installation with exotic jetstream config", func(t *testing.T) { | ||
installer := NewExoticJetStreamInstaller(testJSExoticBus, logging.NewArgoEventsLogger()) | ||
conf, err := installer.Install(context.TODO()) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, conf.JetStream) | ||
assert.Equal(t, conf.JetStream.URL, testJSExoticURL) | ||
}) | ||
} | ||
|
||
func TestUninstallationJSExotic(t *testing.T) { | ||
t.Run("uninstallation with exotic jetstream config", func(t *testing.T) { | ||
installer := NewExoticJetStreamInstaller(testJSExoticBus, logging.NewArgoEventsLogger()) | ||
err := installer.Uninstall(context.TODO()) | ||
assert.NoError(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.