Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ jobs:
AZURE_STORAGE_ACCESS_KEY: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
JFROG_URL: ${{ secrets.JFROG_URL }}
JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }}
JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
run: |
sudo mkdir -p /srv ; sudo chown runner /srv
mkdir -p out/coverage
Expand Down
18 changes: 18 additions & 0 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -41,6 +42,11 @@ func createTestConfig() *os.File {
jsonString, err := json.Marshal(gin.H{
"architectures": []string{},
"enableMetricsEndpoint": true,
"JFrogPublishEndpoints": gin.H{
"test-jfrog": gin.H{
"url": "http://jfrog.example.com",
},
},
})
if err != nil {
return nil
Expand Down Expand Up @@ -173,3 +179,15 @@ func (s *APISuite) TestTruthy(c *C) {
c.Check(truthy(-1), Equals, true)
c.Check(truthy(gin.H{}), Equals, true)
}

func (s *APISuite) TestGetJFrogEndpoints(c *C) {
response, err := s.HTTPRequest("GET", "/api/jfrog", nil)
c.Assert(err, IsNil)
c.Check(response.Code, Equals, 200)

var endpoints []string
err = json.Unmarshal(response.Body.Bytes(), &endpoints)
c.Assert(err, IsNil)
sort.Strings(endpoints)
c.Check(endpoints, DeepEquals, []string{"test-jfrog"})
}
21 changes: 21 additions & 0 deletions api/jfrog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package api

import (
"github.com/gin-gonic/gin"
)

// @Summary JFrog repositories
// @Description **Get list of JFrog repositories**
// @Description
// @Description List configured JFrog publish endpoints.
// @Tags Status
// @Produce json
// @Success 200 {array} string "List of JFrog publish endpoints"
// @Router /api/jfrog [get]
func apiJFrogList(c *gin.Context) {
keys := []string{}
for k := range context.Config().JFrogPublishRoots {
keys = append(keys, k)
}
c.JSON(200, keys)
}
1 change: 1 addition & 0 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func Router(c *ctx.AptlyContext) http.Handler {

{
api.GET("/s3", apiS3List)
api.GET("/jfrog", apiJFrogList)
}

{
Expand Down
13 changes: 13 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/aptly-dev/aptly/deb"
"github.com/aptly-dev/aptly/files"
"github.com/aptly-dev/aptly/http"
"github.com/aptly-dev/aptly/jfrog"
"github.com/aptly-dev/aptly/pgp"
"github.com/aptly-dev/aptly/s3"
"github.com/aptly-dev/aptly/swift"
Expand Down Expand Up @@ -461,6 +462,18 @@ func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedSto
if err != nil {
Fatal(err)
}
} else if strings.HasPrefix(name, "jfrog:") {
params, ok := context.config().JFrogPublishRoots[name[6:]]
if !ok {
Fatal(fmt.Errorf("published JFrog storage %v not configured", name[6:]))
}

var err error
publishedStorage, err = jfrog.NewPublishedStorage(
name[6:], params)
if err != nil {
Fatal(err)
}
} else {
Fatal(fmt.Errorf("unknown published storage format: %v", name))
}
Expand Down
37 changes: 37 additions & 0 deletions context/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"reflect"
"testing"

"github.com/aptly-dev/aptly/utils"
"github.com/smira/flag"

. "gopkg.in/check.v1"
Expand Down Expand Up @@ -87,3 +88,39 @@ func (s *AptlyContextSuite) TestGetPublishedStorageBadFS(c *C) {
&FatalError{ReturnCode: 1, Message: fmt.Sprintf("error loading config file %s/.aptly.conf: invalid yaml (EOF) or json (EOF)",
os.Getenv("HOME"))})
}

func (s *AptlyContextSuite) TestGetPublishedStorageJFrogConfigured(c *C) {
prevConfig := utils.Config
defer func() { utils.Config = prevConfig }()

s.context.configLoaded = true
utils.Config.RootDir = c.MkDir()
utils.Config.JFrogPublishRoots = map[string]utils.JFrogPublishRoot{
"test": {
Repository: "aptly-repo",
Url: "https://example.jfrog.local/artifactory",
AccessToken: "token",
Prefix: "public",
},
}

storage := s.context.GetPublishedStorage("jfrog:test")
c.Assert(storage, NotNil)
c.Assert(fmt.Sprintf("%v", storage), Equals, "jfrog:aptly-repo:public")

// Ensure we get the cached object on repeated lookups.
storageAgain := s.context.GetPublishedStorage("jfrog:test")
c.Assert(storageAgain, Equals, storage)
}

func (s *AptlyContextSuite) TestGetPublishedStorageJFrogMissing(c *C) {
prevConfig := utils.Config
defer func() { utils.Config = prevConfig }()

s.context.configLoaded = true
utils.Config.JFrogPublishRoots = map[string]utils.JFrogPublishRoot{}

c.Assert(func() { s.context.GetPublishedStorage("jfrog:missing") },
FatalErrorPanicMatches,
&FatalError{ReturnCode: 1, Message: "published JFrog storage missing not configured"})
}
23 changes: 23 additions & 0 deletions debian/aptly.conf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,29 @@ filesystem_publish_endpoints:
#
# `aptly publish snapshot wheezy-main s3:test:`
#

# JFrog Artifactory Endpoint Support
#
# aptly can be configured to publish repositories directly to JFrog Artifactory. First,
# publishing endpoints should be described in the aptly configuration file.
#
# In order to publish to JFrog, specify endpoint as `jfrog:endpoint-name:` before
# publishing prefix on the command line, e.g.:
#
# `aptly publish snapshot wheezy-main jfrog:test:`
#
jfrog_publish_endpoints:
# # Endpoint Name
# test:
# # JFrog URL
# url: "https://artifactory.example.com/artifactory/"
# # Repository
# repository: apt-local
# # Username
# username: admin
# # Password
# password: password

s3_publish_endpoints:
# # Endpoint Name
# test:
Expand Down
2 changes: 1 addition & 1 deletion docs/Publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Publish snapshot or local repo as Debian repository to be used as APT source on

The published repository is signed with the user's GnuPG key.

Repositories can be published to local directories, Amazon S3 buckets, Azure or Swift Storage.
Repositories can be published to local directories, Amazon S3 buckets, Azure, Swift, or JFrog Artifactory Storage.

#### GPG Keys

Expand Down
44 changes: 38 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aptly-dev/aptly

go 1.24.0
go 1.24.6

require (
github.com/AlekSi/pointer v1.1.0
Expand All @@ -13,8 +13,8 @@ require (
github.com/h2non/filetype v1.1.3
github.com/jlaffaye/ftp v0.2.0 // indirect
github.com/kjk/lzma v0.0.0-20120628231508-2a7c55cad4a2
github.com/klauspost/compress v1.17.9
github.com/klauspost/pgzip v1.2.5
github.com/klauspost/compress v1.17.11
github.com/klauspost/pgzip v1.2.6
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-shellwords v1.0.12
Expand Down Expand Up @@ -42,10 +42,14 @@ require (

require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect
Expand All @@ -66,9 +70,16 @@ require (
github.com/cloudflare/circl v1.6.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/forPelevin/gomoji v1.3.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-git/v5 v5.14.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
Expand All @@ -77,33 +88,52 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jfrog/archiver/v3 v3.6.1 // indirect
github.com/jfrog/build-info-go v1.11.0 // indirect
github.com/jfrog/gofrog v1.7.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ulikunitz/xz v0.5.14 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/text v0.31.0 // indirect
Expand All @@ -112,19 +142,21 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.64.1 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.1
github.com/ProtonMail/go-crypto v1.0.0
github.com/ProtonMail/go-crypto v1.1.6
github.com/aws/aws-sdk-go-v2 v1.32.5
github.com/aws/aws-sdk-go-v2/config v1.28.5
github.com/aws/aws-sdk-go-v2/credentials v1.17.46
github.com/aws/aws-sdk-go-v2/service/s3 v1.67.1
github.com/aws/smithy-go v1.22.1
github.com/google/uuid v1.6.0
github.com/jfrog/jfrog-client-go v1.55.0
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.3
Expand Down
Loading
Loading