Skip to content

Commit

Permalink
artifactory support
Browse files Browse the repository at this point in the history
  • Loading branch information
rusenask committed Aug 4, 2017
1 parent c2590d5 commit 315973e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
11 changes: 4 additions & 7 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func newFromTransport(registryUrl, username, password string, transport http.Rou
}

if err := registry.Ping(); err != nil {
return nil, err
registry.Logf("registry failed ping request, error: %s", err)
}

return registry, nil
Expand All @@ -108,13 +108,10 @@ func (r *Registry) url(pathTemplate string, args ...interface{}) string {

func (r *Registry) Ping() error {
url := r.url("/v2/")
// r.Logf("registry.ping url=%s", url)
resp, err := r.Client.Get(url)
if resp != nil {
defer resp.Body.Close()
}
if err != nil {

return err
}
return err
resp.Body.Close()
return nil
}
40 changes: 40 additions & 0 deletions registry/registry_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package registry

import (
"testing"
)

func TestGetDigestDockerHub(t *testing.T) {
client, err := New("https://index.docker.io", "", "")
if err != nil {
t.Errorf("failed to get registry, error: %s", err)
}

tags, err := client.Tags("karolisr/keel")
if err != nil {
t.Errorf("failed to get tags, error: %s", err)
}

if len(tags) == 0 {
t.Errorf("no tags?")
}
}

// Supply authentication details to test this
func TestGetDigestArtifactory(t *testing.T) {
t.Skip()

client, err := New("https://keel-docker-local.jfrog.io", "", "")
if err != nil {
t.Fatalf("failed to get registry, error: %s", err)
}

tags, err := client.Tags("webhook-demo")
if err != nil {
t.Fatalf("failed to get tags, error: %s", err)
}

if len(tags) == 0 {
t.Errorf("no tags?")
}
}

0 comments on commit 315973e

Please sign in to comment.