@@ -23,10 +23,10 @@ import (
23
23
"os"
24
24
"path/filepath"
25
25
26
- "github.com/containerd/containerd/v2/pkg/identifiers"
27
26
"github.com/containerd/errdefs"
28
27
"github.com/containerd/log"
29
28
29
+ "github.com/containerd/nerdctl/v2/pkg/identifiers"
30
30
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/native"
31
31
"github.com/containerd/nerdctl/v2/pkg/lockutil"
32
32
"github.com/containerd/nerdctl/v2/pkg/strutil"
@@ -109,9 +109,10 @@ func (vs *volumeStore) Unlock() error {
109
109
// Create will create a new volume, or return an existing one if there is one already by that name
110
110
// Besides a possible locking error, it might return ErrInvalidArgument, hard filesystem errors, json errors
111
111
func (vs * volumeStore ) Create (name string , labels []string ) (* native.Volume , error ) {
112
- if err := identifiers .Validate (name ); err != nil {
113
- return nil , fmt .Errorf ("malformed volume name: %w (%w) " , err , errdefs . ErrInvalidArgument )
112
+ if err := identifiers .ValidateDockerCompat (name ); err != nil {
113
+ return nil , fmt .Errorf ("invalid volume name: %w" , err )
114
114
}
115
+
115
116
volPath := filepath .Join (vs .dir , name )
116
117
volDataPath := filepath .Join (volPath , dataDirName )
117
118
volFilePath := filepath .Join (volPath , volumeJSONFileName )
@@ -178,8 +179,8 @@ func (vs *volumeStore) Create(name string, labels []string) (*native.Volume, err
178
179
// Get retrieves a native volume from the store
179
180
// Besides a possible locking error, it might return ErrInvalidArgument, ErrNotFound, or a filesystem error
180
181
func (vs * volumeStore ) Get (name string , size bool ) (* native.Volume , error ) {
181
- if err := identifiers .Validate (name ); err != nil {
182
- return nil , fmt .Errorf ("malformed volume name %q : %w" , name , err )
182
+ if err := identifiers .ValidateDockerCompat (name ); err != nil {
183
+ return nil , fmt .Errorf ("invalid volume name: %w" , err )
183
184
}
184
185
volPath := filepath .Join (vs .dir , name )
185
186
volDataPath := filepath .Join (volPath , dataDirName )
@@ -274,8 +275,8 @@ func (vs *volumeStore) Remove(names []string) (removed []string, warns []error,
274
275
fn := func () error {
275
276
for _ , name := range names {
276
277
// Invalid name, soft error
277
- if err := identifiers .Validate (name ); err != nil {
278
- warns = append (warns , fmt .Errorf ("malformed volume name: %w (%w) " , err , errdefs . ErrInvalidArgument ))
278
+ if err := identifiers .ValidateDockerCompat (name ); err != nil {
279
+ warns = append (warns , fmt .Errorf ("invalid volume name: %w" , err ))
279
280
continue
280
281
}
281
282
dir := filepath .Join (vs .dir , name )
0 commit comments