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

feat: use Dockerhub API to poll for digest change #19

Merged
merged 25 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"github.com/stretchr/testify/assert"
)

// test ShouldDeploy for a multitude of conditions
/*
Test ShouldDeploy for a multitude of conditions.
*/
func TestAutoDeployLatestTag(t *testing.T) {
te := SetUpClientTest(t)
defer te.TearDown()
Expand Down Expand Up @@ -66,7 +68,7 @@ func TestAutoDeployLatestTag(t *testing.T) {

shouldDeploy, _ = te.Clients.ShouldDeploy(te.TestRepoName)
tagToDeploy, _ = te.Clients.GetFormattedPinnedTag(te.TestRepoName)
// should not deploy as the image is not changed, even though
// should not deploy as all tags are based on the digest "latest", even though
// the pinned tag is changed
assert.False(t, shouldDeploy)
assert.Equal(t, "test", tagToDeploy)
Expand Down
9 changes: 7 additions & 2 deletions client/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,13 @@ func (te *testEngine) TearDown() {
te.Ts.Close()
}

// named tag is what it will appear as in the docker registryDomain
// actual tag is what the tag is based on (this is for testing purposes only)
/*
For the following tests, note that the base image tags "latest" and "alpine"
are taken to be equivalent to image digest strings in the mock image-tag store.
The mock image tag store is used in turn because we are mocking the Dockerhub API server.
While in the real world, image digests are SHA hashes, this still allows us to test
the auto-deploy behaviour as we use the digest string to check if the underlying image is changed.
*/
func (te *testEngine) PushNewTag(namedTag, actualTag string) {
_, registryDomain, registryPrefix, _ := utils.ExtractRegistryInfo(te.Conf, te.TestRepoName)
mockImageName := utils.ConstructImageName(registryDomain, registryPrefix, te.TestRepoName, namedTag)
Expand Down