-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker): Fixed imageId parsing and digest support (#7053)
- Loading branch information
1 parent
df8d181
commit 59259a9
Showing
4 changed files
with
121 additions
and
10 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
102 changes: 102 additions & 0 deletions
102
app/scripts/modules/docker/src/image/DockerImageUtils.spec.ts
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,102 @@ | ||
import { DockerImageUtils } from './DockerImageUtils'; | ||
|
||
describe('imageId parsing', () => { | ||
it('parses undefined without choking', () => { | ||
expect(DockerImageUtils.splitImageId(undefined)).toEqual({ | ||
organization: '', | ||
repository: '', | ||
digest: undefined, | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with no organization and no tag/digest', () => { | ||
const imageId = 'image'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: '', | ||
repository: 'image', | ||
digest: undefined, | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with tag but no organization', () => { | ||
const imageId = 'image:tag'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: '', | ||
repository: 'image', | ||
digest: undefined, | ||
tag: 'tag', | ||
}); | ||
}); | ||
|
||
it('parses image with no organization and correctly distinguishes digest from tag', () => { | ||
const imageId = 'image:sha256:abc123'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: '', | ||
repository: 'image', | ||
digest: 'sha256:abc123', | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with organization but no tag/digest', () => { | ||
const imageId = 'organization/image'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'organization', | ||
repository: 'organization/image', | ||
digest: undefined, | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with organization and tag', () => { | ||
const imageId = 'organization/image:tag'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'organization', | ||
repository: 'organization/image', | ||
digest: undefined, | ||
tag: 'tag', | ||
}); | ||
}); | ||
|
||
it('parses image with organization and correctly distinguishes digest from tag', () => { | ||
const imageId = 'organization/image:sha256:abc123'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'organization', | ||
repository: 'organization/image', | ||
digest: 'sha256:abc123', | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with nested organization', () => { | ||
const imageId = 'nested/organization/image'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'nested/organization', | ||
repository: 'nested/organization/image', | ||
digest: undefined, | ||
tag: undefined, | ||
}); | ||
}); | ||
|
||
it('parses image with tag and nested organization', () => { | ||
const imageId = 'nested/organization/image:tag'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'nested/organization', | ||
repository: 'nested/organization/image', | ||
digest: undefined, | ||
tag: 'tag', | ||
}); | ||
}); | ||
|
||
it('parses image with nested organization and correctly distinguishes digest from tag', () => { | ||
const imageId = 'nested/organization/image:sha256:abc123'; | ||
expect(DockerImageUtils.splitImageId(imageId)).toEqual({ | ||
organization: 'nested/organization', | ||
repository: 'nested/organization/image', | ||
digest: 'sha256:abc123', | ||
tag: undefined, | ||
}); | ||
}); | ||
}); |
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