Skip to content

Commit

Permalink
Eventing mesh dashboard delivery [component] (#6988)
Browse files Browse the repository at this point in the history
  • Loading branch information
montaro authored Feb 6, 2020
1 parent 588ee67 commit 2bed6bc
Show file tree
Hide file tree
Showing 10 changed files with 360 additions and 95 deletions.
131 changes: 69 additions & 62 deletions components/application-broker/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions components/application-broker/cmd/broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
appCli "github.com/kyma-project/kyma/components/application-operator/pkg/client/clientset/versioned"
appInformer "github.com/kyma-project/kyma/components/application-operator/pkg/client/informers/externalversions"
"github.com/sirupsen/logrus"
istioCli "istio.io/client-go/pkg/clientset/versioned"
v1 "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
Expand Down Expand Up @@ -67,9 +68,12 @@ func main() {
eventingClient, err := eventingCli.NewForConfig(k8sConfig)
fatalOnError(err)
knClient := knative.NewClient(eventingClient, k8sClient)
istioClient, err := istioCli.NewForConfig(k8sConfig)
fatalOnError(err)

livenessCheckStatus := broker.LivenessCheckStatus{Succeeded: false}
srv := SetupServerAndRunControllers(cfg, log, stopCh, k8sClient, scClientSet, appClient, mClient, knClient, &livenessCheckStatus)
srv := SetupServerAndRunControllers(cfg, log, stopCh, k8sClient, scClientSet, appClient, mClient, knClient,
istioClient, &livenessCheckStatus)

fatalOnError(srv.Run(ctx, fmt.Sprintf(":%d", cfg.Port)))
}
Expand All @@ -81,6 +85,7 @@ func SetupServerAndRunControllers(cfg *config.Config, log *logrus.Entry, stopCh
appClient appCli.Interface,
mClient mappingCli.Interface,
knClient knative.Client,
istioClient istioCli.Interface,
livenessCheckStatus *broker.LivenessCheckStatus,
) *broker.Server {

Expand Down Expand Up @@ -136,7 +141,7 @@ func SetupServerAndRunControllers(cfg *config.Config, log *logrus.Entry, stopCh
srv := broker.New(sFact.Application(), sFact.Instance(), sFact.InstanceOperation(), accessChecker,
mClient.ApplicationconnectorV1alpha1(), siFacade,
mInformersGroup.ApplicationMappings().Lister(), brokerService,
&mClient, knClient, log, livenessCheckStatus)
&mClient, knClient, &istioClient, log, livenessCheckStatus)

// start informers
scInformerFactory.Start(stopCh)
Expand Down
6 changes: 4 additions & 2 deletions components/application-broker/cmd/broker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func newTestSuite(t *testing.T) *testSuite {
k8sClientSet := k8sfake.NewSimpleClientset()
scClientSet := scfake.NewSimpleClientset()
appClient := appfake.NewSimpleClientset()
knClient := knative.NewClient(bt.NewFakeClients())
knCli, k8sCli, istioClient := bt.NewFakeClients()
knClient := knative.NewClient(knCli, k8sCli)

k8sClientSet.CoreV1().Namespaces().Create(&corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -161,7 +162,8 @@ func newTestSuite(t *testing.T) *testSuite {

livenessCheckStatus := broker.LivenessCheckStatus{Succeeded: false}

srv := SetupServerAndRunControllers(&cfg, log.Logger, stopCh, k8sClientSet, scClientSet, appClient, abClientSet, knClient, &livenessCheckStatus)
srv := SetupServerAndRunControllers(&cfg, log.Logger, stopCh, k8sClientSet, scClientSet, appClient, abClientSet,
knClient, istioClient, &livenessCheckStatus)
server := httptest.NewServer(srv.CreateHandler())

osbClient, err := newOSBClient(fmt.Sprintf("%s/%s", server.URL, namespace))
Expand Down
9 changes: 7 additions & 2 deletions components/application-broker/internal/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/kyma-project/kyma/components/application-broker/pkg/client/clientset/versioned/typed/applicationconnector/v1alpha1"
listers "github.com/kyma-project/kyma/components/application-broker/pkg/client/listers/applicationconnector/v1alpha1"
"github.com/kyma-project/kyma/components/application-broker/platform/idprovider"

istioCli "istio.io/client-go/pkg/clientset/versioned"
)

//go:generate mockery -name=instanceStorage -output=automock -outpkg=automock -case=underscore
Expand Down Expand Up @@ -111,6 +113,7 @@ func New(applicationFinder appFinder,
brokerService *NsBrokerService,
mClient *mappingCli.Interface,
knClient knative.Client,
istioClient *istioCli.Interface,
log *logrus.Entry,
livenessCheckStatus *LivenessCheckStatus,
) *Server {
Expand All @@ -133,8 +136,10 @@ func New(applicationFinder appFinder,
conv: &appToServiceConverter{},
appEnabledChecker: enabledChecker,
},
provisioner: NewProvisioner(instStorage, instStorage, stateService, opStorage, opStorage, accessChecker, applicationFinder, serviceInstanceGetter, eaClient, knClient, instStorage, idp, log),
deprovisioner: NewDeprovisioner(instStorage, stateService, opStorage, opStorage, idp, applicationFinder, knClient, log),
provisioner: NewProvisioner(instStorage, instStorage, stateService, opStorage, opStorage, accessChecker,
applicationFinder, serviceInstanceGetter, eaClient, knClient, *istioClient, instStorage, idp, log),
deprovisioner: NewDeprovisioner(instStorage, stateService, opStorage, opStorage, idp, applicationFinder,
knClient, log),
binder: &bindService{
appSvcFinder: applicationFinder,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ func TestDoDeprovision(t *testing.T) {
fixDeprovisionSucceeded(),
).Return(nil).Once()

knCli, k8sCli := bt.NewFakeClients(tc.initialObjs...)
/* The third return value is an istio client, which is ignored in case of deprovisioning because it's used
only to create istio policy in case of provisioning in order to enable Prometheus scraping which is required
even in case of deprovisioning
*/
knCli, k8sCli, _ := bt.NewFakeClients(tc.initialObjs...)

dpr := NewDeprovisioner(
nil,
Expand All @@ -260,13 +264,14 @@ func TestDoDeprovision(t *testing.T) {
}

func newDeprovisionServiceTestSuite(t *testing.T) *deprovisionServiceTestSuite {
knCli, k8sCli, _ := bt.NewFakeClients()
return &deprovisionServiceTestSuite{
t: t,
mockInstanceStateGetter: &automock.InstanceStateGetter{},
mockInstanceStorage: &automock.InstanceStorage{},
mockOperationStorage: &automock.OperationStorage{},
mockAppFinder: &automock.AppFinder{},
client: knative.NewClient(bt.NewFakeClients()),
client: knative.NewClient(knCli, k8sCli),
}
}

Expand Down
Loading

0 comments on commit 2bed6bc

Please sign in to comment.