Package org.openrewrite.docker.trait
Class DockerCopyFrom
java.lang.Object
org.openrewrite.docker.trait.DockerCopyFrom
- All Implemented Interfaces:
DockerImageReference<Docker.Instruction>,org.openrewrite.trait.Trait<Docker.Instruction>
A trait representing the image reference carried by the
--from flag of a
COPY or ADD instruction. Provides the same semantic access to image name,
tag, and digest as DockerFrom, while distinguishing an external image reference
(e.g. COPY --from=nginx:latest) from a reference to an earlier build stage
(e.g. COPY --from=builder or COPY --from=0). When the value refers to a
build stage the image accessors return null; use isStageReference() to
disambiguate.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMatcher forDockerCopyFromtraits with builder-style configuration.Nested classes/interfaces inherited from interface org.openrewrite.docker.trait.DockerImageReference
DockerImageReference.UnpinnedReason -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandigestMatches(String pattern) Checks if the digest matches the given glob pattern; false for stage references or when absent.Returns the digest, or empty if no digest is specified or this is a stage reference.Returns the raw--fromvalue with environment variable references preserved, or empty if there is no--fromflag.Returns the image name (without tag or digest), or empty if this is a stage reference or there is no--fromflag.getTag()Returns the tag, or empty if no tag is specified or this is a stage reference.Returns the reason the referenced external image is unpinned, or empty if it's pinned or this is a stage reference.booleanimageNameMatches(String pattern) Checks if the image name matches the given glob pattern; always false for stage references.booleanReturns true if the referenced external image is pinned by digest.booleanReturns true if the--fromvalue refers to an earlier build stage (by name or numeric index) rather than an external image.booleanReturns true if the referenced external image is unpinned (no tag or an explicit "latest" tag).booleantagMatches(String pattern) Checks if the tag matches the given glob pattern; false for stage references or when absent.withImageReference(String reference) Returns the instruction with its--fromvalue replaced byreference(e.g.Returns the instruction with the tag of its external image reference replaced bytag, preserving the image name and any digest.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.trait.Trait
getCursor, getTree
-
Constructor Details
-
DockerCopyFrom
public DockerCopyFrom()
-
-
Method Details
-
getFromValue
Returns the raw--fromvalue with environment variable references preserved, or empty if there is no--fromflag. -
isStageReference
public boolean isStageReference()Returns true if the--fromvalue refers to an earlier build stage (by name or numeric index) rather than an external image. -
getImageName
Returns the image name (without tag or digest), or empty if this is a stage reference or there is no--fromflag.- Specified by:
getImageNamein interfaceDockerImageReference<Docker.Instruction>
-
getTag
Returns the tag, or empty if no tag is specified or this is a stage reference.- Specified by:
getTagin interfaceDockerImageReference<Docker.Instruction>
-
getDigest
Returns the digest, or empty if no digest is specified or this is a stage reference.- Specified by:
getDigestin interfaceDockerImageReference<Docker.Instruction>
-
isDigestPinned
public boolean isDigestPinned()Returns true if the referenced external image is pinned by digest.- Specified by:
isDigestPinnedin interfaceDockerImageReference<Docker.Instruction>
-
isUnpinned
public boolean isUnpinned()Returns true if the referenced external image is unpinned (no tag or an explicit "latest" tag). Stage references and digest-pinned images are considered pinned.- Specified by:
isUnpinnedin interfaceDockerImageReference<Docker.Instruction>
-
getUnpinnedReason
Returns the reason the referenced external image is unpinned, or empty if it's pinned or this is a stage reference.- Specified by:
getUnpinnedReasonin interfaceDockerImageReference<Docker.Instruction>
-
withImageReference
Returns the instruction with its--fromvalue replaced byreference(e.g."nginx:1.25"), or unchanged if there is no--fromflag.- Specified by:
withImageReferencein interfaceDockerImageReference<Docker.Instruction>
-
withTag
Returns the instruction with the tag of its external image reference replaced bytag, preserving the image name and any digest. Unchanged for stage references.- Specified by:
withTagin interfaceDockerImageReference<Docker.Instruction>
-
imageNameMatches
Checks if the image name matches the given glob pattern; always false for stage references.- Specified by:
imageNameMatchesin interfaceDockerImageReference<Docker.Instruction>
-
tagMatches
Checks if the tag matches the given glob pattern; false for stage references or when absent.- Specified by:
tagMatchesin interfaceDockerImageReference<Docker.Instruction>
-
digestMatches
Checks if the digest matches the given glob pattern; false for stage references or when absent.- Specified by:
digestMatchesin interfaceDockerImageReference<Docker.Instruction>
-