Skip to content

Commit

Permalink
fix: process FROM scratch (#25)
Browse files Browse the repository at this point in the history
* fix: process FROM scratch

Fixes #24

Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury authored Nov 17, 2023
1 parent 6448cfa commit 04cfc71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/command/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ func TestCheckNginx(t *testing.T) {
})
}
}

func TestFromScratch(t *testing.T) {
errors := AnalyzePath("resources/Containerfile.fromscratch")
if len(errors) > 0 {
t.Error("Image with FROM scratch returns errors")
}
}
6 changes: 5 additions & 1 deletion pkg/command/from.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package command

import (
"fmt"

"github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/redhat-developer/docker-openshift-analyzer/pkg/decompiler"
"github.com/redhat-developer/docker-openshift-analyzer/pkg/utils"
Expand All @@ -21,7 +20,12 @@ import (
type From struct {
}

const SCRATCH_IMAGE_NAME = "scratch"

func (f From) Analyze(node *parser.Node, source utils.Source, line Line) []error {
if node.Value == SCRATCH_IMAGE_NAME {
return nil
}
errs := []error{}
decompiledNode, err := decompiler.Decompile(node.Value)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/command/resources/Containerfile.fromscratch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM scratch

0 comments on commit 04cfc71

Please sign in to comment.