Skip to content

Commit

Permalink
Extracting common broker spec elements into embeddable struct (opensh…
Browse files Browse the repository at this point in the history
…ift#1841)

* Initial types changes

* Add SharedServiceBrokerSpec to validation/broker_test

* Use Cluster* auth config types.

* Update controller_test

* Update admission tests with embedded fields

* Update admission test auth config types

* Update integration test broker specs

* Update auth type names for int tests

* Update e2e broker specs with shared fields

* Add some missed updates for building

* Update generated files for a successful build

* Add missed items to get tests passing

* Rebased generated code

* Use Common instead of Shared

* Update generated code after rebase

* Update missed rename
  • Loading branch information
Erik Nelson authored and pmorie committed Mar 20, 2018
1 parent 3f8fab6 commit c9b8f60
Show file tree
Hide file tree
Showing 18 changed files with 592 additions and 387 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func setup() (*util.FakeServiceBrokerServer, *servicecatalog.ClusterServiceBroke
url := fbs.Start()
fakeClusterServiceBroker := &servicecatalog.ClusterServiceBroker{
Spec: servicecatalog.ClusterServiceBrokerSpec{
URL: url,
CommonServiceBrokerSpec: servicecatalog.CommonServiceBrokerSpec{
URL: url,
},
},
}

Expand Down
52 changes: 30 additions & 22 deletions pkg/apis/servicecatalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ type ClusterServiceBrokerList struct {
Items []ClusterServiceBroker
}

// ClusterServiceBrokerSpec represents a description of a Broker.
type ClusterServiceBrokerSpec struct {
// URL is the address used to communicate with the ClusterServiceBroker.
// CommonServiceBrokerSpec represents a description of a Broker.
type CommonServiceBrokerSpec struct {
// URL is the address used to communicate with the ServiceBroker.
URL string

// AuthInfo contains the data that the service catalog should use to authenticate
// with the Service Broker.
AuthInfo *ServiceBrokerAuthInfo

// InsecureSkipTLSVerify disables TLS certificate verification when communicating with this Broker.
// This is strongly discouraged. You should use the CABundle instead.
// +optional
Expand All @@ -65,7 +61,7 @@ type ClusterServiceBrokerSpec struct {
CABundle []byte

// RelistBehavior specifies the type of relist behavior the catalog should
// exhibit when relisting ClusterServiceClasses available from a broker.
// exhibit when relisting ServiceClasses available from a broker.
RelistBehavior ServiceBrokerRelistBehavior

// RelistDuration is the frequency by which a controller will relist the
Expand All @@ -83,6 +79,15 @@ type ClusterServiceBrokerSpec struct {
RelistRequests int64
}

// ClusterServiceBrokerSpec represents a description of a Broker.
type ClusterServiceBrokerSpec struct {
CommonServiceBrokerSpec

// AuthInfo contains the data that the service catalog should use to authenticate
// with the Service Broker.
AuthInfo *ClusterServiceBrokerAuthInfo
}

// ServiceBrokerRelistBehavior represents a type of broker relist behavior.
type ServiceBrokerRelistBehavior string

Expand All @@ -96,33 +101,36 @@ const (
ServiceBrokerRelistBehaviorManual ServiceBrokerRelistBehavior = "Manual"
)

// ServiceBrokerAuthInfo is a union type that contains information on one of the authentication methods
// the the service catalog and brokers may support, according to the OpenServiceBroker API
// specification (https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md).
type ServiceBrokerAuthInfo struct {
// Basic provides configuration for basic authentication.
Basic *BasicAuthConfig
// BearerTokenAuthConfig provides configuration to send an opaque value as a bearer token.
// ClusterServiceBrokerAuthInfo is a union type that contains information on
// one of the authentication methods the the service catalog and brokers may
// support, according to the OpenServiceBroker API specification
// (https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md).
type ClusterServiceBrokerAuthInfo struct {
// ClusterBasicAuthConfig provides configuration for basic authentication.
Basic *ClusterBasicAuthConfig
// ClusterBearerTokenAuthConfig provides configuration to send an opaque value as a bearer token.
// The value is referenced from the 'token' field of the given secret. This value should only
// contain the token value and not the `Bearer` scheme.
Bearer *BearerTokenAuthConfig
Bearer *ClusterBearerTokenAuthConfig
}

// BasicAuthConfig provides config for the basic authentication.
type BasicAuthConfig struct {
// ClusterBasicAuthConfig provides config for the basic authentication of
// cluster scoped brokers.
type ClusterBasicAuthConfig struct {
// SecretRef is a reference to a Secret containing information the
// catalog should use to authenticate to this ServiceBroker.
// catalog should use to authenticate to this ClusterServiceBroker.
//
// Required at least one of the fields:
// - Secret.Data["username"] - username used for authentication
// - Secret.Data["password"] - password or token needed for authentication
SecretRef *ObjectReference
}

// BearerTokenAuthConfig provides config for the bearer token authentication.
type BearerTokenAuthConfig struct {
// ClusterBearerTokenAuthConfig provides config for the bearer token
// authentication of cluster scoped brokers.
type ClusterBearerTokenAuthConfig struct {
// SecretRef is a reference to a Secret containing information the
// catalog should use to authenticate to this ServiceBroker.
// catalog should use to authenticate to this ClusterServiceBroker.
//
// Required field:
// - Secret.Data["token"] - bearer token for authentication
Expand Down
48 changes: 28 additions & 20 deletions pkg/apis/servicecatalog/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ type ClusterServiceBrokerList struct {
Items []ClusterServiceBroker `json:"items"`
}

// ClusterServiceBrokerSpec represents a description of a Broker.
type ClusterServiceBrokerSpec struct {
// URL is the address used to communicate with the ClusterServiceBroker.
// CommonServiceBrokerSpec represents a description of a Broker.
type CommonServiceBrokerSpec struct {
// URL is the address used to communicate with the ServiceBroker.
URL string `json:"url"`

// AuthInfo contains the data that the service catalog should use to authenticate
// with the ClusterServiceBroker.
AuthInfo *ServiceBrokerAuthInfo `json:"authInfo,omitempty"`

// InsecureSkipTLSVerify disables TLS certificate verification when communicating with this Broker.
// This is strongly discouraged. You should use the CABundle instead.
// +optional
Expand All @@ -74,7 +70,7 @@ type ClusterServiceBrokerSpec struct {
CABundle []byte `json:"caBundle,omitempty"`

// RelistBehavior specifies the type of relist behavior the catalog should
// exhibit when relisting ClusterServiceClasses available from a broker.
// exhibit when relisting ServiceClasses available from a broker.
// +optional
RelistBehavior ServiceBrokerRelistBehavior `json:"relistBehavior"`

Expand All @@ -94,6 +90,15 @@ type ClusterServiceBrokerSpec struct {
RelistRequests int64 `json:"relistRequests"`
}

// ClusterServiceBrokerSpec represents a description of a Broker.
type ClusterServiceBrokerSpec struct {
CommonServiceBrokerSpec `json:",inline"`

// AuthInfo contains the data that the service catalog should use to authenticate
// with the ClusterServiceBroker.
AuthInfo *ClusterServiceBrokerAuthInfo `json:"authInfo,omitempty"`
}

// ServiceBrokerRelistBehavior represents a type of broker relist behavior.
type ServiceBrokerRelistBehavior string

Expand All @@ -107,20 +112,22 @@ const (
ServiceBrokerRelistBehaviorManual ServiceBrokerRelistBehavior = "Manual"
)

// ServiceBrokerAuthInfo is a union type that contains information on one of the authentication methods
// the the service catalog and brokers may support, according to the OpenServiceBroker API
// specification (https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md).
type ServiceBrokerAuthInfo struct {
// Basic provides configuration for basic authentication.
Basic *BasicAuthConfig `json:"basic,omitempty"`
// BearerTokenAuthConfig provides configuration to send an opaque value as a bearer token.
// ClusterServiceBrokerAuthInfo is a union type that contains information on
// one of the authentication methods the the service catalog and brokers may
// support, according to the OpenServiceBroker API specification
// (https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md).
type ClusterServiceBrokerAuthInfo struct {
// ClusterBasicAuthConfigprovides configuration for basic authentication.
Basic *ClusterBasicAuthConfig `json:"basic,omitempty"`
// ClusterBearerTokenAuthConfig provides configuration to send an opaque value as a bearer token.
// The value is referenced from the 'token' field of the given secret. This value should only
// contain the token value and not the `Bearer` scheme.
Bearer *BearerTokenAuthConfig `json:"bearer,omitempty"`
Bearer *ClusterBearerTokenAuthConfig `json:"bearer,omitempty"`
}

// BasicAuthConfig provides config for the basic authentication.
type BasicAuthConfig struct {
// ClusterBasicAuthConfig provides config for the basic authentication of
// cluster scoped brokers.
type ClusterBasicAuthConfig struct {
// SecretRef is a reference to a Secret containing information the
// catalog should use to authenticate to this ServiceBroker.
//
Expand All @@ -130,8 +137,9 @@ type BasicAuthConfig struct {
SecretRef *ObjectReference `json:"secretRef,omitempty"`
}

// BearerTokenAuthConfig provides config for the bearer token authentication.
type BearerTokenAuthConfig struct {
// ClusterBearerTokenAuthConfig provides config for the bearer token
// authentication of cluster scoped brokers.
type ClusterBearerTokenAuthConfig struct {
// SecretRef is a reference to a Secret containing information the
// catalog should use to authenticate to this ServiceBroker.
//
Expand Down
Loading

0 comments on commit c9b8f60

Please sign in to comment.