Skip to content

Commit

Permalink
chore: standardizes on term "skip-tls-verify" when disabling cert val…
Browse files Browse the repository at this point in the history
…idation

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Nov 7, 2022
1 parent a475951 commit 3d7b1fd
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Example:
registries:
- prefix: "localhost:5001/test"
location: localhost:5001
skipTLS: false
skipTLSVerify: false
plainHTTP: true
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/client/commands/build_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (o *BuildCollectionOptions) Run(ctx context.Context) error {
}

var clientOpts = []orasclient.ClientOption{
orasclient.SkipTLSVerify(o.Insecure),
orasclient.SkipTLSVerify(o.SkipTLSVerify),
orasclient.WithAuthConfigs(o.Configs),
orasclient.WithPlainHTTP(o.PlainHTTP),
orasclient.WithRegistryConfig(o.RegistryConfig),
Expand Down
6 changes: 3 additions & 3 deletions cmd/client/commands/options/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (

// Remote describes remote configuration options that can be set.
type Remote struct {
Insecure bool
SkipTLSVerify bool
PlainHTTP bool
RegistryConfig registryclient.RegistryConfig
}

// BindFlags binds options from a flag set to Remote options.
func (o *Remote) BindFlags(fs *pflag.FlagSet) {
fs.BoolVarP(&o.Insecure, "insecure", "", o.Insecure, "allow connections to registries SSL registry without certs")
fs.BoolVarP(&o.PlainHTTP, "plain-http", "", o.PlainHTTP, "use plain http and not https when contacting registries")
fs.BoolVar(&o.SkipTLSVerify, "skip-tls-verify", o.SkipTLSVerify, "disable TLS certificate verification when contacting registries")
fs.BoolVar(&o.PlainHTTP, "plain-http", o.PlainHTTP, "use plain http and not https when contacting registries")
}

// LoadRegistryConfig loads the registry config from disk.
Expand Down
2 changes: 1 addition & 1 deletion cmd/client/commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (o *PullOptions) Run(ctx context.Context) error {
}

var clientOpts = []orasclient.ClientOption{
orasclient.SkipTLSVerify(o.Insecure),
orasclient.SkipTLSVerify(o.SkipTLSVerify),
orasclient.WithAuthConfigs(o.Configs),
orasclient.WithPlainHTTP(o.PlainHTTP),
orasclient.WithCache(cache),
Expand Down
2 changes: 1 addition & 1 deletion cmd/client/commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (o *PushOptions) Run(ctx context.Context) error {
}

client, err := orasclient.NewClient(
orasclient.SkipTLSVerify(o.Insecure),
orasclient.SkipTLSVerify(o.SkipTLSVerify),
orasclient.WithAuthConfigs(o.Configs),
orasclient.WithPlainHTTP(o.PlainHTTP),
orasclient.WithRegistryConfig(o.RegistryConfig),
Expand Down
4 changes: 2 additions & 2 deletions cmd/client/commands/sigstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func signCollection(_ context.Context, reference string, authConfigs []string, r
regopts := cosignopts.RegistryOptions{
Keychain: authn.DefaultKeychain,
}
if remoteOpts.PlainHTTP || remoteOpts.Insecure {
if remoteOpts.PlainHTTP || remoteOpts.SkipTLSVerify {
regopts.AllowInsecure = true
}

Expand Down Expand Up @@ -70,7 +70,7 @@ func verifyCollection(ctx context.Context, reference string, authConfigs []strin
Keychain: authn.DefaultKeychain,
}

if remoteOpts.PlainHTTP || remoteOpts.Insecure {
if remoteOpts.PlainHTTP || remoteOpts.SkipTLSVerify {
regopts.AllowInsecure = true
}

Expand Down
8 changes: 4 additions & 4 deletions registryclient/orasclient/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ClientConfig struct {
configs []string
credFn func(context.Context, string) (auth.Credential, error)
plainHTTP bool
insecure bool
skipTLSVerify bool
cache content.Store
copyOpts oras.CopyOptions
attributes model.Matcher
Expand Down Expand Up @@ -64,7 +64,7 @@ func NewClient(options ...ClientOption) (registryclient.Client, error) {

client.authCache = auth.NewCache()
client.plainHTTP = config.plainHTTP
client.insecure = config.insecure
client.skipTLSVerify = config.skipTLSVerify
client.copyOpts = config.copyOpts
client.destroy = destroy
client.cache = config.cache
Expand Down Expand Up @@ -120,9 +120,9 @@ func WithRegistryConfig(registryConf registryclient.RegistryConfig) ClientOption
}

// SkipTLSVerify disables TLS certificate checking.
func SkipTLSVerify(insecure bool) ClientOption {
func SkipTLSVerify(skipTLSVerify bool) ClientOption {
return func(config *ClientConfig) error {
config.insecure = insecure
config.skipTLSVerify = skipTLSVerify
return nil
}
}
Expand Down
6 changes: 3 additions & 3 deletions registryclient/orasclient/oras.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

type orasClient struct {
plainHTTP bool
insecure bool
skipTLSVerify bool
authCache auth.Cache
credFn func(context.Context, string) (auth.Credential, error)
registryConf registryclient.RegistryConfig
Expand Down Expand Up @@ -332,11 +332,11 @@ func (c *orasClient) setupRepo(ctx context.Context, reference string) (registry.
switch {
case registryConfig == nil:
repo.PlainHTTP = c.plainHTTP
repo.Client = c.authClient(c.insecure)
repo.Client = c.authClient(c.skipTLSVerify)
return repo, nil
default:
repo.PlainHTTP = registryConfig.PlainHTTP
repo.Client = c.authClient(registryConfig.SkipTLS)
repo.Client = c.authClient(registryConfig.SkipTLSVerify)
return repo, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion registryclient/registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Endpoint struct {
// The endpoint's remote location.
Location string `mapstructure:"location" json:"location"`
// If true, certs verification will be skipped.
SkipTLS bool `mapstructure:"skipTLS" json:"skipTLS"`
SkipTLSVerify bool `mapstructure:"skipTLSVerify" json:"skipTLSVerify"`
// If true, the client will use HTTP to
// connect to the registry.
PlainHTTP bool `mapstructure:"plainHTTP" json:"plainHTTP"`
Expand Down
20 changes: 10 additions & 10 deletions registryclient/registries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ func TestFindRegistry(t *testing.T) {
{
Prefix: "*.example.com",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
{
Prefix: "*.not.com",
Endpoint: Endpoint{
SkipTLS: false,
SkipTLSVerify: false,
},
},
},
Expand All @@ -37,7 +37,7 @@ func TestFindRegistry(t *testing.T) {
expReg: Registry{
Prefix: "*.example.com",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
},
Expand All @@ -48,13 +48,13 @@ func TestFindRegistry(t *testing.T) {
{
Prefix: "*.example.com",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
{
Prefix: "*",
Endpoint: Endpoint{
SkipTLS: false,
SkipTLSVerify: false,
},
},
},
Expand All @@ -63,7 +63,7 @@ func TestFindRegistry(t *testing.T) {
expReg: Registry{
Prefix: "*.example.com",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
},
Expand All @@ -74,13 +74,13 @@ func TestFindRegistry(t *testing.T) {
{
Prefix: "reg.example.*",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
{
Prefix: "*",
Endpoint: Endpoint{
SkipTLS: false,
SkipTLSVerify: false,
},
},
},
Expand All @@ -89,7 +89,7 @@ func TestFindRegistry(t *testing.T) {
expReg: Registry{
Prefix: "reg.example.*",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
},
Expand All @@ -100,7 +100,7 @@ func TestFindRegistry(t *testing.T) {
{
Prefix: "*.not.com",
Endpoint: Endpoint{
SkipTLS: true,
SkipTLSVerify: true,
},
},
},
Expand Down

0 comments on commit 3d7b1fd

Please sign in to comment.