JFrog Go Client

General

jfrog-client-go is a library which provides Go APIs to performs actions on JFrog Artifactory, Xray and Distribution from your Go application. The project is still relatively new, and its APIs may therefore change frequently between releases. The library can be used as a go-module, which should be added to your project's go.mod file. As a reference you may look at JFrog CLI' s go.mod file, which uses this library as a dependency.

Pull Requests

We welcome pull requests from the community.

Guidelines

  • If the existing tests do not already cover your changes, please add tests.
  • Pull requests should be created on the dev branch.
  • Please use gofmt for formatting the code before submitting the pull request.

Tests

To run the tests on the source code, you'll need a running JFrog instance. See the Prerequisites column in the Test Types section below for more information.
Use the following command with the below options to run the tests.
go test -v github.com/jfrog/jfrog-client-go/tests -timeout 0 [test-types] [flags]
If you'd like to run a specific test, add the test function name using the -run flag. For example:
go test -v github.com/jfrog/jfrog-client-go/tests -timeout 0 -run TestGetArtifactoryVersionWithCustomHttpClient -test.artifactory -rt.url=http://127.0.0.1:8081/artifactory -rt.user=admin -rt.password=password
Note: The tests create an Artifactory repository named jfrog-client-tests-repo1. Once the tests are completed, the content of this repository is deleted.

Flags

