Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1201615 - Give swagger the correct base URL #1780

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/cmd/server/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string

// MasterPublicURL is how clients can access the OpenShift API server
MasterPublicURL string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add validation to ensure the URL is present (required for swagger), well-formed, and matches any other MasterPublicURLs that may be present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and for the next question: each stanza has its own copy to keep it contained if we decide to allow starting these components separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liggitt PublicURL to match the AssetConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't validate well formedness of the others.

Also, why do they have to match?

On Apr 17, 2015, at 8:12 AM, David Eads notifications@github.com wrote:

In pkg/cmd/server/api/types.go:

@@ -47,10 +47,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string

  • // MasterPublicURL is how clients can access the OpenShift API server
  • MasterPublicURL string
    Add validation to ensure the URL is present (required for swagger), well-formed, and matches any other MasterPublicURLs that may be present.


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MasterConfig has no effective stanza. What would you suggest.

On Apr 17, 2015, at 8:14 AM, David Eads notifications@github.com wrote:

In pkg/cmd/server/api/types.go:

@@ -47,10 +47,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string

  • // MasterPublicURL is how clients can access the OpenShift API server
  • MasterPublicURL string
    Oh, and for the next question: each stanza has its own copy to keep it contained if we decide to allow starting these components separately.


Reply to this email directly or view it on GitHub.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublicURL to match the AssetConfig?

I can't decide whether I like everything using the same names to refer to the same things, or removing prefixes based on context. I think I lean toward the same names... but I don't feel that strongly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same name. Less mental struggle.

----- Original Message -----

@@ -47,10 +47,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string

  • // MasterPublicURL is how clients can access the OpenShift API server
  • MasterPublicURL string

PublicURL to match the AssetConfig?

I can't decide whether I like everything using the same names to refer to the
same things, or removing prefixes based on context. I think I lean toward
the same names... but I don't feel that strongly


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1780/files#r28603240

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not validating those URLs today. Why?

----- Original Message -----

We don't validate well formedness of the others.

Also, why do they have to match?

On Apr 17, 2015, at 8:12 AM, David Eads notifications@github.com wrote:

In pkg/cmd/server/api/types.go:

@@ -47,10 +47,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string

  • // MasterPublicURL is how clients can access the OpenShift API server
  • MasterPublicURL string
    Add validation to ensure the URL is present (required for swagger),
    well-formed, and matches any other MasterPublicURLs that may be present.


Reply to this email directly or view it on GitHub.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not validating those URLs today. Why?

Oversight?


// EtcdStorageConfig contains information about how API resources are
// stored in Etcd. These values are only relevant when etcd is the
// backing store for the cluster.
EtcdStorageConfig EtcdStorageConfig

// EtcdClientInfo contains information about how to connect to etcd
EtcdClientInfo EtcdConnectionInfo

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/server/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ type MasterConfig struct {
// CORSAllowedOrigins
CORSAllowedOrigins []string `json:"corsAllowedOrigins"`

// MasterPublicURL is how clients can access the OpenShift API server
MasterPublicURL string `json:"masterPublicURL"`

// EtcdStorageConfig contains information about how API resources are
// stored in Etcd. These values are only relevant when etcd is the
// backing store for the cluster.
EtcdStorageConfig EtcdStorageConfig `json:"etcdStorageConfig"`

// EtcdClientInfo contains information about how to connect to etcd
EtcdClientInfo EtcdConnectionInfo `json:"etcdClientInfo"`
// KubeletClientInfo contains information about how to connect to kubelets
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/server/api/validation/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
func ValidateMasterConfig(config *api.MasterConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}

if _, urlErrs := ValidateURL(config.MasterPublicURL, "masterPublicURL"); len(urlErrs) > 0 {
allErrs = append(allErrs, urlErrs...)
}

if config.AssetConfig != nil {
allErrs = append(allErrs, ValidateAssetConfig(config.AssetConfig).Prefix("assetConfig")...)
colocated := config.AssetConfig.ServingInfo.BindAddress == config.ServingInfo.BindAddress
Expand Down Expand Up @@ -115,6 +119,10 @@ func ValidateAssetConfig(config *api.AssetConfig) fielderrors.ValidationErrorLis
}
}

if _, urlErrs := ValidateURL(config.MasterPublicURL, "masterPublicURL"); len(urlErrs) > 0 {
allErrs = append(allErrs, urlErrs...)
}

return allErrs
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/server/api/validation/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func ValidateOAuthConfig(config *api.OAuthConfig) fielderrors.ValidationErrorLis
allErrs = append(allErrs, fielderrors.NewFieldRequired("masterURL"))
}

if len(config.MasterPublicURL) == 0 {
allErrs = append(allErrs, fielderrors.NewFieldRequired("masterPublicURL"))
if _, urlErrs := ValidateURL(config.MasterPublicURL, "masterPublicURL"); len(urlErrs) > 0 {
allErrs = append(allErrs, urlErrs...)
}

if len(config.AssetPublicURL) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/origin/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (c *AuthConfig) InstallAPI(container *restful.Container) []string {

return []string{
fmt.Sprintf("Started OAuth2 API at %%s%s", OpenShiftOAuthAPIPrefix),
fmt.Sprintf("Started login server at %%s%s", OpenShiftLoginPrefix),
fmt.Sprintf("Started Login endpoint at %%s%s", OpenShiftLoginPrefix),
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/server/origin/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ func (c *MasterConfig) Run(protected []APIInstaller, unprotected []APIInstaller)

// install swagger
swaggerConfig := swagger.Config{
WebServices: append(safe.RegisteredWebServices(), open.RegisteredWebServices()...),
ApiPath: swaggerAPIPrefix,
WebServicesUrl: c.Options.MasterPublicURL,
WebServices: append(safe.RegisteredWebServices(), open.RegisteredWebServices()...),
ApiPath: swaggerAPIPrefix,
}
// log nothing from swagger
swagger.LogInfo = func(format string, v ...interface{}) {}
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/server/start/master_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig
BindAddress: args.ListenArg.ListenAddr.URL.Host,
},
CORSAllowedOrigins: corsAllowedOrigins.List(),
MasterPublicURL: masterPublicAddr.String(),

KubernetesMasterConfig: kubernetesMasterConfig,
EtcdConfig: etcdConfig,
Expand Down