Skip to content

Commit

Permalink
add dotnet flag
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Nov 21, 2024
1 parent 463ea52 commit 58a5308
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 6 additions & 1 deletion buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,15 @@ func DotnetCmd(c *cli.Context) error {
return err
}

allowInsecureConnection, err := cliutils.ExtractBoolFlagFromArgs(&filteredDotnetArgs, "allow-insecure-connections")
if err != nil {
return err
}

// Run command.
dotnetCmd := dotnet.NewDotnetCoreCliCommand()
dotnetCmd.SetServerDetails(rtDetails).SetRepoName(targetRepo).SetBuildConfiguration(buildConfiguration).
SetBasicCommand(filteredDotnetArgs[0]).SetUseNugetV2(useNugetV2)
SetBasicCommand(filteredDotnetArgs[0]).SetUseNugetV2(useNugetV2).SetAllowInsecureConnections(allowInsecureConnection)
// Since we are using the values of the command's arguments and flags along the buildInfo collection process,
// we want to separate the actual .NET basic command (restore/build...) from the arguments and flags
if len(filteredDotnetArgs) > 1 {
Expand Down
15 changes: 6 additions & 9 deletions nuget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func testNativeNugetDotnetResolve(t *testing.T, uniqueTests []testDescriptor, bu
return
}
t.Run(test.name, func(t *testing.T) {
testNugetCmd(t, projectPath, buildName, strconv.Itoa(buildNumber), test.expectedModules, test.args, test.expectedDependencies, projectType.String())
testNugetCmd(t, projectPath, buildName, strconv.Itoa(buildNumber), test.expectedModules, test.args, test.expectedDependencies)
})
}
cleanTestsHomeEnv()
Expand All @@ -108,18 +108,18 @@ func TestNuGetWithGlobalConfig(t *testing.T) {
err = createConfigFileForTest([]string{jfrogHomeDir}, tests.NugetRemoteRepo, "", t, project.Nuget, true)
assert.NoError(t, err)
// allow insecure connection for testings to work with localhost server
testNugetCmd(t, projectPath, tests.NuGetBuildName, "1", []string{"packagesconfig"}, []string{"nuget", "restore"}, []int{6}, project.Nuget.String())
testNugetCmd(t, projectPath, tests.NuGetBuildName, "1", []string{"packagesconfig"}, []string{"nuget", "restore"}, []int{6})

cleanTestsHomeEnv()
}

func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expectedModule, args []string, expectedDependencies []int, projectType string) {
func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expectedModule, args []string, expectedDependencies []int) {
wd, err := os.Getwd()
assert.NoError(t, err, "Failed to get current dir")
chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, projectPath)
defer chdirCallback()

allowInsecureConnectionForTests(projectType, &args)
allowInsecureConnectionForTests(&args)
args = append(args, "--build-name="+buildName, "--build-number="+buildNumber)

err = runNuGet(t, args...)
Expand Down Expand Up @@ -157,11 +157,8 @@ func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expe
}

// Add allow insecure connection for testings to work with localhost server
// dotNet also uses this cmd, and we want to apply this only for Nuget.
func allowInsecureConnectionForTests(projectType string, args *[]string) *[]string {
if projectType == project.Nuget.String() {
*args = append(*args, "--allow-insecure-connections")
}
func allowInsecureConnectionForTests(args *[]string) *[]string {
*args = append(*args, "--allow-insecure-connections")
return args
}

Expand Down

0 comments on commit 58a5308

Please sign in to comment.