Class DockerCopyFrom.Matcher

java.lang.Object
org.openrewrite.trait.SimpleTraitMatcher<DockerCopyFrom>
org.openrewrite.docker.trait.DockerCopyFrom.Matcher
All Implemented Interfaces:
org.openrewrite.trait.TraitMatcher<DockerCopyFrom>
Enclosing class:
DockerCopyFrom

public static class DockerCopyFrom.Matcher extends org.openrewrite.trait.SimpleTraitMatcher<DockerCopyFrom>
Matcher for DockerCopyFrom traits with builder-style configuration.
  • Constructor Details

    • Matcher

      public Matcher()
  • Method Details

    • imageName

      @Contract("_ -> this") public DockerCopyFrom.Matcher imageName(String pattern)
      Only match images with names matching this glob pattern.
    • tag

      @Contract("_ -> this") public DockerCopyFrom.Matcher tag(String pattern)
      Only match images with tags matching this glob pattern.
    • digest

      @Contract("_ -> this") public DockerCopyFrom.Matcher digest(String pattern)
      Only match images with digests matching this glob pattern.
    • excludeStageReferences

      @Contract("-> this") public DockerCopyFrom.Matcher excludeStageReferences()
      Exclude --from values that reference an earlier build stage, matching only external image references.
    • test

      protected @Nullable DockerCopyFrom test(org.openrewrite.Cursor cursor)
      Specified by:
      test in class org.openrewrite.trait.SimpleTraitMatcher<DockerCopyFrom>
    • asVisitor

      public <P> org.openrewrite.TreeVisitor<? extends org.openrewrite.Tree,P> asVisitor(org.openrewrite.trait.VisitFunction2<DockerCopyFrom,P> visitor)
      Specified by:
      asVisitor in interface org.openrewrite.trait.TraitMatcher<DockerCopyFrom>
      Overrides:
      asVisitor in class org.openrewrite.trait.SimpleTraitMatcher<DockerCopyFrom>
    • extractTextForMatching

      protected String extractTextForMatching(Docker.Argument arg)
      Extracts text from a Docker argument, replacing environment variables with wildcards for glob matching purposes.
      Parameters:
      arg - The argument to extract text from
      Returns:
      Text with environment variables replaced by '*'
    • extractText

      @Contract(value="null -> null", pure=true) protected @Nullable String extractText(@Nullable Docker.Argument arg)
      Extracts text from a Docker argument, returning null if the argument contains any environment variables (since the actual value cannot be determined statically).
      Parameters:
      arg - The argument to extract text from, may be null
      Returns:
      The literal text content, or null if the argument is null or contains environment variables
    • extractTextWithVariables

      @Contract(value="null -> null; !null -> !null", pure=true) protected @Nullable String extractTextWithVariables(@Nullable Docker.Argument arg)
      Extracts text from a Docker argument, including environment variable references in their original form (e.g., ${VAR} or $VAR).
      Parameters:
      arg - The argument to extract text from, may be null
      Returns:
      The text content with environment variable references preserved, or null if arg is null
    • hasEnvironmentVariables

      @Contract(value="null -> false", pure=true) protected boolean hasEnvironmentVariables(@Nullable Docker.Argument arg)
      Checks if a Docker argument contains any environment variables.
      Parameters:
      arg - The argument to check, may be null
      Returns:
      true if the argument contains environment variables, false otherwise
    • matchesBidirectional

      protected boolean matchesBidirectional(String text, String pattern, boolean hasEnvVars)
      Performs bidirectional glob matching when environment variables are present. When the text contains wildcards (from env vars), we need to check if either the pattern matches the text OR the text (as a pattern) matches the pattern.
      Parameters:
      text - The text to match (may contain wildcards from env vars)
      pattern - The glob pattern to match against
      hasEnvVars - Whether the original text contained environment variables
      Returns:
      true if there's a match in either direction
    • getQuoteStyle

      protected @Nullable Docker.Literal.QuoteStyle getQuoteStyle(Docker.Argument arg)
      Gets the quote style from a Docker argument, if any literal content is quoted.
      Parameters:
      arg - The argument to check
      Returns:
      The quote style, or null if unquoted