Skip to content

Commit

Permalink
Delete a redundant arg and optimize some codes in the
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanqiang Miao committed Aug 17, 2016
1 parent 0eb9cf4 commit 04e9fad
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pkg/cmd/admin/registry/registry.go
Expand Up @@ -295,21 +295,16 @@ func (opts *RegistryOptions) RunCmdRegistry() error {
if err := restclient.LoadTLSFiles(config); err != nil {
return fmt.Errorf("registry does not exist; the provided credentials %q could not load certificate info: %v", opts.Config.Credentials, err)
}
insecure := "false"
if config.Insecure {
insecure = "true"
} else {
if len(config.KeyData) == 0 || len(config.CertData) == 0 {
return fmt.Errorf("registry does not exist; the provided credentials %q are missing the client certificate and/or key", opts.Config.Credentials)
}
if !config.Insecure && (len(config.KeyData) == 0 || len(config.CertData) == 0) {
return fmt.Errorf("registry does not exist; the provided credentials %q are missing the client certificate and/or key", opts.Config.Credentials)
}

secretEnv = app.Environment{
"OPENSHIFT_MASTER": config.Host,
"OPENSHIFT_CA_DATA": string(config.CAData),
"OPENSHIFT_KEY_DATA": string(config.KeyData),
"OPENSHIFT_CERT_DATA": string(config.CertData),
"OPENSHIFT_INSECURE": insecure,
"OPENSHIFT_INSECURE": fmt.Sprintf("%v", config.Insecure),
}
}

Expand Down Expand Up @@ -341,7 +336,7 @@ func (opts *RegistryOptions) RunCmdRegistry() error {
env["REGISTRY_HTTP_ADDR"] = fmt.Sprintf(":%d", healthzPort)
env["REGISTRY_HTTP_NET"] = "tcp"
}
secrets, volumes, mounts, extraEnv, tls, err := generateSecretsConfig(opts.Config, opts.namespace, servingCert, servingKey)
secrets, volumes, mounts, extraEnv, tls, err := generateSecretsConfig(opts.Config, servingCert, servingKey)
if err != nil {
return err
}
Expand Down Expand Up @@ -516,7 +511,7 @@ func generateReadinessProbeConfig(port int, https bool) *kapi.Probe {
// as the TLS serving cert that are necessary for the registry container.
// Runs true if the registry should be served over TLS.
func generateSecretsConfig(
cfg *RegistryConfig, namespace string, defaultCrt, defaultKey []byte,
cfg *RegistryConfig, defaultCrt, defaultKey []byte,
) ([]*kapi.Secret, []kapi.Volume, []kapi.VolumeMount, app.Environment, bool, error) {
var secrets []*kapi.Secret
var volumes []kapi.Volume
Expand Down

0 comments on commit 04e9fad

Please sign in to comment.