Drew Short
3 years ago
7 changed files with 128 additions and 43 deletions
-
29cmd/check.go
-
20cmd/root.go
-
0distribution/rhel.Dockerfile
-
17distribution/ubuntu.Dockerfile
-
30internal/parser/dockerfile.go
-
51internal/parser/dockerfile/dockerfile.go
-
24internal/parser/parser.go
@ -0,0 +1,17 @@ |
|||||
|
FROM golang:1.17-buster as builder |
||||
|
|
||||
|
ENV GO111MODULE=on |
||||
|
|
||||
|
WORKDIR /go/src/app |
||||
|
COPY . . |
||||
|
|
||||
|
RUN go build -v |
||||
|
|
||||
|
FROM ubuntu:20.04 AS server |
||||
|
|
||||
|
WORKDIR /app |
||||
|
|
||||
|
COPY --from=builder /go/src/app/pinned-package-updater . |
||||
|
|
||||
|
ENTRYPOINT ["/app/pinned-package-updater"] |
||||
|
CMD ["serve"] |
@ -1,30 +0,0 @@ |
|||||
/* |
|
||||
Copyright © 2021 Drew Short <warricks@sothr.com> |
|
||||
|
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
you may not use this file except in compliance with the License. |
|
||||
You may obtain a copy of the License at |
|
||||
|
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
|
|
||||
Unless required by applicable law or agreed to in writing, software |
|
||||
distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
See the License for the specific language governing permissions and |
|
||||
limitations under the License. |
|
||||
*/ |
|
||||
|
|
||||
// Package parser implements the required components for working with image definitions
|
|
||||
package parser |
|
||||
|
|
||||
import ( |
|
||||
"github.com/moby/buildkit/frontend/dockerfile/parser" |
|
||||
"os" |
|
||||
) |
|
||||
|
|
||||
func parse(dockerfilePath string) { |
|
||||
dockerfile, err := os.Open(dockerfilePath) |
|
||||
defer dockerfile.Close() |
|
||||
|
|
||||
parseResult, err := parser.Parse(dockerfile) |
|
||||
} |
|
@ -0,0 +1,51 @@ |
|||||
|
/* |
||||
|
Copyright © 2021 Drew Short <warricks@sothr.com> |
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
|
||||
|
// Package dockerfile implements the required components for working with dockerfile image definitions
|
||||
|
package dockerfile |
||||
|
|
||||
|
import ( |
||||
|
"os" |
||||
|
|
||||
|
log "github.com/sirupsen/logrus" |
||||
|
|
||||
|
buildkitDockerfile "github.com/moby/buildkit/frontend/dockerfile/parser" |
||||
|
|
||||
|
"sothr.com/warricksothr/pinned-package-updater/internal/parser" |
||||
|
) |
||||
|
|
||||
|
// Parse reads a Dockerfile, interprets the AST and returns information about the image(s) and package(s) defined
|
||||
|
func Parse(dockerfilePath string) (parser.ParseResult, error) { |
||||
|
dockerfile, err := os.Open(dockerfilePath) |
||||
|
if err != nil { |
||||
|
log.Fatalf("Unexpected error reading file %s: %s", dockerfilePath, err) |
||||
|
return parser.ParseResult{}, err |
||||
|
} |
||||
|
defer func(dockerfile *os.File) { |
||||
|
err := dockerfile.Close() |
||||
|
if err != nil { |
||||
|
log.Error("Unexpected error closing file %s: %s", dockerfilePath, err) |
||||
|
} |
||||
|
}(dockerfile) |
||||
|
|
||||
|
_, err = buildkitDockerfile.Parse(dockerfile) |
||||
|
if err != nil { |
||||
|
log.Fatalf("Unexpected error parsing Dockerfile %s: %s", dockerfilePath, err) |
||||
|
return parser.ParseResult{}, err |
||||
|
} |
||||
|
|
||||
|
return parser.ParseResult{}, nil |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue