Skip to content

Commit

Permalink
WIP - add feature to not list untagged images.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjsr committed Jul 15, 2024
1 parent 8273f7b commit 86d2369
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions commands/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type DockerCommandOptions = {

export type DockerImageComandOptions = {
json?: boolean;
noUntagged?: boolean;
} & DockerCommandOptions;

interface ContainerImage {
Expand Down Expand Up @@ -76,16 +77,20 @@ export const dockerCommand = ():commander.Command => {
const images = new commander.Command("images")
.description("List all images in the given github package repository")
.option("-j, --json", "Output as JSON", false)
.option('--no-untagged', 'Do not list images with no tags')
.passThroughOptions()
.action(async (_localOptions: DockerImageComandOptions, command: commander.Command) => {
const options: DockerImageComandOptions = command.optsWithGlobals();
const { repoInfo, octo } = await parseCommonRepoOptions(command);

if (!options.json) {
console.log(`Listing all container images for ${repoString(repoInfo)}`);
console.log(`Listing all container images for ${repoString(repoInfo)}${options.noUntagged && ' with at least 1 tag'}`);

Check failure on line 87 in commands/docker.ts

View workflow job for this annotation

GitHub Actions / build

This line has a length of 127. Maximum allowed is 120
}

const images: ContainerImage[] = await getContainerImageVersions(octo, repoInfo.owner, repoInfo.repo);
let images: ContainerImage[] = await getContainerImageVersions(octo, repoInfo.owner, repoInfo.repo);
if (options.noUntagged) {
images = images.filter((image) => image.tags?.length >= 1);
}
if (options.json) {
console.log(images);
} else {
Expand Down

0 comments on commit 86d2369

Please sign in to comment.