Test Types
Type
Description
Prerequisites
-test.artifactory
Artifactory tests
Artifactory Pro
-test.distribution
Distribution tests
Artifactory with Distribution
-test.xray
Xray tests
Artifactory with Xray
-test.pipelines
Pipelines tests
JFrog Pipelines
-test.access
Access tests
Artifactory Pro
-test.repositories
Access tests
Artifactory Pro
Connection Details
Flag
Description
-rt.url
[Default: http://localhost:8081/artifactory] Artifactory URL.
-ds.url
[Optional] JFrog Distribution URL.
-xr.url
[Optional] JFrog Xray URL.
-pipe.url
[Optional] JFrog Pipelines URL.
-access.url
[Optional] JFrog Access URL.
-rt.user
[Default: admin] Artifactory username.
-rt.password
[Default: password] Artifactory password.
-rt.apikey
[Optional] Artifactory API key.
-rt.sshKeyPath
[Optional] Ssh key file path. Should be used only if the Artifactory URL format is ssh://[domain]:port
-rt.sshPassphrase
[Optional] Ssh key passphrase.
-pipe.accessToken
[Optional] Pipelines access token.
-pipe.vcsToken
[Optional] Vcs token for Pipelines tests (should have admin permissions).
-pipe.vcsRepo
[Optional] Vcs full repo path for Pipelines tests (ex: "domain/myrepo").
-pipe.vcsBranch
[Optional] Vcs branch for Pipelines tests (ex: "main").
-access.token
[Optional] Access access token.
-ci.runId
[Optional] A unique identifier used as a suffix to create repositories in the tests.

General APIs

Setting the Logger

Default logger:
log.SetLogger(log.NewLogger(log.INFO, nil))
You may also log to a file, and/or add log prefixes as shown below:
var file *os.File
// Log flags as described in https://pkg.go.dev/log#pkg-constants.
logFlags := Ldate | Ltime
...
log.SetLogger(log.NewLoggerWithFlags(log.DEBUG, file, logFlags))

Setting the Temp Dir

The default temp dir used is 'os.TempDir()'. Use the following API to set a new temp dir:
fileutils.SetTempDirBase(filepath.Join("my", "temp", "path"))

Artifactory APIs

Creating Artifactory Service Manager

Creating Artifactory Details
rtDetails := auth.NewArtifactoryDetails()
rtDetails.SetUrl("http://localhost:8081/artifactory")
rtDetails.SetSshKeyPath("path/to/.ssh/")
rtDetails.SetApiKey("apikey")
rtDetails.SetUser("user")
rtDetails.SetPassword("password")
rtDetails.SetAccessToken("accesstoken")
// if client certificates are required
rtDetails.SetClientCertPath("path/to/.cer")
rtDetails.SetClientCertKeyPath("path/to/.key")
Creating Artifactory Details with Custom HTTP Client
proxyUrl, err := url.Parse("http://proxyIp:proxyPort")
myCustomClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
rtDetails := auth.NewArtifactoryDetails()
rtDetails.SetUrl("http://localhost:8081/artifactory")
rtDetails.SetSshKeysPath("path/to/.ssh/")
rtDetails.SetApiKey("apikey")
rtDetails.SetUser("user")
rtDetails.SetPassword("password")
rtDetails.SetAccessToken("accesstoken")
serviceConfig, err := config.NewConfigBuilder().
SetServiceDetails(rtDetails).
SetDryRun(false).
SetHttpClient(myCustomClient).
Build()
Creating Artifactory Service Config
serviceConfig, err := config.NewConfigBuilder().
SetServiceDetails(rtDetails).
SetCertificatesPath(certPath).
SetThreads(threads).
SetDryRun(false).
// Add [Context](https://golang.org/pkg/context/)
SetContext(ctx).
// Optionally overwrite the default dial timeout, which is set to 30 seconds.
SetDialTimeout(180 * time.Second).
// Optionally set the total HTTP request timeout.
SetOverallRequestTimeout(10 * time.Minute).
// Optionally overwrite the default HTTP retries, which is set to 3.
SetHttpRetries(8).
Build()
Creating New Artifactory Service Manager
rtManager, err := artifactory.New(serviceConfig)

Using Artifactory Services

Uploading Files to Artifactory
Using the UploadFiles() function, we can upload files and get the general statistics of the action (The actual number of successful and failed uploads), and the error value if it occurred.
params := services.NewUploadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "repo/path/"
params.AddVcsProps = false
params.BuildProps = "build.name=buildName;build.number=17;build.timestamp=1600856623553"
params.Recursive = true
params.Regexp = false
params.IncludeDirs = false
params.Flat = true
params.ExplodeArchive = false
params.Archive = "zip"
params.Deb = ""
params.Symlink = false
params.Exclusions = "(.*)a.zip"
// Retries default value: 3
params.Retries = 5
// The min file size in bytes for "checksum deploy".
// "Checksum deploy" is the action of calculating the file checksum locally, before
// the upload, and skipping the actual file transfer if the file already
// exists in Artifactory.
// MinChecksumDeploy default value: 10400
params.MinChecksumDeploy = 15360
// Set to false to disable all checksum calculation, including "checksum deploy".
// ChecksumsCalcEnabled default value: true
params.ChecksumsCalcEnabled = false
// Attach properties to the uploaded files
targetProps := utils.NewProperties()
targetProps.AddProperty("key1", "val1")
params.TargetProps = targetProps
totalUploaded, totalFailed, err := rtManager.UploadFiles(params)
Downloading Files from Artifactory
Using the DownloadFiles() function, we can download files and get the general statistics of the action (The actual number of files downloaded, and the number of files we expected to download). In addition, we get the error value if it occurred.
params := services.NewDownloadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the downloaded files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.IncludeDirs = false
params.Flat = false
params.Explode = false
params.Symlink = true
params.ValidateSymlink = false
params.Exclusions = "(.*)a.zip"
// Retries default value: 3
params.Retries = 5
// SplitCount default value: 3
params.SplitCount = 2
// MinSplitSize default value: 5120
params.MinSplitSize = 7168
totalDownloaded, totalFailed, err := rtManager.DownloadFiles(params)
Downloading Release Bundles v1 from Artifactory
Using the DownloadFiles() function, we can download release bundles v1 and get the general statistics of the action (The actual number of files downloaded, and the number of files we expected to download). In addition, we get the error value if it occurred.
It is possible to validate the downloaded release bundle's files by providing a local path to a GPG public key file (the public GPG key should of course correspond to the private GPG key which was used to sign the release bundle).
params := services.NewDownloadParams()
// Path on the local file system to which the files should be downloaded.
params.Target = "target/path/"
// Bundle's name and version should be separated with "/".
params.Bundle = "bundleName/10"
// Optional GPG validation
params.PublicGpgKey = "public/key/file/path"
totalDownloaded, totalFailed, err := rtManager.DownloadFiles(params)
Read more about GPG signing release bundles v1 here.
Uploading and Downloading Files with Summary
The methods UploadFilesWithSummary() and DownloadFilesWithSummary() are similar to UploadFlies() and DownloadFlies(), but return an OperationSummary struct, which allows iterating over the details of the uploaded/downloaded files. The OperationSummary struct contains:
  • TotalSucceeded - the number of successful uploads/downloads
  • TotalFailed - the number of failed uploads/downloads
  • TransferDetailsReader - a ContentReader of FileTransferDetails structs, with a struct for each successful transfer of file
  • ArtifactsDetailsReader - a ContentReader of ArtifactDetails structs, with a struct for each artifact in Artifactory that was uploaded/downloaded successfully
The ContentReaders can be closed separately by calling Close() on each of them, or they both can be closed at once by calling Close() on the OperationSummary struct.
params := services.NewUploadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "repo/path/"
summary, err := rtManager.UploadFilesWithSummary(params)
defer summary.Close()
reader, totalDownloaded, totalExpected, err := rtManager.DownloadFilesWithResultReader(params)
// Iterate over each file
for currentFileInfo := new(utils.FileInfo); reader.NextRecord(currentFileInfo) == nil; currentFileInfo = new(utils.FileInfo) {
fmt.Printf("File path: %s\n", currentFileInfo.LocalPath)
}
if err := reader.GetError(); err != nil {
return err
}
Read more about ContentReader.
Copying Files in Artifactory
params := services.NewMoveCopyParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.Flat = false
rtManager.Copy(params)
Moving Files in Artifactory
params := services.NewMoveCopyParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.Flat = false
rtManager.Move(params)
Deleting Files from Artifactory
params := services.NewDeleteParams()
params.Pattern = "repo/*/*.zip"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
pathsToDelete, err := rtManager.GetPathsToDelete(params)
if err != nil {
return err
}
defer pathsToDelete.Close()
rtManager.DeleteFiles(pathsToDelete)
Read more about ContentReader.
Searching Files in Artifactory
params := services.NewSearchParams()
params.Pattern = "repo/*/*.zip"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
reader, err := rtManager.SearchFiles(params)
if err != nil {
return err
}
defer reader.Close()
Read more about ContentReader.
Setting Properties on Files in Artifactory
searchParams = services.NewSearchParams()
searchParams.Recursive = true
searchParams.IncludeDirs = false
reader, err = rtManager.SearchFiles(searchParams)
if err != nil {
return err
}
defer reader.Close()
propsParams = services.NewPropsParams()
propsParams.Pattern = "repo/*/*.zip"
propsParams.Reader = reader
// Filter the files by properties.
propsParams.Props = "key=value"
rtManager.SetProps(propsParams)
Read more about ContentReader.
Deleting Properties from Files in Artifactory
searchParams = services.NewSearchParams()
searchParams.Recursive = true
searchParams.IncludeDirs = false
resultItems, err = rtManager.SearchFiles(searchParams)
if err != nil {
return err
}
defer reader.Close()
propsParams = services.NewPropsParams()
propsParams.Pattern = "repo/*/*.zip"
propsParams.Reader = reader
// Filter the files by properties.
propsParams.Props = "key=value"
rtManager.DeleteProps(propsParams)
Getting Properties from Files in Artifactory
rtManager.GetItemProperties("repo/path/file")
Read more about ContentReader.
Publishing Build Info to Artifactory
buildInfo := &buildinfo.BuildInfo{}
// Optional Artifactory project key
projectKey := "my-project-key"
...
rtManager.PublishBuildInfo(buildInfo, projectKey)
Fetching Build Info from Artifactory
buildInfoParams := services.NewBuildInfoParams{}
buildInfoParams.BuildName = "buildName"
buildInfoParams.BuildNumber = "LATEST"
// Optional Artifactory project key
buildInfoParams.ProjectKey = "my-project-key"
rtManager.GetBuildInfo(buildInfoParams)
Promoting Published Builds in Artifactory
params := services.NewPromotionParams()
params.BuildName = "buildName"
params.BuildNumber = "10"
params.TargetRepo = "target-repo"
params.Status = "status"
params.Comment = "comment"
params.Copy = &trueValue
params.FailFast = true
params.IncludeDependencies = &falseValue
params.SourceRepo = "source-repo"
// Optional Artifactory project key
params.ProjectKey = "my-project-key"
rtManager.PromoteBuild(params)
Promoting a Docker Image in Artifactory
sourceDockerImage := "hello-world"
sourceRepo := "docker-local-1"
targetRepo := "docker-local-2"
params := services.NewDockerPromoteParams(sourceDockerImage, sourceRepo, targetRepo)
// Optional parameters:
params.TargetDockerImage = "target-docker-image"
params.SourceTag = "42"
params.TargetTag = "43"
params.Copy = true
rtManager.PromoteDocker(params)
Triggering Build Scanning with JFrog Xray
params := services.NewXrayScanParams()
params.BuildName = buildName
params.BuildNumber = buildNumber
rtManager.XrayScanBuild(params)
Discarding Old Builds
params := services.NewDiscardBuildsParams()
params.BuildName = "buildName"
params.MaxDays = "max-days"
params.MaxBuilds = "max-builds"
params.ExcludeBuilds = "1,2"
params.DeleteArtifacts = false
params.Async = false
// Optional Artifactory project key
projectKey := "my-project-key"
rtManager.DiscardBuilds(params)
Cleaning Unreferenced Git LFS Files from Artifactory
params := services.NewGitLfsCleanParams()
params.Refs = "refs/remotes/*"
params.Repo = "my-project-lfs"
params.GitPath = "path/to/git"
reader,err := rtManager.GetUnreferencedGitLfsFiles(params)
defer reader.Close()
rtManager.DeleteFiles(reader)
Executing AQLs
rtManager.Aql(aql string)
Reading Files in Artifactory
rtManager.ReadRemoteFile(FilePath string)
Creating an Access Token
params := services.NewCreateTokenParams()
params.Scope = "api:* member-of-groups:readers"
params.Username = "user"
params.ExpiresIn = 3600 // default -1 (use server default)
params.GrantType = "client_credentials"
params.Refreshable = true
params.Audience = "jfrt@<serviceID1> jfrt@<serviceID2>"
results, err := rtManager.CreateToken(params)
Fetching Access Tokens
results, err := rtManager.GetTokens()
Fetching Access Tokens of a User
results, err := rtManager.GetUserTokens(username)
Refreshing an Access Token
params := services.NewRefreshTokenParams()
params.AccessToken = "<access token>"
params.RefreshToken = "<refresh token>"
params.Token.Scope = "api:*"
params.Token.ExpiresIn = 3600
results, err := rtManager.RefreshToken(params)
Revoking an Access Token
params := services.NewRevokeTokenParams()
// Provide either TokenId or Token
params.TokenId = "<token id>"
// params.Token = "access token"
err := rtManager.RevokeToken(params)
Create API Key
// Returns an error if API key already exists - use RegenerateAPIKey instead.
apiKey, err := rtManager.CreateAPIKey()
Regenerate API Key
apiKey, err := rtManager.RegenerateAPIKey()
Get API Key
apiKey, err := rtManager.GetAPIKey()
Creating and Updating Local Repository
You can create and update a local repository for the following package types:
Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle, Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift, Vagrant, and Yum.
Each package type has its own parameters struct, can be created using the method New<packageType>LocalRepositoryParams().
Example for creating local Generic repository:
params := services.NewGenericLocalRepositoryParams()
params.Key = "generic-repo"
params.Description = "This is a public description for generic-repo"
params.Notes = "These are internal notes for generic-repo"
params.RepoLayoutRef = "simple-default"
params.ArchiveBrowsingEnabled = true
params.XrayIndex = true
params.IncludesPattern = "**/*"
params.ExcludesPattern = "excludedDir/*"
params.DownloadRedirect = true
err = servicesManager.CreateLocalRepository().Generic(params)
You can also create a local repository with basic local params:
params := services.NewLocalRepositoryBaseParams()
params.Key = "generic-repo"
params.PackageType = "generic"
params.Description = "This is a public description for generic-repo"
err := servicesManager.CreateLocalRepository(params)
Updating local Generic repository:
err = servicesManager.UpdateLocalRepository().Generic(params)
Creating and Updating Remote Repository
You can create and update a remote repository for the following package types:
Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle, Helm, Ivy, Maven, Npm, Nuget, Opkg, P2, Puppet, Pypi, Rpm, Sbt, Swift, Vcs, and Yum.
Each package type has its own parameters struct, can be created using the method New<packageType>RemoteRepositoryParams().
Example for creating remote Maven repository:
params := services.NewMavenRemoteRepositoryParams()
params.Key = "maven-central-remote"
params.Url = "https://repo.maven.apache.org"
params.RepoLayoutRef = "maven-2-default"
params.Description = "A caching proxy repository for Maven central"
params.HandleSnapshot = false
params.HandleReleases = true
params.FetchJarsEagerly = true
params.XrayIndex = true
params.AssumedOfflinePeriodSecs = 600
params.SuppressPomConsistencyChecks = true
params.RemoteRepoChecksumPolicyType = "pass-thru"
err = servicesManager.CreateRemoteRepository().Maven(params)
Updating remote Maven repository:
err = servicesManager.UpdateRemoteRepository().Maven(params)
You can also create a remote repository with basic remote params:
params := services.NewRemoteRepositoryBaseParams()
params.Key = "remote-repo"
params.Url = "https://repo.maven.apache.org"
err := servicesManager.CreateRemoteRepository(params)
Creating and Updating Virtual Repository
You can create and update a virtual repository for the following package types:
Alpine, Bower, Cran, Chef, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle, Helm, Ivy, Maven, Npm, Nuget, P2, Puppet, Pypi, Rpm, Sbt, Swift and Yum.
Each package type has its own parameters struct, can be created using the method New<packageType>VirtualRepositoryParams().
Example for creating virtual Go repository:
params := services.NewGoVirtualRepositoryParams()
params.Description = "This is an aggregated repository for several go repositories"
params.RepoLayoutRef = "go-default"
params.Repositories = {"gocenter-remote", "go-local"}
params.DefaultDeploymentRepo = "go-local"
params.ExternalDependenciesEnabled = true
params.ExternalDependenciesPatterns = {"**/github.com/**", "**/golang.org/**", "**/gopkg.in/**"}
params.ArtifactoryRequestsCanRetrieveRemoteArtifacts = true
err = servicesManager.CreateVirtualRepository().Go(params)
You can also create a virtual repository with basic virtual params:
params := services.NewVirtualRepositoryBaseParams()
params.Key = "generic-repo"
params.PackageType = "generic"
params.Description = "This is a public description for generic-repo"
params.Repositories = string[]{"remote-repo","local-repo"}
err := servicesManager.CreateVirtualRepository(params)
Updating virtual Go repository:
err = servicesManager.UpdateVirtualRepository().Go(params)
Creating and Updating Federated Repository
You can create and update a federated repository for the following package types:
Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle, Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift Vagrant and Yum
Each package type has its own parameters struct, can be created using the method New<packageType>FederatedRepositoryParams().
Example for creating federated Generic repository:
params := services.NewGenericFederatedRepositoryParams()
params.Key = "generic-repo"
params.Description = "This is a public description for generic-repo"
params.Notes = "These are internal notes for generic-repo"
params.RepoLayoutRef = "simple-default"
params.ArchiveBrowsingEnabled = true
params.XrayIndex = true
params.IncludesPattern = "**/*"
params.ExcludesPattern = "excludedDir/*"
params.DownloadRedirect = true
params.Members = []services.FederatedRepositoryMemberParams{
{Url: "http://targetartifactory/artifactory/federatedRepositoryName", Enabled: true},
}
err = servicesManager.CreateFederatedRepository().Generic(params)
You can also create a federated repository with basic federated params:
params := services.NewFederatedRepositoryBaseParams()
params.Key = "generic-repo"
params.PackageType = "generic"
params.Description = "This is a public description for generic-repo"
params.Members = []services.FederatedRepositoryMemberParams{
{Url: "http://targetartifactory/artifactory/federatedRepositoryName", Enabled: true},
}
err := servicesManager.CreateFederatedRepository(params)
Updating federated Generic repository:
err = servicesManager.UpdateFederatedRepository().Generic(params)
Removing a Repository
You can remove a repository from Artifactory using its key:
servicesManager.DeleteRepository("generic-repo")
Getting Repository Details
You can get repository details from Artifactory using its key, and the desired params struct. The function expects to get the repo key (name) and a pointer to a param struct that will be filled up. The param struct should contain the desired params fields corresponded to the Artifactory REST API:
repoDetails = services.RepositoryDetails{}
err := servicesManager.GetRepository("maven-repo", &repoDetails)
repoDetails = services.LocalRepositoryBaseParams{}
err := servicesManager.GetRepository("maven-repo", &repoDetails)
repoDetails = services.MavenLocalRepositoryParams{}
err := servicesManager.GetRepository("maven-repo", &repoDetails)
services.RepositoryDetails
Getting All Repositories
You can get all repositories from Artifactory:
servicesManager.GetAllRepositories()
You can get all repositories from Artifactory filtered according to theirs type and/or theirs package type:
params := services.NewRepositoriesFilterParams()
params.RepoType = "remote"
params.PackageType = "maven"
err := servicesManager.GetAllRepositoriesFiltered(params)
Check if Repository Exists
You can check whether a repository exists in Artifactory:
exists, err := servicesManager.IsRepoExists()
Creating and Updating Repository Replications
Example of creating a repository replication:
params := services.NewCreateReplicationParams()
// Source replication repository.
params.RepoKey = "my-repository"
params.CronExp = "0 0 12 * * ?"
params.Username = "admin"
params.Password = "password"
params.Url = "http://localhost:8081/artifactory/remote-repo"
params.Enabled = true
params.SocketTimeoutMillis = 15000
params.EnableEventReplication = true
params.SyncDeletes = true
params.SyncProperties = true
params.SyncStatistics = true
params.PathPrefix = "/path/to/repo"
err = servicesManager.CreateReplication(params)
Example of updating a local repository replication:
params := services.NewUpdateReplicationParams()
// Source replication repository.
params.RepoKey = "my-repository"
params.CronExp = "0 0 12 * * ?"
params.Enabled = true
params.SocketTimeoutMillis = 15000
params.EnableEventReplication = true
params.SyncDeletes = true
params.SyncProperties = true
params.SyncStatistics = true
params.PathPrefix = "/path/to/repo"
err = servicesManager.UpdateReplication(params)
Getting a Repository Replication
You can get a repository replication configuration from Artifactory using its key:
replicationConfiguration, err := servicesManager.GetReplication("my-repository")
Removing a Repository Replication
You can remove a repository replication configuration from Artifactory using its key:
err := servicesManager.DeleteReplication("my-repository")
Converting a Local Repository to a Federated Repository
You can convert a local repository to a federated repository using its key:
err := servicesManager.ConvertLocalToFederatedRepository("my-repository")
Triggering a Full Federated Repository Synchronisation
You can trigger a full federated repository synchronisation for all members using its key:
err := servicesManager.TriggerFederatedRepositoryFullSyncAll("my-repository")
You can also trigger a full federated repository synchronisation for a specific member using its key and the members URL
err := servicesManager.TriggerFederatedRepositoryFullSyncMirror("my-repository", "http://localhost:8081/artifactory/my-repository")
Creating and Updating Permission Targets
You can create or update a permission target in Artifactory. Permissions are set according to the following conventions: read, write, annotate, delete, manage, managedXrayMeta, distribute For repositories You can specify the name "ANY" in order to apply to all repositories, "ANY REMOTE" for all remote repositories or "ANY LOCAL" for all local repositories.
Creating a new permission target :
params := services.NewPermissionTargetParams()
params.Name = "java-developers"
params.Repo = &services.PermissionTargetSection{}
params.Repo.Repositories = []string{"ANY REMOTE", "local-repo1", "local-repo2"}
params.Repo.ExcludePatterns = []string{"dir/*"}
params.Repo.Actions = &services.Actions{}
params.Repo.Actions.Users = map[string][]string{
"user1": {"read", "write"},
"user2": {"write", "annotate", "read"},
}
params.Repo.Actions.Groups = map[string][]string{
"group1": {"manage", "read", "annotate"},
}