Skip to content

Commit 8f96084

Browse files
authored
Merge pull request #5865 from hpcng/master
master merge for release 3.7.2
2 parents 6604f44 + 784c581 commit 8f96084

File tree

15 files changed

+239
-224
lines changed

15 files changed

+239
-224
lines changed

cmd/internal/cli/build.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/sylabs/singularity/pkg/build/types"
2525
"github.com/sylabs/singularity/pkg/build/types/parser"
2626
"github.com/sylabs/singularity/pkg/cmdline"
27+
"github.com/sylabs/singularity/pkg/image"
2728
"github.com/sylabs/singularity/pkg/sylog"
2829
)
2930

@@ -135,7 +136,7 @@ var buildDetachedFlag = cmdline.Flag{
135136
var buildBuilderFlag = cmdline.Flag{
136137
ID: "buildBuilderFlag",
137138
Value: &buildArgs.builderURL,
138-
DefaultValue: endpoint.SCSDefaultBuilderURI,
139+
DefaultValue: "",
139140
Name: "builder",
140141
Usage: "remote Build Service URL, setting this implies --remote",
141142
EnvKeys: []string{"BUILDER"},
@@ -145,7 +146,7 @@ var buildBuilderFlag = cmdline.Flag{
145146
var buildLibraryFlag = cmdline.Flag{
146147
ID: "buildLibraryFlag",
147148
Value: &buildArgs.libraryURL,
148-
DefaultValue: endpoint.SCSDefaultLibraryURI,
149+
DefaultValue: "",
149150
Name: "library",
150151
Usage: "container Library URL",
151152
EnvKeys: []string{"LIBRARY"},
@@ -299,8 +300,15 @@ func checkBuildTarget(path string) error {
299300

300301
question := fmt.Sprintf("Build target '%s' already exists and will be deleted during the build process. Do you want to continue? [N/y]", f.Name())
301302

302-
if isDefFile, _ := parser.IsValidDefinition(abspath); isDefFile {
303-
question = fmt.Sprintf("Build target '%s' is a definition file that will be overwritten. Do you still want to overwrite? [N/y]", f.Name())
303+
img, err := image.Init(abspath, false)
304+
if err != nil {
305+
if err != image.ErrUnknownFormat {
306+
return fmt.Errorf("while determining '%s' format: %s", f.Name(), err)
307+
}
308+
// unknown image file format
309+
question = fmt.Sprintf("Build target '%s' may be a definition file or a text/binary file that will be overwritten. Do you still want to overwrite it? [N/y]", f.Name())
310+
} else {
311+
img.File.Close()
304312
}
305313

306314
input, err := interactive.AskYNQuestion("n", question)

cmd/internal/cli/delete.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/spf13/cobra"
1616
"github.com/sylabs/singularity/docs"
1717
"github.com/sylabs/singularity/internal/app/singularity"
18-
"github.com/sylabs/singularity/internal/pkg/remote/endpoint"
1918
"github.com/sylabs/singularity/internal/pkg/util/interactive"
2019
"github.com/sylabs/singularity/pkg/cmdline"
2120
"github.com/sylabs/singularity/pkg/sylog"
@@ -69,7 +68,7 @@ var deleteLibraryURI string
6968
var deleteLibraryURIFlag = cmdline.Flag{
7069
ID: "deleteLibraryURIFlag",
7170
Value: &deleteLibraryURI,
72-
DefaultValue: endpoint.SCSDefaultLibraryURI,
71+
DefaultValue: "",
7372
Name: "library",
7473
Usage: "delete images from the provided library",
7574
EnvKeys: []string{"LIBRARY"},

cmd/internal/cli/key.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ import (
1414
"github.com/spf13/cobra"
1515
"github.com/sylabs/singularity/docs"
1616
"github.com/sylabs/singularity/internal/pkg/buildcfg"
17-
"github.com/sylabs/singularity/internal/pkg/remote/endpoint"
1817
"github.com/sylabs/singularity/pkg/cmdline"
1918
"github.com/sylabs/singularity/pkg/sylog"
2019
)
2120

22-
const (
23-
defaultKeyServer = endpoint.SCSDefaultKeyserverURI
24-
)
25-
2621
var (
2722
keyServerURI string // -u command line option
2823
keySearchLongList bool // -l option for long-list
@@ -34,7 +29,7 @@ var (
3429
var keyServerURIFlag = cmdline.Flag{
3530
ID: "keyServerURIFlag",
3631
Value: &keyServerURI,
37-
DefaultValue: defaultKeyServer,
32+
DefaultValue: "",
3833
Name: "url",
3934
ShortHand: "u",
4035
Usage: "specify the key server URL",

cmd/internal/cli/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var pullArchFlag = cmdline.Flag{
6868
var pullLibraryURIFlag = cmdline.Flag{
6969
ID: "pullLibraryURIFlag",
7070
Value: &pullLibraryURI,
71-
DefaultValue: endpoint.SCSDefaultLibraryURI,
71+
DefaultValue: "",
7272
Name: "library",
7373
Usage: "download images from the provided library",
7474
EnvKeys: []string{"LIBRARY"},
@@ -207,7 +207,7 @@ func pullRun(cmd *cobra.Command, args []string) {
207207
if err != nil {
208208
sylog.Fatalf("Unable to get library client configuration: %v", err)
209209
}
210-
co, err := getKeyserverClientOpts(endpoint.SCSDefaultKeyserverURI, endpoint.KeyserverVerifyOp)
210+
co, err := getKeyserverClientOpts("", endpoint.KeyserverVerifyOp)
211211
if err != nil {
212212
sylog.Fatalf("Unable to get keyserver client configuration: %v", err)
213213
}

cmd/internal/cli/push.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
var pushLibraryURIFlag = cmdline.Flag{
3737
ID: "pushLibraryURIFlag",
3838
Value: &PushLibraryURI,
39-
DefaultValue: endpoint.SCSDefaultLibraryURI,
39+
DefaultValue: "",
4040
Name: "library",
4141
Usage: "the library to push to",
4242
EnvKeys: []string{"LIBRARY"},
@@ -102,7 +102,7 @@ var PushCmd = &cobra.Command{
102102
sylog.Fatalf("Cannot push image to library: %v", remoteWarning)
103103
}
104104

105-
co, err := getKeyserverClientOpts(endpoint.SCSDefaultKeyserverURI, endpoint.KeyserverVerifyOp)
105+
co, err := getKeyserverClientOpts("", endpoint.KeyserverVerifyOp)
106106
if err != nil {
107107
sylog.Fatalf("Unable to get keyserver client configuration: %v", err)
108108
}

cmd/internal/cli/search.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/sylabs/scs-library-client/client"
1515
"github.com/sylabs/singularity/docs"
1616
"github.com/sylabs/singularity/internal/pkg/client/library"
17-
"github.com/sylabs/singularity/internal/pkg/remote/endpoint"
1817
"github.com/sylabs/singularity/pkg/cmdline"
1918
"github.com/sylabs/singularity/pkg/sylog"
2019
)
@@ -32,7 +31,7 @@ var (
3231
var searchLibraryFlag = cmdline.Flag{
3332
ID: "searchLibraryFlag",
3433
Value: &SearchLibraryURI,
35-
DefaultValue: endpoint.SCSDefaultLibraryURI,
34+
DefaultValue: "",
3635
Name: "library",
3736
Usage: "URI for library to search",
3837
EnvKeys: []string{"LIBRARY"},

cmd/internal/cli/singularity.go

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,10 @@ func CheckRootOrUnpriv(cmd *cobra.Command, args []string) {
586586
}
587587
}
588588

589+
// getKeyServerClientOpts returns client options for keyserver access.
590+
// A "" value for uri will return client options for the current endpoint.
591+
// A specified uri will return client options for that keyserver.
589592
func getKeyserverClientOpts(uri string, op endpoint.KeyserverOp) ([]scskeyclient.Option, error) {
590-
isDefault := uri == endpoint.SCSDefaultKeyserverURI
591-
592593
if currentRemoteEndpoint == nil {
593594
var err error
594595

@@ -599,19 +600,17 @@ func getKeyserverClientOpts(uri string, op endpoint.KeyserverOp) ([]scskeyclient
599600
return nil, fmt.Errorf("unable to load remote configuration: %v", err)
600601
}
601602
}
602-
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig && isDefault {
603-
sylog.Warningf("No default remote in use, falling back to default keyserver: %s", uri)
604-
}
605-
if isDefault {
606-
uri = ""
603+
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig {
604+
sylog.Warningf("No default remote in use, falling back to default keyserver: %s", endpoint.SCSDefaultKeyserverURI)
607605
}
608606

609607
return currentRemoteEndpoint.KeyserverClientOpts(uri, op)
610608
}
611609

610+
// getLibraryClientConfig returns client config for library server access.
611+
// A "" value for uri will return client config for the current endpoint.
612+
// A specified uri will return client options for that library server.
612613
func getLibraryClientConfig(uri string) (*scslibclient.Config, error) {
613-
isDefault := uri == endpoint.SCSDefaultLibraryURI
614-
615614
if currentRemoteEndpoint == nil {
616615
var err error
617616

@@ -622,19 +621,17 @@ func getLibraryClientConfig(uri string) (*scslibclient.Config, error) {
622621
return nil, fmt.Errorf("unable to load remote configuration: %v", err)
623622
}
624623
}
625-
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig && isDefault {
626-
sylog.Warningf("No default remote in use, falling back to default library: %s", uri)
627-
}
628-
if isDefault {
629-
uri = ""
624+
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig {
625+
sylog.Warningf("No default remote in use, falling back to default library: %s", endpoint.SCSDefaultLibraryURI)
630626
}
631627

632628
return currentRemoteEndpoint.LibraryClientConfig(uri)
633629
}
634630

631+
// getBuilderClientConfig returns client config for build server access.
632+
// A "" value for uri will return client config for the current endpoint.
633+
// A specified uri will return client options for that build server.
635634
func getBuilderClientConfig(uri string) (*scsbuildclient.Config, error) {
636-
isDefault := uri == endpoint.SCSDefaultBuilderURI
637-
638635
if currentRemoteEndpoint == nil {
639636
var err error
640637

@@ -645,11 +642,8 @@ func getBuilderClientConfig(uri string) (*scsbuildclient.Config, error) {
645642
return nil, fmt.Errorf("unable to load remote configuration: %v", err)
646643
}
647644
}
648-
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig && isDefault {
649-
sylog.Warningf("No default remote in use, falling back to default builder: %s", uri)
650-
}
651-
if isDefault {
652-
uri = ""
645+
if currentRemoteEndpoint == endpoint.DefaultEndpointConfig {
646+
sylog.Warningf("No default remote in use, falling back to default builder: %s", endpoint.SCSDefaultBuilderURI)
653647
}
654648

655649
return currentRemoteEndpoint.BuilderClientConfig(uri)

cmd/internal/cli/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var (
3131
var verifyServerURIFlag = cmdline.Flag{
3232
ID: "verifyServerURIFlag",
3333
Value: &keyServerURI,
34-
DefaultValue: defaultKeyServer,
34+
DefaultValue: "",
3535
Name: "url",
3636
ShortHand: "u",
3737
Usage: "specify a URL for a key server",

e2e/pull/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests {
629629

630630
t.Run("pull", c.testPullCmd)
631631
t.Run("pullDisableCache", c.testPullDisableCacheCmd)
632+
633+
// Regressions
634+
t.Run("issue5808", c.issue5808)
632635
}),
633636
}
634637
}

e2e/pull/regressions.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) 2020, Sylabs Inc. All rights reserved.
2+
// This software is licensed under a 3-clause BSD license. Please consult the
3+
// LICENSE.md file distributed with the sources of this project regarding your
4+
// rights to use or distribute this software.
5+
6+
package pull
7+
8+
import (
9+
"path"
10+
"testing"
11+
12+
"github.com/sylabs/singularity/e2e/internal/e2e"
13+
)
14+
15+
// If a remote is set to a different endpoint we should be able to pull
16+
// with `--library https://library.sylabs.io` from the default Sylabs cloud library.
17+
func (c ctx) issue5808(t *testing.T) {
18+
testEndpoint := "issue5808"
19+
testEndpointURI := "https://cloud.staging.sylabs.io"
20+
defaultLibraryURI := "https://library.sylabs.io"
21+
testImage := "library://sylabs/tests/signed:1.0.0"
22+
23+
pullDir, cleanup := e2e.MakeTempDir(t, "", "issue5808", "")
24+
defer cleanup(t)
25+
26+
// Add another endpoint
27+
argv := []string{"add", "--no-login", testEndpoint, testEndpointURI}
28+
c.env.RunSingularity(
29+
t,
30+
e2e.AsSubtest("remote add"),
31+
e2e.WithProfile(e2e.UserProfile),
32+
e2e.WithCommand("remote"),
33+
e2e.WithArgs(argv...),
34+
e2e.ExpectExit(0),
35+
)
36+
// Remove test remote when we are done here
37+
defer func(t *testing.T) {
38+
argv := []string{"remove", testEndpoint}
39+
c.env.RunSingularity(
40+
t,
41+
e2e.AsSubtest("remote remove"),
42+
e2e.WithProfile(e2e.UserProfile),
43+
e2e.WithCommand("remote"),
44+
e2e.WithArgs(argv...),
45+
e2e.ExpectExit(0),
46+
)
47+
}(t)
48+
49+
// Set as default
50+
argv = []string{"use", testEndpoint}
51+
c.env.RunSingularity(
52+
t,
53+
e2e.AsSubtest("remote use"),
54+
e2e.WithProfile(e2e.UserProfile),
55+
e2e.WithCommand("remote"),
56+
e2e.WithArgs(argv...),
57+
e2e.ExpectExit(0),
58+
)
59+
60+
// Pull a library image
61+
dest := path.Join(pullDir, "alpine.sif")
62+
argv = []string{"--arch", "amd64", "--library", defaultLibraryURI, dest, testImage}
63+
c.env.RunSingularity(
64+
t,
65+
e2e.AsSubtest("pull"),
66+
e2e.WithProfile(e2e.UserProfile),
67+
e2e.WithCommand("pull"),
68+
e2e.WithArgs(argv...),
69+
e2e.ExpectExit(0),
70+
)
71+
72+
}

0 commit comments

Comments
 (0)