-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package client | ||
|
||
// Docker represents the data used for Repositories of type Docker | ||
type Docker struct { | ||
V1Enabled bool `json:"v1Enabled"` | ||
ForceBasicAuth bool `json:"forceBasicAuth"` | ||
HTTPPort int `json:"httpPort"` | ||
HTTPSPort int `json:"httpsPort"` | ||
} | ||
|
||
func (c client) RepositoryDockerCreate(repo Repository, repoType string) error { | ||
return c.RepositoryCreate(repo, "docker", repoType) | ||
} | ||
|
||
func (c client) RepositoryDockerRead(id string, repoType string) (*Repository, error) { | ||
return c.RepositoryRead(id, "docker", repoType) | ||
} | ||
|
||
func (c client) RepositoryDockerUpdate(id string, repo Repository, repoType string) error { | ||
return c.RepositoryUpdate(id, repo, "docker", repoType) | ||
} | ||
|
||
func (c client) RepositoryDockerDelete(id string) error { | ||
return c.RepositoryDelete(id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package client | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func getTestRepositoryDocker(name string) Repository { | ||
return Repository{ | ||
Name: name, | ||
Online: true, | ||
Cleanup: RepositoryCleanup{ | ||
PolicyNames: []string{"weekly-cleanup"}, | ||
}, | ||
Docker: &Docker{ | ||
V1Enabled: false, | ||
ForceBasicAuth: true, | ||
HTTPPort: 8082, | ||
HTTPSPort: 8083, | ||
}, | ||
Storage: RepositoryStorage{ | ||
BlobStoreName: "default", | ||
StrictContentTypeValidation: true, | ||
WritePolicy: "allow_once", | ||
}, | ||
} | ||
} | ||
|
||
func TestRepositoryDockerHosted(t *testing.T) { | ||
client := NewClient(getDefaultConfig()) | ||
repo := getTestRepositoryDocker("test-docker-repo-hosted") | ||
|
||
err := client.RepositoryDockerCreate(repo, "hosted") | ||
assert.Nil(t, err) | ||
|
||
updatedRepo := repo | ||
updatedRepo.Online = false | ||
|
||
err = client.RepositoryDockerUpdate(repo.Name, updatedRepo, "hosted") | ||
assert.Nil(t, err) | ||
|
||
err = client.RepositoryDockerDelete(repo.Name) | ||
assert.Nil(t, err) | ||
} |