Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions pkg/workflow/action_pins.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ func getEmbeddedContainerPin(image string) (actionpins.ContainerPin, bool) {
return actionpins.GetContainerPin(image)
}

// lookupContainerPin returns the ContainerPin for the given image, checking cache first
// then falling back to embedded pins. Returns false if the image is not pinned.
func lookupContainerPin(image string, cache *ActionCache) (ContainerPin, bool) {
if cache != nil {
if pin, ok := cache.GetContainerPin(image); ok {
return pin, true
}
}
if pin, ok := getEmbeddedContainerPin(image); ok {
return ContainerPin(pin), true
}
Comment on lines +85 to +95
return ContainerPin{}, false
}

// getActionPinWithData returns the pinned action reference for a given action@version,
// delegating to pkg/actionpins with a PinContext built from WorkflowData.
func getActionPinWithData(actionRepo, version string, data *WorkflowData) (string, error) {
Expand Down
11 changes: 5 additions & 6 deletions pkg/workflow/awf_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,12 @@ func buildAWFImageTagWithDigests(imageTag string, workflowData *WorkflowData) st
// resolveContainerDigest resolves a container image digest from cache first, then
// falls back to embedded container pins.
func resolveContainerDigest(image string, workflowData *WorkflowData) string {
if workflowData != nil && workflowData.ActionCache != nil {
if pin, ok := workflowData.ActionCache.GetContainerPin(image); ok && pin.Digest != "" {
return pin.Digest
}
var cache *ActionCache
if workflowData != nil {
cache = workflowData.ActionCache
}
if embeddedPin, ok := getEmbeddedContainerPin(image); ok && embeddedPin.Digest != "" {
return embeddedPin.Digest
if pin, ok := lookupContainerPin(image, cache); ok && pin.Digest != "" {
return pin.Digest
}
return ""
}
Expand Down
16 changes: 4 additions & 12 deletions pkg/workflow/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,10 @@ func applyContainerPins(images []string, workflowData *WorkflowData) ([]string,
}

for i, img := range images {
if cache != nil {
if pin, ok := cache.GetContainerPin(img); ok && pin.PinnedImage != "" {
result[i] = pin.PinnedImage
pins[i] = GHAWManifestContainer(pin)
dockerLog.Printf("Pinned container image: %s -> %s", img, pin.PinnedImage)
continue
}
}
if embeddedPin, ok := getEmbeddedContainerPin(img); ok && embeddedPin.PinnedImage != "" {
result[i] = embeddedPin.PinnedImage
pins[i] = GHAWManifestContainer(embeddedPin)
dockerLog.Printf("Pinned container image from embedded pins: %s -> %s", img, embeddedPin.PinnedImage)
if pin, ok := lookupContainerPin(img, cache); ok && pin.PinnedImage != "" {
result[i] = pin.PinnedImage
pins[i] = GHAWManifestContainer(pin)
dockerLog.Printf("Pinned container image: %s -> %s", img, pin.PinnedImage)
continue
Comment on lines 207 to 212
}
result[i] = img
Expand Down
Loading