forked from argoproj/argo-events
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* webhook validations Signed-off-by: Bilal Bakht Ahmad <tringingly@gmail.com> * add Exotic Kafka installer * Change order of EventBus reconcilation Calling client.Status().Update() before calling client.Update() persists the status for exotic evnetbuses, otherwise the status is not perisisted. Signed-off-by: David Farr <david_farr@intuit.com> * requeue reconciler Signed-off-by: Bilal Bakht Ahmad <tringingly@gmail.com> * Make additional copy of obj to update eb status Signed-off-by: David Farr <david_farr@intuit.com> * oxford comma Co-authored-by: David Farr <david_farr@intuit.com> * stylistic change Signed-off-by: Bilal Bakht Ahmad <tringingly@gmail.com> Signed-off-by: Bilal Bakht Ahmad <tringingly@gmail.com> Signed-off-by: David Farr <david_farr@intuit.com> Co-authored-by: David Farr <david_farr@intuit.com>
- Loading branch information
Showing
7 changed files
with
150 additions
and
5 deletions.
There are no files selected for viewing
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" | ||
) | ||
|
||
// exoticKafkaInstaller is an inalleration implementation of exotic kafka config. | ||
type exoticKafkaInstaller struct { | ||
eventBus *v1alpha1.EventBus | ||
|
||
logger *zap.SugaredLogger | ||
} | ||
|
||
// NewExoticKafkaInstaller return a new exoticKafkaInstaller | ||
func NewExoticKafkaInstaller(eventBus *v1alpha1.EventBus, logger *zap.SugaredLogger) Installer { | ||
return &exoticKafkaInstaller{ | ||
eventBus: eventBus, | ||
logger: logger.Named("exotic-kafka"), | ||
} | ||
} | ||
|
||
func (i *exoticKafkaInstaller) Install(ctx context.Context) (*v1alpha1.BusConfig, error) { | ||
kafkaObj := i.eventBus.Spec.Kafka | ||
if kafkaObj == nil || kafkaObj.Exotic == 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{ | ||
Kafka: kafkaObj.Exotic, | ||
} | ||
return busConfig, nil | ||
} | ||
|
||
func (i *exoticKafkaInstaller) 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,55 @@ | ||
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" | ||
) | ||
|
||
const ( | ||
testExoticKafkaName = "test-kafka" | ||
testExoticKafkaURL = "kafka:9092" | ||
) | ||
|
||
var ( | ||
testKafkaExoticBus = &v1alpha1.EventBus{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: v1alpha1.SchemeGroupVersion.String(), | ||
Kind: "EventBus", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: testNamespace, | ||
Name: testExoticKafkaName, | ||
}, | ||
Spec: v1alpha1.EventBusSpec{ | ||
Kafka: &v1alpha1.KafkaBus{ | ||
Exotic: &v1alpha1.KafkaConfig{ | ||
URL: testExoticKafkaURL, | ||
}, | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
func TestInstallationKafkaExotic(t *testing.T) { | ||
t.Run("installation with exotic kafka config", func(t *testing.T) { | ||
installer := NewExoticKafkaInstaller(testKafkaExoticBus, logging.NewArgoEventsLogger()) | ||
conf, err := installer.Install(context.TODO()) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, conf.Kafka) | ||
assert.Equal(t, conf.Kafka.URL, testExoticKafkaURL) | ||
}) | ||
} | ||
|
||
func TestUninstallationKafkaExotic(t *testing.T) { | ||
t.Run("uninstallation with exotic kafka config", func(t *testing.T) { | ||
installer := NewExoticKafkaInstaller(testKafkaExoticBus, 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