Skip to content

Commit c3170f1

Browse files
authored
Merge pull request #6293 from thaJeztah/remove_deprecated_opts
opts: remove deprecated types and functions
2 parents 73d88f5 + 5934553 commit c3170f1

File tree

5 files changed

+0
-210
lines changed

5 files changed

+0
-210
lines changed

opts/hosts.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@ const (
3232
hostGatewayName = "host-gateway"
3333
)
3434

35-
// ValidateHost validates that the specified string is a valid host and returns it.
36-
//
37-
// Deprecated: this function is no longer used, and will be removed in the next release.
38-
func ValidateHost(val string) (string, error) {
39-
host := strings.TrimSpace(val)
40-
// The empty string means default and is not handled by parseDockerDaemonHost
41-
if host != "" {
42-
_, err := parseDockerDaemonHost(host)
43-
if err != nil {
44-
return val, err
45-
}
46-
}
47-
// Note: unlike most flag validators, we don't return the mutated value here
48-
// we need to know what the user entered later (using ParseHost) to adjust for TLS
49-
return val, nil
50-
}
51-
5235
// ParseHost and set defaults for a Daemon host string
5336
func ParseHost(defaultToTLS bool, val string) (string, error) {
5437
host := strings.TrimSpace(val)

opts/opts.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
7979
return ret
8080
}
8181

82-
// GetAll returns the values of slice.
83-
//
84-
// Deprecated: use [ListOpts.GetSlice] instead. This method will be removed in a future release.
85-
func (opts *ListOpts) GetAll() []string {
86-
return *opts.values
87-
}
88-
8982
// GetSlice returns the values of slice.
9083
//
9184
// It implements [cobra.SliceValue] to allow shell completion to be provided
@@ -132,43 +125,6 @@ func (opts *ListOpts) WithValidator(validator ValidatorFctType) *ListOpts {
132125
return opts
133126
}
134127

135-
// NamedOption is an interface that list and map options
136-
// with names implement.
137-
//
138-
// Deprecated: NamedOption is no longer used and will be removed in the next release.
139-
type NamedOption interface {
140-
Name() string
141-
}
142-
143-
// NamedListOpts is a ListOpts with a configuration name.
144-
// This struct is useful to keep reference to the assigned
145-
// field name in the internal configuration struct.
146-
//
147-
// Deprecated: NamedListOpts is no longer used and will be removed in the next release.
148-
type NamedListOpts struct {
149-
name string
150-
ListOpts
151-
}
152-
153-
var _ NamedOption = &NamedListOpts{}
154-
155-
// NewNamedListOptsRef creates a reference to a new NamedListOpts struct.
156-
//
157-
// Deprecated: NewNamedListOptsRef is no longer used and will be removed in the next release.
158-
func NewNamedListOptsRef(name string, values *[]string, validator ValidatorFctType) *NamedListOpts {
159-
return &NamedListOpts{
160-
name: name,
161-
ListOpts: *NewListOptsRef(values, validator),
162-
}
163-
}
164-
165-
// Name returns the name of the NamedListOpts in the configuration.
166-
//
167-
// Deprecated: NamedListOpts is no longer used and will be removed in the next release.
168-
func (o *NamedListOpts) Name() string {
169-
return o.name
170-
}
171-
172128
// MapOpts holds a map of values and a validation function.
173129
type MapOpts struct {
174130
values map[string]string
@@ -215,35 +171,6 @@ func NewMapOpts(values map[string]string, validator ValidatorFctType) *MapOpts {
215171
}
216172
}
217173

218-
// NamedMapOpts is a MapOpts struct with a configuration name.
219-
// This struct is useful to keep reference to the assigned
220-
// field name in the internal configuration struct.
221-
//
222-
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
223-
type NamedMapOpts struct {
224-
name string
225-
MapOpts
226-
}
227-
228-
var _ NamedOption = &NamedMapOpts{}
229-
230-
// NewNamedMapOpts creates a reference to a new NamedMapOpts struct.
231-
//
232-
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
233-
func NewNamedMapOpts(name string, values map[string]string, validator ValidatorFctType) *NamedMapOpts {
234-
return &NamedMapOpts{
235-
name: name,
236-
MapOpts: *NewMapOpts(values, validator),
237-
}
238-
}
239-
240-
// Name returns the name of the NamedMapOpts in the configuration.
241-
//
242-
// Deprecated: NamedMapOpts is no longer used and will be removed in the next release.
243-
func (o *NamedMapOpts) Name() string {
244-
return o.name
245-
}
246-
247174
// ValidatorFctType defines a validator function that returns a validated string and/or an error.
248175
type ValidatorFctType func(val string) (string, error)
249176

opts/opts_test.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func TestMapOpts(t *testing.T) {
112112
}
113113
}
114114

115-
//nolint:gocyclo // ignore "cyclomatic complexity 17 is too high"
116115
func TestListOptsWithoutValidator(t *testing.T) {
117116
o := NewListOpts(nil)
118117
err := o.Set("foo")
@@ -146,9 +145,6 @@ func TestListOptsWithoutValidator(t *testing.T) {
146145
if o.String() != "[bar bar]" {
147146
t.Errorf("%s != [bar bar]", o.String())
148147
}
149-
if listOpts := o.GetAll(); len(listOpts) != 2 || listOpts[0] != "bar" || listOpts[1] != "bar" {
150-
t.Errorf("Expected [[bar bar]], got [%v]", listOpts)
151-
}
152148
if listOpts := o.GetSlice(); len(listOpts) != 2 || listOpts[0] != "bar" || listOpts[1] != "bar" {
153149
t.Errorf("Expected [[bar bar]], got [%v]", listOpts)
154150
}
@@ -364,38 +360,6 @@ func sampleValidator(val string) (string, error) {
364360
return "", fmt.Errorf("invalid key %s", k)
365361
}
366362

367-
func TestNamedListOpts(t *testing.T) {
368-
var v []string
369-
o := NewNamedListOptsRef("foo-name", &v, nil)
370-
371-
o.Set("foo")
372-
if o.String() != "[foo]" {
373-
t.Errorf("%s != [foo]", o.String())
374-
}
375-
if o.Name() != "foo-name" {
376-
t.Errorf("%s != foo-name", o.Name())
377-
}
378-
if len(v) != 1 {
379-
t.Errorf("expected foo to be in the values, got %v", v)
380-
}
381-
}
382-
383-
func TestNamedMapOpts(t *testing.T) {
384-
tmpMap := make(map[string]string)
385-
o := NewNamedMapOpts("max-name", tmpMap, nil)
386-
387-
o.Set("max-size=1")
388-
if o.String() != "map[max-size:1]" {
389-
t.Errorf("%s != [map[max-size:1]", o.String())
390-
}
391-
if o.Name() != "max-name" {
392-
t.Errorf("%s != max-name", o.Name())
393-
}
394-
if _, exist := tmpMap["max-size"]; !exist {
395-
t.Errorf("expected map-size to be in the values, got %v", tmpMap)
396-
}
397-
}
398-
399363
func TestValidateMACAddress(t *testing.T) {
400364
if _, err := ValidateMACAddress(`92:d0:c6:0a:29:33`); err != nil {
401365
t.Fatalf("ValidateMACAddress(`92:d0:c6:0a:29:33`) got %s", err)

opts/quotedstring.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

opts/quotedstring_test.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)