Skip to content

Commit 5374634

Browse files
authored
Merge branch 'dev' into createSpecFromVariables
2 parents 82d5deb + 04daeb8 commit 5374634

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

artifactory/commands/dotnet/dotnetcommand.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import (
1919
)
2020

2121
const (
22-
SourceName = "JFrogArtifactory"
22+
// SourceName should match the one in the config file template.
23+
SourceName = "JFrogCli"
2324
configFilePattern = "jfrog.cli.nuget."
2425

2526
dotnetTestError = `the command failed with an error.
@@ -30,14 +31,16 @@ The initial error is:
3031
)
3132

3233
type DotnetCommand struct {
33-
toolchainType dotnet.ToolchainType
34-
subCommand string
35-
argAndFlags []string
36-
repoName string
37-
solutionPath string
38-
useNugetV2 bool
39-
buildConfiguration *commonBuild.BuildConfiguration
40-
serverDetails *config.ServerDetails
34+
toolchainType dotnet.ToolchainType
35+
subCommand string
36+
argAndFlags []string
37+
repoName string
38+
solutionPath string
39+
useNugetV2 bool
40+
// By default, package sources are required to use HTTPS. This option allows sources to use HTTP.
41+
allowInsecureConnections bool
42+
buildConfiguration *commonBuild.BuildConfiguration
43+
serverDetails *config.ServerDetails
4144
}
4245

4346
func (dc *DotnetCommand) SetServerDetails(serverDetails *config.ServerDetails) *DotnetCommand {
@@ -70,6 +73,11 @@ func (dc *DotnetCommand) SetUseNugetV2(useNugetV2 bool) *DotnetCommand {
7073
return dc
7174
}
7275

76+
func (dc *DotnetCommand) SetAllowInsecureConnections(allowInsecureConnections bool) *DotnetCommand {
77+
dc.allowInsecureConnections = allowInsecureConnections
78+
return dc
79+
}
80+
7381
func (dc *DotnetCommand) SetArgAndFlags(argAndFlags []string) *DotnetCommand {
7482
dc.argAndFlags = argAndFlags
7583
return dc
@@ -242,7 +250,7 @@ func (dc *DotnetCommand) prepareConfigFileIfNeeded() (cleanup func() error, err
242250
return fileutils.RemoveTempDir(tempDirPath)
243251
}
244252

245-
configFile, err := InitNewConfig(tempDirPath, dc.repoName, dc.serverDetails, dc.useNugetV2)
253+
configFile, err := InitNewConfig(tempDirPath, dc.repoName, dc.serverDetails, dc.useNugetV2, dc.allowInsecureConnections)
246254
if err == nil {
247255
dc.argAndFlags = append(dc.argAndFlags, dc.GetToolchain().GetTypeFlagPrefix()+"configfile", configFile.Name())
248256
}
@@ -269,7 +277,7 @@ func getFlagValueIfExists(cmdFlag string, argAndFlags []string) (string, error)
269277
}
270278

271279
// InitNewConfig is used when neither of the flags were provided, and we need to init our own config.
272-
func InitNewConfig(configDirPath, repoName string, server *config.ServerDetails, useNugetV2 bool) (configFile *os.File, err error) {
280+
func InitNewConfig(configDirPath, repoName string, server *config.ServerDetails, useNugetV2, allowInsecureConnections bool) (configFile *os.File, err error) {
273281
// Initializing a new NuGet config file that NuGet will use into a temp file
274282
configFile, err = os.CreateTemp(configDirPath, configFilePattern)
275283
if errorutils.CheckError(err) != nil {
@@ -283,12 +291,12 @@ func InitNewConfig(configDirPath, repoName string, server *config.ServerDetails,
283291
// We would prefer to write the NuGet configuration using the `nuget add source` command,
284292
// but the NuGet configuration utility doesn't currently allow setting protocolVersion.
285293
// Until that is supported, the templated method must be used.
286-
err = addSourceToNugetTemplate(configFile, server, useNugetV2, repoName)
294+
err = addSourceToNugetTemplate(configFile, server, useNugetV2, repoName, allowInsecureConnections)
287295
return
288296
}
289297

290298
// Adds a source to the nuget config template
291-
func addSourceToNugetTemplate(configFile *os.File, server *config.ServerDetails, useNugetV2 bool, repoName string) error {
299+
func addSourceToNugetTemplate(configFile *os.File, server *config.ServerDetails, useNugetV2 bool, repoName string, allowInsecureConnections bool) error {
292300
sourceUrl, user, password, err := GetSourceDetails(server, repoName, useNugetV2)
293301
if err != nil {
294302
return err
@@ -301,7 +309,7 @@ func addSourceToNugetTemplate(configFile *os.File, server *config.ServerDetails,
301309
}
302310

303311
// Format the templates
304-
_, err = fmt.Fprintf(configFile, dotnet.ConfigFileFormat, sourceUrl, protoVer, user, password)
312+
_, err = fmt.Fprintf(configFile, dotnet.ConfigFileFormat, sourceUrl, protoVer, allowInsecureConnections, user, password)
305313
return err
306314
}
307315

artifactory/commands/dotnet/dotnetcommand_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestInitNewConfig(t *testing.T) {
7474
User: "user",
7575
Password: "pass",
7676
}
77-
configFile, err := InitNewConfig(tmpDir, repoName, server, false)
77+
configFile, err := InitNewConfig(tmpDir, repoName, server, false, true)
7878
assert.NoError(t, err)
7979
f, err := os.Open(configFile.Name())
8080
assert.NoError(t, err)
@@ -87,7 +87,7 @@ func TestInitNewConfig(t *testing.T) {
8787
assert.Equal(t, `<?xml version="1.0" encoding="utf-8"?>
8888
<configuration>
8989
<packageSources>
90-
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/v3/test-repo" protocolVersion="3" />
90+
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/v3/test-repo" protocolVersion="3" allowInsecureConnections="true"/>
9191
</packageSources>
9292
<packageSourceCredentials>
9393
<JFrogCli>
@@ -98,7 +98,7 @@ func TestInitNewConfig(t *testing.T) {
9898
</configuration>`, string(buf[:n]))
9999
server.Password = ""
100100
server.AccessToken = "abc123"
101-
configFile, err = InitNewConfig(tmpDir, repoName, server, true)
101+
configFile, err = InitNewConfig(tmpDir, repoName, server, true, true)
102102
assert.NoError(t, err)
103103
updatedConfigFile, err := os.Open(configFile.Name())
104104
assert.NoError(t, err)
@@ -111,7 +111,7 @@ func TestInitNewConfig(t *testing.T) {
111111
assert.Equal(t, `<?xml version="1.0" encoding="utf-8"?>
112112
<configuration>
113113
<packageSources>
114-
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/test-repo" protocolVersion="2" />
114+
<add key="JFrogCli" value="https://server.com/artifactory/api/nuget/test-repo" protocolVersion="2" allowInsecureConnections="true"/>
115115
</packageSources>
116116
<packageSourceCredentials>
117117
<JFrogCli>
@@ -164,11 +164,12 @@ func testPrepareDotnetBuildInfoModule(t *testing.T, subCommand string, flags []s
164164
}()
165165
module := createNewDotnetModule(t, tmpDir)
166166
cmd := DotnetCommand{
167-
toolchainType: dotnet.DotnetCore,
168-
subCommand: subCommand,
169-
argAndFlags: flags,
170-
buildConfiguration: buildUtils.NewBuildConfiguration("", "", "mod", ""),
171-
serverDetails: &config.ServerDetails{ArtifactoryUrl: "https://my-instance.jfrog.io"},
167+
toolchainType: dotnet.DotnetCore,
168+
subCommand: subCommand,
169+
argAndFlags: flags,
170+
buildConfiguration: buildUtils.NewBuildConfiguration("", "", "mod", ""),
171+
serverDetails: &config.ServerDetails{ArtifactoryUrl: "https://my-instance.jfrog.io"},
172+
allowInsecureConnections: true,
172173
}
173174
callbackFunc, err := cmd.prepareDotnetBuildInfoModule(module)
174175
if !assert.NoError(t, err) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ require (
9898

9999
// replace github.com/jfrog/jfrog-client-go => github.com/eyalbe4/jfrog-client-go v1.28.1-0.20241103083749-45c13ff7fe16
100100

101-
// replace github.com/jfrog/build-info-go => github.com/galusben/build-info-go v0.0.0-20240930113238-ac3b31030284
101+
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd
102102

103103
// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.3-0.20231223133729-ef57bd08cedc

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ github.com/jedib0t/go-pretty/v6 v6.6.1 h1:iJ65Xjb680rHcikRj6DSIbzCex2huitmc7bDtx
8989
github.com/jedib0t/go-pretty/v6 v6.6.1/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
9090
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
9191
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
92-
github.com/jfrog/build-info-go v1.10.5 h1:cW03JlPlKv7RMUU896uLUxyLWXAmCgR5Y5QX0fwgz0Q=
93-
github.com/jfrog/build-info-go v1.10.5/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
92+
github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd h1:PzxnJ1mjHIL4bAC4RPm87WnJ1TZXFBicyOhtIHRQH6g=
93+
github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
9494
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
9595
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
9696
github.com/jfrog/jfrog-client-go v1.48.0 h1:hx5B7+Wnobmzq4aFVZtALtbEVDFcjpn0Wb4q2m6H4KU=

0 commit comments

Comments
 (0)