Skip to content

Commit 16d0cd1

Browse files
authored
Merge pull request #214 from bart0sh/PR017-move-version-to-go-specs-go
Move version APIs to the specs-go package
2 parents e665440 + 7dd001f commit 16d0cd1

File tree

12 files changed

+99
-77
lines changed

12 files changed

+99
-77
lines changed

cmd/cdi/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
2020
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
2121
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
22-
golang.org/x/mod v0.4.2 // indirect
22+
golang.org/x/mod v0.19.0 // indirect
2323
golang.org/x/sys v0.1.0 // indirect
2424
gopkg.in/yaml.v2 v2.4.0 // indirect
2525
tags.cncf.io/container-device-interface/specs-go v0.8.0 // indirect

cmd/cdi/go.sum

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,13 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
4545
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
4646
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
4747
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
48-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
49-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
50-
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
51-
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
52-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
53-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
54-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
55-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
56-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
48+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
49+
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5750
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5851
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5952
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6053
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
6154
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
62-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
63-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
64-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
65-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6655
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
6756
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
6857
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

cmd/validate/go.sum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
1616
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
1717
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
1818
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
19-
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
19+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
2020
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
2121
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2222
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626
99
github.com/stretchr/testify v1.7.0
1010
github.com/xeipuuv/gojsonschema v1.2.0
11-
golang.org/x/mod v0.4.2
1211
golang.org/x/sys v0.1.0
1312
sigs.k8s.io/yaml v1.3.0
1413
tags.cncf.io/container-device-interface/specs-go v0.8.0
@@ -20,6 +19,7 @@ require (
2019
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
2120
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
2221
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
22+
golang.org/x/mod v0.19.0 // indirect
2323
gopkg.in/yaml.v2 v2.4.0 // indirect
2424
gopkg.in/yaml.v3 v3.0.1 // indirect
2525
)

go.sum

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,13 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
3737
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
3838
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
3939
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
40-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
41-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
42-
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
43-
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
44-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
45-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
46-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
47-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
48-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
40+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
41+
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
4942
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5043
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5144
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5245
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
5346
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
54-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
55-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
56-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
57-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5847
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
5948
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
6049
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

pkg/cdi/spec.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,17 @@ func (s *Spec) edits() *ContainerEdits {
200200
return &ContainerEdits{&s.ContainerEdits}
201201
}
202202

