Skip to content

Commit 6a67b55

Browse files
committed
Revert "pkg/registry: Login option for passing TLS config in memory"
Signed-off-by: Scott Rigby <scott@r6by.com>
1 parent 65f5284 commit 6a67b55

File tree

2 files changed

+4
-44
lines changed

2 files changed

+4
-44
lines changed

pkg/registry/client.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func LoginOptPlainText(isPlainText bool) LoginOption {
357357
}
358358
}
359359

360-
func ensureTLSConfig(client *auth.Client, setConfig *tls.Config) (*tls.Config, error) {
360+
func ensureTLSConfig(client *auth.Client) (*tls.Config, error) {
361361
var transport *http.Transport
362362

363363
switch t := client.Client.Transport.(type) {
@@ -386,10 +386,7 @@ func ensureTLSConfig(client *auth.Client, setConfig *tls.Config) (*tls.Config, e
386386
return nil, fmt.Errorf("unable to access TLS client configuration, the provided HTTP Transport is not supported, given: %T", client.Client.Transport)
387387
}
388388

389-
switch {
390-
case setConfig != nil:
391-
transport.TLSClientConfig = setConfig
392-
case transport.TLSClientConfig == nil:
389+
if transport.TLSClientConfig == nil {
393390
transport.TLSClientConfig = &tls.Config{}
394391
}
395392

@@ -399,7 +396,7 @@ func ensureTLSConfig(client *auth.Client, setConfig *tls.Config) (*tls.Config, e
399396
// LoginOptInsecure returns a function that sets the insecure setting on login
400397
func LoginOptInsecure(insecure bool) LoginOption {
401398
return func(o *loginOperation) {
402-
tlsConfig, err := ensureTLSConfig(o.client.authorizer, nil)
399+
tlsConfig, err := ensureTLSConfig(o.client.authorizer)
403400

404401
if err != nil {
405402
panic(err)
@@ -415,7 +412,7 @@ func LoginOptTLSClientConfig(certFile, keyFile, caFile string) LoginOption {
415412
if (certFile == "" || keyFile == "") && caFile == "" {
416413
return
417414
}
418-
tlsConfig, err := ensureTLSConfig(o.client.authorizer, nil)
415+
tlsConfig, err := ensureTLSConfig(o.client.authorizer)
419416
if err != nil {
420417
panic(err)
421418
}
@@ -442,17 +439,6 @@ func LoginOptTLSClientConfig(certFile, keyFile, caFile string) LoginOption {
442439
}
443440
}
444441

445-
// LoginOptTLSClientConfigFromConfig returns a function that sets the TLS settings on login
446-
// receiving the configuration in memory rather than from files.
447-
func LoginOptTLSClientConfigFromConfig(conf *tls.Config) LoginOption {
448-
return func(o *loginOperation) {
449-
_, err := ensureTLSConfig(o.client.authorizer, conf)
450-
if err != nil {
451-
panic(err)
452-
}
453-
}
454-
}
455-
456442
type (
457443
// LogoutOption allows specifying various settings on logout
458444
LogoutOption func(*logoutOperation)

pkg/registry/client_tls_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package registry
1818

1919
import (
20-
"crypto/tls"
21-
"crypto/x509"
2220
"os"
2321
"testing"
2422

@@ -54,30 +52,6 @@ func (suite *TLSRegistryClientTestSuite) Test_0_Login() {
5452
suite.Nil(err, "no error logging into registry with good credentials")
5553
}
5654

57-
func (suite *TLSRegistryClientTestSuite) Test_1_Login() {
58-
err := suite.RegistryClient.Login(suite.DockerRegistryHost,
59-
LoginOptBasicAuth("badverybad", "ohsobad"),
60-
LoginOptTLSClientConfigFromConfig(&tls.Config{}))
61-
suite.NotNil(err, "error logging into registry with bad credentials")
62-
63-
// Create a *tls.Config from tlsCert, tlsKey, and tlsCA.
64-
cert, err := tls.LoadX509KeyPair(tlsCert, tlsKey)
65-
suite.Nil(err, "error loading x509 key pair")
66-
rootCAs := x509.NewCertPool()
67-
caCert, err := os.ReadFile(tlsCA)
68-
suite.Nil(err, "error reading CA certificate")
69-
rootCAs.AppendCertsFromPEM(caCert)
70-
conf := &tls.Config{
71-
Certificates: []tls.Certificate{cert},
72-
RootCAs: rootCAs,
73-
}
74-
75-
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
76-
LoginOptBasicAuth(testUsername, testPassword),
77-
LoginOptTLSClientConfigFromConfig(conf))
78-
suite.Nil(err, "no error logging into registry with good credentials")
79-
}
80-
8155
func (suite *TLSRegistryClientTestSuite) Test_1_Push() {
8256
testPush(&suite.TestSuite)
8357
}

0 commit comments

Comments
 (0)