@@ -19,7 +19,8 @@ import (
1919)
2020
2121const (
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
3233type 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
4346func (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+
7381func (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
0 commit comments