Skip to content

Commit

Permalink
Register with manifestList
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupuis committed Sep 16, 2023
1 parent 68fad1d commit 9e0c45d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions datalog/subscription/register_skill.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
?image
[:schema/entity-type
:docker.image/digest
{(:docker.manifest-list/_images :as :manifest-list) [:docker.manifest-list/digest]}
{:docker.image/labels [:docker.image.label/name :docker.image.label/value]}
{:docker.image/repository [:docker.repository/host
(:docker.repository/repository :as :name)]}])
Expand Down
18 changes: 13 additions & 5 deletions lib/events/register_skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export const handler: MappingEventHandler<
map: event => {
const data = event.map(e =>
handle.transformData<{
image: subscription.datalog.DockerImage;
image: subscription.datalog.DockerImage & {
manifestList: Array<{ digest: string }>;
};
commit: subscription.datalog.Commit;
registry: docker.ExtendedDockerRegistry;
}>(e),
Expand Down Expand Up @@ -360,13 +362,19 @@ export function imageName(

export function fullImageName(
image: Pick<
subscription.datalog.DockerImage,
"digest" | "tags" | "repository"
subscription.datalog.DockerImage & {
manifestList: Array<{ digest: string }>;
},
"digest" | "tags" | "repository" | "manifestList"
>,
): string {
let digest = image.digest;
if (image.manifestList?.length > 0) {
digest = image.manifestList[0].digest;
}
return `${imageName(image)}${
!image.digest && image.tags?.length > 0 ? `:${image.tags[0]}` : ""
}${image.digest ? `@${image.digest}` : ""}`;
!digest && image.tags?.length > 0 ? `:${image.tags[0]}` : ""
}${digest ? `@${digest}` : ""}`;
}

export async function inlineDatalogResources(
Expand Down
4 changes: 3 additions & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import { docker, subscription } from "@atomist/skill";

export interface RegisterSkill {
image: subscription.datalog.DockerImage;
image: subscription.datalog.DockerImage & {
manifestList: Array<{ digest: string }>;
};
commit: subscription.datalog.Commit;
registry: docker.ExtendedDockerRegistry[];
}

0 comments on commit 9e0c45d

Please sign in to comment.