Skip to content

Commit 7dd001f

Browse files
committed
Make all unrelated APIs private
Signed-off-by: Ed Bartosh <[email protected]>
1 parent 2cad149 commit 7dd001f

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

pkg/parser/parser.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package parser
1919
import (
2020
"fmt"
2121
"strings"
22-
23-
specs "tags.cncf.io/container-device-interface/specs-go"
2422
)
2523

2624
// QualifiedName returns the qualified name for a device.
@@ -107,7 +105,11 @@ func ParseDevice(device string) (string, string, string) {
107105
// If parsing fails, an empty vendor and the class set to the
108106
// verbatim input is returned.
109107
func ParseQualifier(kind string) (string, string) {
110-
return specs.ParseQualifier(kind)
108+
parts := strings.SplitN(kind, "/", 2)
109+
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
110+
return "", kind
111+
}
112+
return parts[0], parts[1]
111113
}
112114

113115
// ValidateVendorName checks the validity of a vendor name.
@@ -196,7 +198,7 @@ func ValidateDeviceName(name string) error {
196198

197199
// IsLetter reports whether the rune is a letter.
198200
func IsLetter(c rune) bool {
199-
return specs.IsLetter(c)
201+
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')
200202
}
201203

202204
// IsDigit reports whether the rune is a digit.

specs-go/parser.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ package specs
1818

1919
import "strings"
2020

21-
// ParseQualifier splits a device qualifier into vendor and class.
21+
// parseQualifier splits a device qualifier into vendor and class.
2222
// The syntax for a device qualifier is
2323
//
2424
// "<vendor>/<class>"
2525
//
2626
// If parsing fails, an empty vendor and the class set to the
2727
// verbatim input is returned.
28-
func ParseQualifier(kind string) (string, string) {
28+
func parseQualifier(kind string) (string, string) {
2929
parts := strings.SplitN(kind, "/", 2)
3030
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
3131
return "", kind
3232
}
3333
return parts[0], parts[1]
3434
}
3535

36-
// IsLetter reports whether the rune is a letter.
37-
func IsLetter(c rune) bool {
36+
// isLetter reports whether the rune is an ASCII letter.
37+
func isLetter(c rune) bool {
3838
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')
3939
}

specs-go/version.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ValidateVersion(spec *Spec) error {
7070
if err != nil {
7171
return fmt.Errorf("could not determine minimum required version: %w", err)
7272
}
73-
if newVersion(minVersion).IsGreaterThan(newVersion(spec.Version)) {
73+
if newVersion(minVersion).isGreaterThan(newVersion(spec.Version)) {
7474
return fmt.Errorf("the spec version must be at least v%v", minVersion)
7575
}
7676
return nil
@@ -96,13 +96,13 @@ func (v version) String() string {
9696
return strings.TrimPrefix(string(v), "v")
9797
}
9898

99-
// IsGreaterThan checks with a version is greater than the specified version.
100-
func (v version) IsGreaterThan(o version) bool {
99+
// isGreaterThan checks with a version is greater than the specified version.
100+
func (v version) isGreaterThan(o version) bool {
101101
return semver.Compare(string(v), string(o)) > 0
102102
}
103103

104-
// IsLatest checks whether the version is the latest supported version
105-
func (v version) IsLatest() bool {
104+
// isLatest checks whether the version is the latest supported version
105+
func (v version) isLatest() bool {
106106
return v == vCurrent
107107
}
108108

@@ -126,11 +126,11 @@ func (r requiredVersionMap) requiredVersion(spec *Spec) version {
126126
if isRequired == nil {
127127
continue
128128
}
129-
if isRequired(spec) && v.IsGreaterThan(minVersion) {
129+
if isRequired(spec) && v.isGreaterThan(minVersion) {
130130
minVersion = v
131131
}
132132
// If we have already detected the latest version then no later version could be detected
133-
if minVersion.IsLatest() {
133+
if minVersion.isLatest() {
134134
break
135135
}
136136
}
@@ -183,7 +183,7 @@ func requiresV060(spec *Spec) bool {
183183
}
184184

185185
// The v0.6.0 spec allows dots "." in Kind name label (class)
186-
vendor, class := ParseQualifier(spec.Kind)
186+
vendor, class := parseQualifier(spec.Kind)
187187
if vendor != "" {
188188
if strings.ContainsRune(class, '.') {
189189
return true
@@ -199,7 +199,7 @@ func requiresV050(spec *Spec) bool {
199199

200200
for _, d := range spec.Devices {
201201
// The v0.5.0 spec allowed device names to start with a digit instead of requiring a letter
202-
if len(d.Name) > 0 && !IsLetter(rune(d.Name[0])) {
202+
if len(d.Name) > 0 && !isLetter(rune(d.Name[0])) {
203203
return true
204204
}
205205
edits = append(edits, &d.ContainerEdits)

0 commit comments

Comments
 (0)