module Hadolint.Rule.DL3065 (rule) where

import Hadolint.Rule
import Language.Docker.Syntax

rule :: Rule args
rule :: forall args. Rule args
rule = RuleCode
-> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args
forall args.
RuleCode
-> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args
simpleRule RuleCode
code DLSeverity
severity Text
message Instruction args -> Bool
forall {args}. Instruction args -> Bool
check
  where
    code :: RuleCode
code = RuleCode
"DL3065"
    severity :: DLSeverity
severity = DLSeverity
DLWarningC
    message :: Text
message =
      Text
"Setting `FROM --platform` to predefined `$TARGETPLATFORM` in is\
      \ redundant as this is the default behavior"

    check :: Instruction args -> Bool
check (From (BaseImage Image
_ Maybe Tag
_ Maybe Digest
_ Maybe ImageAlias
_ (Just Text
platform))) =
      Text
platform Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"$TARGETPLATFORM" Bool -> Bool -> Bool
&& Text
platform Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"${TARGETPLATFORM}"
    check Instruction args
_ = Bool
True
{-# INLINEABLE rule #-}