Skip to content

Commit

Permalink
Services and Plans APIs (Peripli#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirilKabakchiev authored and dzahariev committed Nov 26, 2018
1 parent e04524b commit c3ab19d
Show file tree
Hide file tree
Showing 50 changed files with 3,154 additions and 342 deletions.
7 changes: 4 additions & 3 deletions Gopkg.lock

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

8 changes: 8 additions & 0 deletions Gopkg.toml
Expand Up @@ -93,6 +93,14 @@
name = "github.com/DATA-DOG/go-sqlmock"
revision = "852fc940e4b9b895dc144b88ee8f6e39228127b0"

[[constraint]]
name = "github.com/tidwall/gjson"
version = "v1.1.3"

[[constraint]]
name = "github.com/tidwall/sjson"
version = "v1.0.2"

# Refer to issue https://github.com/golang/dep/issues/1799
[[override]]
name = "gopkg.in/fsnotify.v1"
Expand Down
27 changes: 17 additions & 10 deletions api/api.go
Expand Up @@ -23,12 +23,16 @@ import (
"net/http"

"github.com/Peripli/service-manager/api/broker"
"github.com/Peripli/service-manager/api/platform"

"github.com/Peripli/service-manager/api/service_offering"
"github.com/Peripli/service-manager/api/service_plan"

"github.com/Peripli/service-manager/api/filters"
"github.com/Peripli/service-manager/api/filters/authn/basic"
"github.com/Peripli/service-manager/api/filters/authn/oauth"
"github.com/Peripli/service-manager/api/info"
"github.com/Peripli/service-manager/api/osb"
"github.com/Peripli/service-manager/api/platform"
"github.com/Peripli/service-manager/pkg/health"
"github.com/Peripli/service-manager/pkg/security"
secfilters "github.com/Peripli/service-manager/pkg/security/filters"
Expand Down Expand Up @@ -65,7 +69,6 @@ func DefaultSettings() *Settings {
ClientID: "",
SkipSSLValidation: false,
}

}

// Validate validates the API settings
Expand All @@ -77,41 +80,45 @@ func (s *Settings) Validate() error {
}

// New returns the minimum set of REST APIs needed for the Service Manager
func New(ctx context.Context, store storage.Storage, settings *Settings, encrypter security.Encrypter) (*web.API, error) {
func New(ctx context.Context, repository storage.Repository, settings *Settings, encrypter security.Encrypter) (*web.API, error) {
bearerAuthnFilter, err := oauth.NewFilter(ctx, settings.TokenIssuerURL, settings.ClientID)
if err != nil {
return nil, err
}
healthRegistry := health.NewDefaultRegistry()
healthRegistry.AddHealthIndicator(&storage.HealthIndicator{Storage: store})
return &web.API{
// Default controllers - more filters can be registered using the relevant API methods
Controllers: []web.Controller{
&broker.Controller{
BrokerStorage: store.Broker(),
Repository: repository,
OSBClientCreateFunc: newOSBClient(settings.SkipSSLValidation),
Encrypter: encrypter,
},
&platform.Controller{
PlatformStorage: store.Platform(),
PlatformStorage: repository.Platform(),
Encrypter: encrypter,
},
&service_offering.Controller{
ServiceOfferingStorage: repository.ServiceOffering(),
},
&service_plan.Controller{
ServicePlanStorage: repository.ServicePlan(),
},
&info.Controller{
TokenIssuer: settings.TokenIssuerURL,
},
osb.NewController(&osb.StorageBrokerFetcher{
BrokerStorage: store.Broker(),
BrokerStorage: repository.Broker(),
Encrypter: encrypter,
}, http.DefaultTransport),
},
// Default filters - more filters can be registered using the relevant API methods
Filters: []web.Filter{
&filters.Logging{},
basic.NewFilter(store.Credentials(), encrypter),
basic.NewFilter(repository.Credentials(), encrypter),
bearerAuthnFilter,
secfilters.NewRequiredAuthnFilter(),
},
Registry: healthRegistry,
Registry: health.NewDefaultRegistry(),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion api/broker/broker.go
Expand Up @@ -45,7 +45,7 @@ func (c *Controller) Routes() []web.Route {
Method: http.MethodGet,
Path: web.BrokersURL,
},
Handler: c.getAllBrokers,
Handler: c.listBrokers,
},
{
Endpoint: web.Endpoint{
Expand Down

0 comments on commit c3ab19d

Please sign in to comment.