Package org.openrewrite.docker.trait
Class DockerFrom
java.lang.Object
org.openrewrite.docker.trait.DockerFrom
- All Implemented Interfaces:
org.openrewrite.trait.Trait<Docker.From>
A trait representing a Docker base image from a FROM instruction.
Provides semantic access to image name, tag, digest, platform, and stage name,
along with matching capabilities that handle environment variables.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMatcher for DockerImage traits with builder-style configuration.static enumReasons why an image may be considered unpinned. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandigestMatches(String pattern) Checks if the digest matches the given glob pattern.@Nullable StringReturns the digest, or null if no digest is specified.@Nullable StringReturns the image name (without tag or digest).@Nullable StringReturns the platform flag value, or null if not specified.@Nullable Docker.Literal.QuoteStyleReturns the quote style used for the image name, if any.@Nullable StringReturns the stage name (AS alias), or null if not specified.@Nullable StringgetTag()Returns the tag, or null if no tag is specified.@Nullable DockerFrom.UnpinnedReasonReturns the reason this image is unpinned, or null if it's pinned.booleanimageNameMatches(String pattern) Checks if the image name (without tag/digest) matches the given glob pattern.booleanReturns true if this is the special "scratch" base image.booleanReturns true if this image is unpinned (no tag, uses "latest" tag, or has no digest).booleantagMatches(String pattern) Checks if the tag matches the given glob pattern.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
-
DockerFrom
public DockerFrom()
-
-
Method Details
-
getImageName
Returns the image name (without tag or digest). Environment variables are preserved in their original form.- Returns:
- The image name, or null if it contains unresolvable variables
-
getTag
Returns the tag, or null if no tag is specified. Environment variables are preserved in their original form.- Returns:
- The tag, or null
-
getDigest
Returns the digest, or null if no digest is specified. Environment variables are preserved in their original form.- Returns:
- The digest, or null
-
getPlatform
Returns the platform flag value, or null if not specified.- Returns:
- The platform (e.g., "linux/amd64"), or null
-
getStageName
Returns the stage name (AS alias), or null if not specified.- Returns:
- The stage name, or null
-
isScratch
public boolean isScratch()Returns true if this is the special "scratch" base image.- Returns:
- true if the image is "scratch"
-
isUnpinned
public boolean isUnpinned()Returns true if this image is unpinned (no tag, uses "latest" tag, or has no digest). Images with a digest are considered pinned regardless of tag.- Returns:
- true if the image is unpinned
-
getUnpinnedReason
Returns the reason this image is unpinned, or null if it's pinned. Images with a digest are considered pinned. Images with environment variables in the tag are conservatively considered pinned (we can't determine the value).- Returns:
- The reason for being unpinned, or null if pinned
-
getQuoteStyle
Returns the quote style used for the image name, if any.- Returns:
- The quote style, or null if unquoted
-
imageNameMatches
Checks if the image name (without tag/digest) matches the given glob pattern.- Parameters:
pattern- The glob pattern to match against- Returns:
- true if the image name matches
-
tagMatches
Checks if the tag matches the given glob pattern.- Parameters:
pattern- The glob pattern to match against- Returns:
- true if the tag matches, false if no tag or doesn't match
-
digestMatches
Checks if the digest matches the given glob pattern.- Parameters:
pattern- The glob pattern to match against- Returns:
- true if the digest matches, false if no digest or doesn't match
-