Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote version to 1.28.1 #733

Merged
merged 6 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Static Code Analysis
uses: dominikh/staticcheck-action@v1
with:
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Install gosec
run: curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Run gosec
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/frogbot-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- uses: jfrog/frogbot@v2
env:
# [Mandatory]
# JFrog platform URL
JF_URL: ${{ secrets.FROGBOT_URL }}

# [Mandatory if JF_USER and JF_PASSWORD are not provided]
# JFrog access token with 'read' permissions on Xray service
JF_ACCESS_TOKEN: ${{ secrets.FROGBOT_ACCESS_TOKEN }}

# [Mandatory]
# The GitHub token automatically generated for the job
JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/frogbot-scan-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- uses: jfrog/frogbot@v2
env:
# [Mandatory]
# JFrog platform URL
JF_URL: ${{ secrets.FROGBOT_URL }}

# [Mandatory if JF_USER and JF_PASSWORD are not provided]
# JFrog access token with 'read' permissions on Xray service
JF_ACCESS_TOKEN: ${{ secrets.FROGBOT_ACCESS_TOKEN }}

# [Mandatory]
# The GitHub token automatically generated for the job
JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Go Cache
uses: actions/cache@v3
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Go Cache
uses: actions/cache@v3
Expand All @@ -121,7 +121,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Go Cache
uses: actions/cache@v3
Expand All @@ -141,7 +141,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down
5 changes: 2 additions & 3 deletions artifactory/services/createreplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ func (rs *CreateReplicationService) performRequest(params *utils.UpdateReplicati
httpClientsDetails := rs.ArtDetails.CreateHttpClientDetails()
utils.SetContentType("application/vnd.org.jfrog.artifactory.replications.ReplicationConfigRequest+json", &httpClientsDetails.Headers)
var url = rs.ArtDetails.GetUrl() + "api/replications/" + params.RepoKey
log.Info("Creating replication..")
operationString := "creating"
log.Info("Creating replication...")
resp, body, err := rs.client.SendPut(url, content, &httpClientsDetails)
if err != nil {
return err
Expand All @@ -42,7 +41,7 @@ func (rs *CreateReplicationService) performRequest(params *utils.UpdateReplicati
return err
}
log.Debug("Artifactory response:", resp.Status)
log.Info("Done " + operationString + " repository.")
log.Info("Done creating replication.")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions artifactory/services/utils/aqlquerybuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ func CreateAqlQueryForLatestCreated(repo, path string) string {
func prepareSearchPattern(pattern string, repositoryExists bool) string {
addWildcardIfNeeded(&pattern, repositoryExists)
// Remove parenthesis
pattern = strings.Replace(pattern, "(", "", -1)
pattern = strings.Replace(pattern, ")", "", -1)
pattern = strings.ReplaceAll(pattern, "(", "")
pattern = strings.ReplaceAll(pattern, ")", "")
return pattern
}

Expand Down
36 changes: 18 additions & 18 deletions artifactory/services/utils/aqlquerybuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ func TestBuildAqlSearchQuery(t *testing.T) {

func TestCommonParams(t *testing.T) {
artifactoryParams := CommonParams{}
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), false, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), false)

artifactoryParams.SortBy = []string{"Vava", "Bubu"}
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), true, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), true)

artifactoryParams.SortBy = nil
artifactoryParams.Limit = 0
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), false, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), false)

artifactoryParams.Limit = -3
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), false, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), false)

artifactoryParams.Limit = 3
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), true, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), true)

artifactoryParams.SortBy = []string{"Vava", "Bubu"}
assertIsSortLimitSpecBool(!includePropertiesInAqlForSpec(&artifactoryParams), true, t)
assertIsSortLimitSpecBool(t, !includePropertiesInAqlForSpec(&artifactoryParams), true)
}

func assertIsSortLimitSpecBool(actual, expected bool, t *testing.T) {
func assertIsSortLimitSpecBool(t *testing.T, actual, expected bool) {
if actual != expected {
t.Error("The function includePropertiesInAqlForSpec() expected to return " + strconv.FormatBool(expected) + " but returned " + strconv.FormatBool(actual) + ".")
}
Expand All @@ -76,20 +76,20 @@ func TestGetQueryReturnFields(t *testing.T) {
artifactoryParams := CommonParams{}
minimalFields := []string{"name", "repo", "path", "actual_md5", "actual_sha1", "sha256", "size", "type", "created", "modified"}

assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "property"), t)
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, SYMLINK), append(minimalFields, "property"), t)
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, NONE), minimalFields, t)
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "property"))
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, SYMLINK), append(minimalFields, "property"))
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, NONE), minimalFields)