203+
// MinimumRequiredVersion determines the minimum spec version for the input spec.
204+
// Deprecated: use cdi.MinimumRequiredVersion instead
205+
func MinimumRequiredVersion(spec *cdi.Spec) (string, error) {
206+
return cdi.MinimumRequiredVersion(spec)
207+
}
208+
203209
// Validate the Spec.
204210
func (s *Spec) validate() (map[string]*Device, error) {
205-
if err := validateVersion(s.Version); err != nil {
211+
if err := cdi.ValidateVersion(s.Spec); err != nil {
206212
return nil, err
207213
}
208-
209-
minVersion, err := MinimumRequiredVersion(s.Spec)
210-
if err != nil {
211-
return nil, fmt.Errorf("could not determine minimum required version: %v", err)
212-
}
213-
if newVersion(minVersion).IsGreaterThan(newVersion(s.Version)) {
214-
return nil, fmt.Errorf("the spec version must be at least v%v", minVersion)
215-
}
216-
217214
if err := ValidateVendorName(s.vendor); err != nil {
218215
return nil, err
219216
}
@@ -242,15 +239,6 @@ func (s *Spec) validate() (map[string]*Device, error) {
242239
return devices, nil
243240
}
244241

245-
// validateVersion checks whether the specified spec version is supported.
246-
func validateVersion(version string) error {
247-
if !validSpecVersions.isValidVersion(version) {
248-
return fmt.Errorf("invalid version %q", version)
249-
}
250-
251-
return nil
252-
}
253-
254242
// ParseSpec parses CDI Spec data into a raw CDI Spec.
255243
func ParseSpec(data []byte) (*cdi.Spec, error) {
256244
var raw *cdi.Spec

pkg/cdi/spec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ func specType(content []byte) string {
525525
}
526526

527527
func TestCurrentVersionIsValid(t *testing.T) {
528-
require.NoError(t, validateVersion(cdi.CurrentVersion))
528+
require.NoError(t, cdi.ValidateVersion(&cdi.Spec{Version: cdi.CurrentVersion}))
529529
}
530530

531531
func TestRequiredVersion(t *testing.T) {
@@ -723,7 +723,7 @@ func TestRequiredVersion(t *testing.T) {
723723

724724
for _, tc := range testCases {
725725
t.Run(tc.description, func(t *testing.T) {
726-
v, err := MinimumRequiredVersion(tc.spec)
726+
v, err := cdi.MinimumRequiredVersion(tc.spec)
727727
require.NoError(t, err)
728728

729729
require.Equal(t, tc.expectedVersion, v)

specs-go/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package specs
22

33
import "os"
44

5-
// CurrentVersion is the current version of the Spec.
6-
const CurrentVersion = "0.8.0"
7-
85
// Spec is the base configuration for CDI
96
type Spec struct {
107
Version string `json:"cdiVersion"`

specs-go/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module tags.cncf.io/container-device-interface/specs-go
22

33
go 1.19
4+
5+
require golang.org/x/mod v0.19.0

specs-go/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
2+
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=

specs-go/parser.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright © The CDI Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package specs
18+
19+
import "strings"
20+
21+
// parseQualifier splits a device qualifier into vendor and class.
22+
// The syntax for a device qualifier is
23+
//
24+
// "<vendor>/<class>"
25+
//
26+
// If parsing fails, an empty vendor and the class set to the
27+
// verbatim input is returned.
28+
func parseQualifier(kind string) (string, string) {
29+
parts := strings.SplitN(kind, "/", 2)
30+
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
31+
return "", kind
32+
}
33+
return parts[0], parts[1]
34+
}
35+
36+
// isLetter reports whether the rune is an ASCII letter.
37+
func isLetter(c rune) bool {
38+
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')
39+
}

pkg/cdi/version.go renamed to specs-go/version.go

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@
1414
limitations under the License.
1515
*/
1616

17-
package cdi
17+
package specs
1818

1919
import (
20+
"fmt"
2021
"strings"
2122

2223
"golang.org/x/mod/semver"
23-
24-
"tags.cncf.io/container-device-interface/pkg/parser"
25-
cdi "tags.cncf.io/container-device-interface/specs-go"
2624
)
2725

2826
const (
29-
// CurrentVersion is the current version of the CDI Spec.
30-
CurrentVersion = cdi.CurrentVersion
27+
// CurrentVersion is the current version of the Spec.
28+
CurrentVersion = "0.8.0"
3129

3230
// vCurrent is the current version as a semver-comparable type
3331
vCurrent version = "v" + CurrentVersion
@@ -60,8 +58,26 @@ var validSpecVersions = requiredVersionMap{
6058
v080: requiresV080,
6159
}
6260

61+
// ValidateVersion checks whether the specified spec version is valid.
62+
// In addition to checking whether the spec version is in the set of known versions,
63+
// the spec is inspected to determine whether the features used are available in specified
64+
// version.
65+
func ValidateVersion(spec *Spec) error {
66+
if !validSpecVersions.isValidVersion(spec.Version) {
67+
return fmt.Errorf("invalid version %q", spec.Version)
68+
}
69+
minVersion, err := MinimumRequiredVersion(spec)
70+
if err != nil {
71+
return fmt.Errorf("could not determine minimum required version: %w", err)
72+
}
73+
if newVersion(minVersion).isGreaterThan(newVersion(spec.Version)) {
74+
return fmt.Errorf("the spec version must be at least v%v", minVersion)
75+
}
76+
return nil
77+
}
78+
6379
// MinimumRequiredVersion determines the minimum spec version for the input spec.
64-
func MinimumRequiredVersion(spec *cdi.Spec) (string, error) {
80+
func MinimumRequiredVersion(spec *Spec) (string, error) {
6581
minVersion := validSpecVersions.requiredVersion(spec)
6682
return minVersion.String(), nil
6783
}
@@ -80,17 +96,17 @@ func (v version) String() string {
8096
return strings.TrimPrefix(string(v), "v")
8197
}
8298

83-
// IsGreaterThan checks with a version is greater than the specified version.
84-
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 {
85101
return semver.Compare(string(v), string(o)) > 0
86102
}
87103

88-
// IsLatest checks whether the version is the latest supported version
89-
func (v version) IsLatest() bool {
104+
// isLatest checks whether the version is the latest supported version
105+
func (v version) isLatest() bool {
90106
return v == vCurrent
91107
}
92108

93-
type requiredFunc func(*cdi.Spec) bool
109+
type requiredFunc func(*Spec) bool
94110

95111
type requiredVersionMap map[version]requiredFunc
96112

@@ -103,18 +119,18 @@ func (r requiredVersionMap) isValidVersion(specVersion string) bool {
103119
}
104120

105121
// requiredVersion returns the minimum version required for the given spec
106-
func (r requiredVersionMap) requiredVersion(spec *cdi.Spec) version {
122+
func (r requiredVersionMap) requiredVersion(spec *Spec) version {
107123
minVersion := vEarliest
108124

109125
for v, isRequired := range validSpecVersions {
110126
if isRequired == nil {
111127
continue
112128
}
113-
if isRequired(spec) && v.IsGreaterThan(minVersion) {
129+
if isRequired(spec) && v.isGreaterThan(minVersion) {
114130
minVersion = v
115131
}
116132
// If we have already detected the latest version then no later version could be detected
117-
if minVersion.IsLatest() {
133+
if minVersion.isLatest() {
118134
break
119135
}
120136
}
@@ -125,12 +141,12 @@ func (r requiredVersionMap) requiredVersion(spec *cdi.Spec) version {
125141
// requiresV080 returns true if the spec uses v0.8.0 features.
126142
// Since the v0.8.0 spec bump was due to the removed .ToOCI functions on the
127143
// spec types, there are explicit spec changes.
128-
func requiresV080(_ *cdi.Spec) bool {
144+
func requiresV080(_ *Spec) bool {
129145
return false
130146
}
131147

132148
// requiresV070 returns true if the spec uses v0.7.0 features
133-
func requiresV070(spec *cdi.Spec) bool {
149+
func requiresV070(spec *Spec) bool {
134150
if spec.ContainerEdits.IntelRdt != nil {
135151
return true
136152
}
@@ -153,7 +169,7 @@ func requiresV070(spec *cdi.Spec) bool {
153169
}
154170

155171
// requiresV060 returns true if the spec uses v0.6.0 features
156-
func requiresV060(spec *cdi.Spec) bool {
172+
func requiresV060(spec *Spec) bool {
157173
// The v0.6.0 spec allows annotations to be specified at a spec level
158174
for range spec.Annotations {
159175
return true
@@ -167,7 +183,7 @@ func requiresV060(spec *cdi.Spec) bool {
167183
}
168184

169185
// The v0.6.0 spec allows dots "." in Kind name label (class)
170-
vendor, class := parser.ParseQualifier(spec.Kind)
186+
vendor, class := parseQualifier(spec.Kind)
171187
if vendor != "" {
172188
if strings.ContainsRune(class, '.') {
173189
return true
@@ -178,12 +194,12 @@ func requiresV060(spec *cdi.Spec) bool {
178194
}
179195

180196
// requiresV050 returns true if the spec uses v0.5.0 features
181-
func requiresV050(spec *cdi.Spec) bool {
182-
var edits []*cdi.ContainerEdits
197+
func requiresV050(spec *Spec) bool {
198+
var edits []*ContainerEdits
183199

184200
for _, d := range spec.Devices {
185201
// The v0.5.0 spec allowed device names to start with a digit instead of requiring a letter
186-
if len(d.Name) > 0 && !parser.IsLetter(rune(d.Name[0])) {
202+
if len(d.Name) > 0 && !isLetter(rune(d.Name[0])) {
187203
return true
188204
}
189205
edits = append(edits, &d.ContainerEdits)
@@ -202,8 +218,8 @@ func requiresV050(spec *cdi.Spec) bool {
202218
}
203219

204220
// requiresV040 returns true if the spec uses v0.4.0 features
205-
func requiresV040(spec *cdi.Spec) bool {
206-
var edits []*cdi.ContainerEdits
221+
func requiresV040(spec *Spec) bool {
222+
var edits []*ContainerEdits
207223

208224
for _, d := range spec.Devices {
209225
edits = append(edits, &d.ContainerEdits)

0 commit comments

Comments
 (0)