You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: frontend/dockerfile/dockerfile_lint_test.go
+62-3Lines changed: 62 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -463,16 +463,38 @@ COPY Dockerfile .
463
463
{
464
464
RuleName: "UndeclaredArgInFrom",
465
465
Description: "FROM command must use declared ARGs",
466
-
Detail: "FROM argument 'BULIDPLATFORM' is not declared",
466
+
Detail: "FROM argument 'BULIDPLATFORM' is not declared (did you mean BUILDPLATFORM?)",
467
467
Level: 1,
468
468
Line: 2,
469
469
},
470
470
},
471
-
StreamBuildErr: "failed to solve: failed to parse platform : \"\" is an invalid component of \"\": platform specifier component must match \"^[A-Za-z0-9_-]+$\": invalid argument",
472
-
UnmarshalBuildErr: "failed to parse platform : \"\" is an invalid component of \"\": platform specifier component must match \"^[A-Za-z0-9_-]+$\": invalid argument",
471
+
StreamBuildErr: "failed to solve: empty platform value from expression $BULIDPLATFORM (did you mean BUILDPLATFORM?)",
472
+
UnmarshalBuildErr: "empty platform value from expression $BULIDPLATFORM (did you mean BUILDPLATFORM?)",
473
473
BuildErrLocation: 2,
474
474
})
475
475
476
+
dockerfile= []byte(`
477
+
ARG MY_OS=linux
478
+
ARG MY_ARCH=amd64
479
+
FROM --platform=linux/${MYARCH} busybox
480
+
COPY Dockerfile .
481
+
`)
482
+
checkLinterWarnings(t, sb, &lintTestParams{
483
+
Dockerfile: dockerfile,
484
+
Warnings: []expectedLintWarning{
485
+
{
486
+
RuleName: "UndeclaredArgInFrom",
487
+
Description: "FROM command must use declared ARGs",
488
+
Detail: "FROM argument 'MYARCH' is not declared (did you mean MY_ARCH?)",
489
+
Level: 1,
490
+
Line: 4,
491
+
},
492
+
},
493
+
StreamBuildErr: "failed to solve: failed to parse platform linux/${MYARCH}: \"\" is an invalid component of \"linux/\": platform specifier component must match \"^[A-Za-z0-9_-]+$\": invalid argument (did you mean MY_ARCH?)",
494
+
UnmarshalBuildErr: "failed to parse platform linux/${MYARCH}: \"\" is an invalid component of \"linux/\": platform specifier component must match \"^[A-Za-z0-9_-]+$\": invalid argument (did you mean MY_ARCH?)",
495
+
BuildErrLocation: 4,
496
+
})
497
+
476
498
dockerfile= []byte(`
477
499
ARG tag=latest
478
500
FROM busybox:${tag}${version} AS b
@@ -561,6 +583,43 @@ RUN echo $foo
561
583
},
562
584
},
563
585
})
586
+
587
+
dockerfile= []byte(`
588
+
FROM alpine
589
+
ARG DIR_BINARIES=binaries/
590
+
ARG DIR_ASSETS=assets/
591
+
ARG DIR_CONFIG=config/
592
+
COPY $DIR_ASSET .
593
+
`)
594
+
checkLinterWarnings(t, sb, &lintTestParams{
595
+
Dockerfile: dockerfile,
596
+
Warnings: []expectedLintWarning{
597
+
{
598
+
RuleName: "UndefinedVar",
599
+
Description: "Variables should be defined before their use",
600
+
Detail: "Usage of undefined variable '$DIR_ASSET' (did you mean $DIR_ASSETS?)",
601
+
Level: 1,
602
+
Line: 6,
603
+
},
604
+
},
605
+
})
606
+
607
+
dockerfile= []byte(`
608
+
FROM alpine
609
+
ENV PATH=$PAHT:/tmp/bin
610
+
`)
611
+
checkLinterWarnings(t, sb, &lintTestParams{
612
+
Dockerfile: dockerfile,
613
+
Warnings: []expectedLintWarning{
614
+
{
615
+
RuleName: "UndefinedVar",
616
+
Description: "Variables should be defined before their use",
617
+
Detail: "Usage of undefined variable '$PAHT' (did you mean $PATH?)",
0 commit comments