artifactoryParams.SortBy = []string{"Vava"}
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, NONE), append(minimalFields, "Vava"), t)
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "Vava"), t)
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, SYMLINK), append(minimalFields, "Vava"), t)
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, NONE), append(minimalFields, "Vava"))
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "Vava"))
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, SYMLINK), append(minimalFields, "Vava"))

artifactoryParams.SortBy = []string{"Vava", "Bubu"}
assertEqualFieldsList(getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "Vava", "Bubu"), t)
assertEqualFieldsList(t, getQueryReturnFields(&artifactoryParams, ALL), append(minimalFields, "Vava", "Bubu"))
}

func assertEqualFieldsList(actual, expected []string, t *testing.T) {
func assertEqualFieldsList(t *testing.T, actual, expected []string) {
if len(actual) != len(expected) {
t.Error("The function getQueryReturnFields() expected to return the array:\n" + strings.Join(expected[:], ",") + ".\nbut returned:\n" + strings.Join(actual[:], ",") + ".")
}
Expand All @@ -109,11 +109,11 @@ func assertEqualFieldsList(actual, expected []string, t *testing.T) {
}

func TestBuildSortBody(t *testing.T) {
assertSortBody(buildSortQueryPart([]string{"bubu"}, ""), `"$asc":["bubu"]`, t)
assertSortBody(buildSortQueryPart([]string{"bubu", "kuku"}, ""), `"$asc":["bubu","kuku"]`, t)
assertSortBody(t, buildSortQueryPart([]string{"bubu"}, ""), `"$asc":["bubu"]`)
assertSortBody(t, buildSortQueryPart([]string{"bubu", "kuku"}, ""), `"$asc":["bubu","kuku"]`)
}

func assertSortBody(actual, expected string, t *testing.T) {
func assertSortBody(t *testing.T, actual, expected string) {
if actual != expected {
t.Error("The function buildSortQueryPart expected to return the string:\n'" + expected + "'.\nbut returned:\n'" + actual + "'.")
}
Expand Down
6 changes: 3 additions & 3 deletions artifactory/services/utils/artifactoryutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func BuildArtifactoryUrl(baseUrl, path string, params map[string]string) (string
parsedUrl.RawQuery = q.Encode()

// Semicolons are reserved as separators in some Artifactory APIs, so they'd better be encoded when used for other purposes
encodedUrl := strings.Replace(parsedUrl.String(), ";", url.QueryEscape(";"), -1)
encodedUrl := strings.ReplaceAll(parsedUrl.String(), ";", url.QueryEscape(";"))
return encodedUrl, nil
}

Expand Down Expand Up @@ -227,8 +227,8 @@ func ParseNameAndVersion(identifier string, useLatestPolicy bool) (string, strin
}
}
// Remove escape chars.
name = strings.Replace(name, "\\/", "/", -1)
version = strings.Replace(version, "\\/", "/", -1)
name = strings.ReplaceAll(name, "\\/", "/")
version = strings.ReplaceAll(version, "\\/", "/")
return name, version, nil
}

Expand Down
2 changes: 1 addition & 1 deletion artifactory/services/utils/deleteutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func WildcardToDirsPath(deletePattern, searchResult string) (string, error) {
return "", errors.New("delete pattern must end with \"/\"")
}

regexpPattern := "^" + strings.Replace(deletePattern, "*", "([^/]*|.*)", -1)
regexpPattern := "^" + strings.ReplaceAll(deletePattern, "*", "([^/]*|.*)")
r, err := regexp.Compile(regexpPattern)
if err != nil {
return "", errorutils.CheckError(err)
Expand Down
34 changes: 17 additions & 17 deletions artifactory/services/utils/deleteutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,44 @@ import (
func TestMatchingDelete(t *testing.T) {
var actual string
actual, _ = WildcardToDirsPath("s/*/path/", "s/a/path/b.zip")
assertDeletePattern("s/a/path/", actual, t)
assertDeletePattern(t, "s/a/path/", actual)
actual, _ = WildcardToDirsPath("s/*/path/", "s/a/b/c/path/b.zip")
assertDeletePattern("s/a/b/c/path/", actual, t)
assertDeletePattern(t, "s/a/b/c/path/", actual)
actual, _ = WildcardToDirsPath("s/a/*/", "s/a/b/path/b.zip")
assertDeletePattern("s/a/b/", actual, t)
assertDeletePattern(t, "s/a/b/", actual)
actual, _ = WildcardToDirsPath("s/*/path/*/", "s/a/path/a/b.zip")
assertDeletePattern("s/a/path/a/", actual, t)
assertDeletePattern(t, "s/a/path/a/", actual)
actual, _ = WildcardToDirsPath("s/*/path/*/", "s/a/a/path/a/b/c/d/b.zip")
assertDeletePattern("s/a/a/path/a/", actual, t)
assertDeletePattern(t, "s/a/a/path/a/", actual)
actual, _ = WildcardToDirsPath("s/*/", "s/a/a/path/a/b/c/d/b.zip")
assertDeletePattern("s/a/", actual, t)
assertDeletePattern(t, "s/a/", actual)
actual, _ = WildcardToDirsPath("s/*/a/*/", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/a/path/", actual, t)
assertDeletePattern(t, "s/a/a/path/", actual)
actual, _ = WildcardToDirsPath("s/*/a/*/*/", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/a/path/k/", actual, t)
assertDeletePattern(t, "s/a/a/path/k/", actual)
actual, _ = WildcardToDirsPath("s/*/*l*/*/*/", "s/a/l/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/l/path/k/", actual, t)
assertDeletePattern(t, "s/a/l/path/k/", actual)
actual, _ = WildcardToDirsPath("s/*/a*/", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/a/", actual, t)
assertDeletePattern(t, "s/a/a/", actual)
actual, _ = WildcardToDirsPath("s/a*/", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/", actual, t)
assertDeletePattern(t, "s/a/", actual)
actual, _ = WildcardToDirsPath("s/*/", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/", actual, t)
assertDeletePattern(t, "s/a/", actual)
actual, _ = WildcardToDirsPath("s/*/*path*/", "s/a/h/path/k/b/c/d/b.zip")
assertDeletePattern("s/a/h/path/", actual, t)
assertDeletePattern(t, "s/a/h/path/", actual)
actual, _ = WildcardToDirsPath("a/b/*********/*******/", "a/b/c/d/e.zip")
assertDeletePattern("a/b/c/d/", actual, t)
assertDeletePattern(t, "a/b/c/d/", actual)
_, err := WildcardToDirsPath("s/*/a/*/*", "s/a/a/path/k/b/c/d/b.zip")
assertDeletePatternErr("delete pattern must end with \"/\"", err.Error(), t)
assertDeletePatternErr(t, "delete pattern must end with \"/\"", err.Error())
}

func assertDeletePattern(expected, actual string, t *testing.T) {
func assertDeletePattern(t *testing.T, expected, actual string) {
if expected != actual {
t.Error("Wrong matching expected: `" + expected + "` Got `" + actual + "`")
}
}

func assertDeletePatternErr(expected, actual string, t *testing.T) {
func assertDeletePatternErr(t *testing.T, expected, actual string) {
if expected != actual {
t.Error("Wrong err message expected: `" + expected + "` Got `" + actual + "`")
}
Expand Down
2 changes: 1 addition & 1 deletion artifactory/services/utils/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (props *Properties) ToEncodedString(concatValues bool) string {
}
for _, value := range values {
if concatValues {
propValue := strings.Replace(value, multiValuesSeparator, fmt.Sprintf("\\%s", multiValuesSeparator), -1)
propValue := strings.ReplaceAll(value, multiValuesSeparator, fmt.Sprintf("\\%s", multiValuesSeparator))
jointProp = fmt.Sprintf("%s%s%s", jointProp, url.QueryEscape(propValue), url.QueryEscape(multiValuesSeparator))
} else {
jointProp = fmt.Sprintf("%s%s=%s%s", jointProp, url.QueryEscape(key), url.QueryEscape(value), propsSeparator)
Expand Down
4 changes: 2 additions & 2 deletions artifactory/services/utils/releasebundleutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package utils

import (
"fmt"
jwt "github.com/golang-jwt/jwt/v4"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/golang-jwt/jwt/v4"
"github.com/jfrog/jfrog-client-go/auth"
"github.com/jfrog/jfrog-client-go/http/jfroghttpclient"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"golang.org/x/crypto/openpgp"
"os"
"path/filepath"
"strings"
Expand Down
6 changes: 3 additions & 3 deletions artifactory/services/utils/repopathfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var repoPathFilesDataProvider = []createRepoPathFileTriplesTest{
func TestCreatePathFilePairs(t *testing.T) {
for _, sample := range pathFilesDataProvider {
t.Run(sample.pattern+"_recursive_"+strconv.FormatBool(sample.recursive), func(t *testing.T) {
validateRepoPathFile(createPathFilePairs("r", sample.pattern, sample.recursive), sample.expectedTriples, sample.pattern, t)
validateRepoPathFile(t, createPathFilePairs("r", sample.pattern, sample.recursive), sample.expectedTriples, sample.pattern)
})
}
}
Expand All @@ -101,12 +101,12 @@ func TestCreateRepoPathFileTriples(t *testing.T) {
repoPathFileTriples, singleRepo, err := createRepoPathFileTriples(sample.pattern, sample.recursive)
assert.NoError(t, err)
assert.Equal(t, sample.expectedSingleRepo, singleRepo)
validateRepoPathFile(repoPathFileTriples, sample.expectedTriples, sample.pattern, t)
validateRepoPathFile(t, repoPathFileTriples, sample.expectedTriples, sample.pattern)
})
}
}

func validateRepoPathFile(actual, expected []RepoPathFile, pattern string, t *testing.T) {
func validateRepoPathFile(t *testing.T, actual, expected []RepoPathFile, pattern string) {
if len(actual) != len(expected) {
t.Errorf("Wrong triple.\nPattern: %v\nExpected: %v\nActual: %v", pattern, expected, actual)
}
Expand Down
6 changes: 3 additions & 3 deletions artifactory/services/utils/searchutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestReduceTopChainDirResult(t *testing.T) {

oldMaxSize := utils.MaxBufferSize
defer func() { utils.MaxBufferSize = oldMaxSize }()
//Test buffer + sort
// Test buffer + sort
utils.MaxBufferSize = 3
reader = content.NewContentReader(filepath.Join(testDataPath, "reduce_top_chain_step4.json"), content.DefaultKey)
resultReader, err = ReduceTopChainDirResult(ResultItem{}, reader)
Expand All @@ -79,7 +79,7 @@ func TestReduceTopChainDirResult(t *testing.T) {
assert.True(t, isMatch)
readerCloseAndAssert(t, resultReader)

//Two files in the same folder and one is a prefix to another.
// Two files in the same folder and one is a prefix to another.
reader = content.NewContentReader(filepath.Join(testDataPath, "reduce_top_chain_step5.json"), content.DefaultKey)
resultReader, err = ReduceTopChainDirResult(ResultItem{}, reader)
assert.NoError(t, err)
Expand All @@ -89,7 +89,7 @@ func TestReduceTopChainDirResult(t *testing.T) {
assert.True(t, isMatch)
readerCloseAndAssert(t, resultReader)

//Two files in the same folder and one is a prefix to another and their folder.
// Two files in the same folder and one is a prefix to another and their folder.
reader = content.NewContentReader(filepath.Join(testDataPath, "reduce_top_chain_step6.json"), content.DefaultKey)
resultReader, err = ReduceTopChainDirResult(ResultItem{}, reader)
assert.NoError(t, err)
Expand Down
1 change: 0 additions & 1 deletion auth/cert/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func GetTransportWithLoadedCert(certificatesDirPath string, insecureTls bool, tr
ClientSessionCache: tls.NewLRUClientSessionCache(1),
InsecureSkipVerify: insecureTls,
}
transport.TLSClientConfig.BuildNameToCertificate()

return transport, nil
}
2 changes: 1 addition & 1 deletion distribution/services/utils/distributionutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestCreateBundleBody(t *testing.T) {
assert.Equal(t, "storing-repo", releaseBundleBody.StoringRepository)
assert.Equal(t, "Release bundle description", releaseBundleBody.Description)
assert.Equal(t, "Release notes", releaseBundleBody.ReleaseNotes.Content)
assert.Equal(t, ReleaseNotesSyntax(Asciidoc), releaseBundleBody.ReleaseNotes.Syntax)
assert.Equal(t, Asciidoc, releaseBundleBody.ReleaseNotes.Syntax)
assert.Len(t, releaseBundleBody.BundleSpec.Queries, 0)
}

Expand Down
Loading