mirror of
https://github.com/mudler/luet.git
synced 2025-09-25 14:38:50 +00:00
⚙️ Add ability to build from Dockerfiles directly
This commit is contained in:
committed by
mudler
parent
4e2a2adfc1
commit
e70a543f42
29
vendor/github.com/asottile/dockerfile/.coveragerc
generated
vendored
Normal file
29
vendor/github.com/asottile/dockerfile/.coveragerc
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
[run]
|
||||
branch = True
|
||||
source =
|
||||
.
|
||||
omit =
|
||||
.tox/*
|
||||
/usr/*
|
||||
setup.py
|
||||
# Don't complain if non-runnable code isn't run
|
||||
*/__main__.py
|
||||
|
||||
[report]
|
||||
exclude_lines =
|
||||
# Have to re-enable the standard pragma
|
||||
\#\s*pragma: no cover
|
||||
|
||||
# Don't complain if tests don't hit defensive assertion code:
|
||||
^\s*raise AssertionError\b
|
||||
^\s*raise NotImplementedError\b
|
||||
^\s*return NotImplemented\b
|
||||
^\s*raise$
|
||||
|
||||
# Don't complain if non-runnable code isn't run:
|
||||
^if __name__ == ['"]__main__['"]:$
|
||||
|
||||
[html]
|
||||
directory = coverage-html
|
||||
|
||||
# vim:ft=dosini
|
9
vendor/github.com/asottile/dockerfile/.gitignore
generated
vendored
Normal file
9
vendor/github.com/asottile/dockerfile/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.pyc
|
||||
/*.egg-info
|
||||
/.coverage
|
||||
/.eggs
|
||||
/.mypy_cache
|
||||
/.pytest_cache
|
||||
/.tox
|
||||
/build
|
||||
/dist
|
3
vendor/github.com/asottile/dockerfile/.gitmodules
generated
vendored
Normal file
3
vendor/github.com/asottile/dockerfile/.gitmodules
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "vendor/github.com/moby/buildkit"]
|
||||
path = vendor/github.com/moby/buildkit
|
||||
url = https://github.com/moby/buildkit
|
48
vendor/github.com/asottile/dockerfile/.pre-commit-config.yaml
generated
vendored
Normal file
48
vendor/github.com/asottile/dockerfile/.pre-commit-config.yaml
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: name-tests-test
|
||||
- id: requirements-txt-fixer
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.7.9
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||
rev: v1.5
|
||||
hooks:
|
||||
- id: autopep8
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
args: [--py3-plus]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v1.26.2
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v1.5.0
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v1.6.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v0.761
|
||||
hooks:
|
||||
- id: mypy
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: gofmt
|
||||
name: gofmt
|
||||
language: system
|
||||
entry: gofmt -l -w
|
||||
files: \.go$
|
19
vendor/github.com/asottile/dockerfile/LICENSE
generated
vendored
Normal file
19
vendor/github.com/asottile/dockerfile/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017 Anthony Sottile
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
4
vendor/github.com/asottile/dockerfile/MANIFEST.in
generated
vendored
Normal file
4
vendor/github.com/asottile/dockerfile/MANIFEST.in
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
include *.go pylib/*.c pylib/*.go
|
||||
recursive-include vendor/github.com/moby/buildkit/frontend/dockerfile/command *.go
|
||||
recursive-include vendor/github.com/moby/buildkit/frontend/dockerfile/parser *.go
|
||||
global-exclude *_test.go
|
79
vendor/github.com/asottile/dockerfile/README.md
generated
vendored
Normal file
79
vendor/github.com/asottile/dockerfile/README.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
[](https://asottile.visualstudio.com/asottile/_build/latest?definitionId=14&branchName=master)
|
||||
[](https://ci.appveyor.com/project/asottile/dockerfile)
|
||||
|
||||
dockerfile
|
||||
==========
|
||||
|
||||
The goal of this repository is to provide a wrapper around
|
||||
[docker/docker](https://github.com/docker/docker)'s parser for dockerfiles.
|
||||
|
||||
|
||||
## python library
|
||||
|
||||
### Installation
|
||||
|
||||
This project uses [setuptools-golang](https://github.com/asottile/setuptools-golang)
|
||||
when built from source. To build from source you'll need a go compiler.
|
||||
|
||||
If you're using linux and sufficiently new pip (>=8.1) you should be able to
|
||||
just download prebuilt manylinux1 wheels.
|
||||
|
||||
```
|
||||
pip install dockerfile
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
There's three api functions provided by this library:
|
||||
|
||||
#### `dockerfile.all_cmds()`
|
||||
|
||||
List all of the known dockerfile cmds.
|
||||
|
||||
```python
|
||||
>>> dockerfile.all_cmds()
|
||||
('add', 'arg', 'cmd', 'copy', 'entrypoint', 'env', 'expose', 'from', 'healthcheck', 'label', 'maintainer', 'onbuild', 'run', 'shell', 'stopsignal', 'user', 'volume', 'workdir')
|
||||
```
|
||||
|
||||
#### `dockerfile.parse_file(filename)`
|
||||
|
||||
Parse a Dockerfile by filename.
|
||||
Returns a `tuple` of `dockerfile.Command` objects representing each layer of
|
||||
the Dockerfile.
|
||||
Possible exceptions:
|
||||
- `dockerfile.GoIOError`: The file could not be opened.
|
||||
- `dockerfile.ParseError`: The Dockerfile was not parseable.
|
||||
|
||||
```python
|
||||
>>> pprint.pprint(dockerfile.parse_file('testfiles/Dockerfile.ok'))
|
||||
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),
|
||||
Command(cmd='cmd', sub_cmd=None, json=True, original='CMD ["echo", "hi"]', start_line=2, flags=(), value=('echo', 'hi')))
|
||||
```
|
||||
|
||||
#### `dockerfile.parse_string(s)`
|
||||
|
||||
Parse a dockerfile using a string.
|
||||
Returns a `tuple` of `dockerfile.Command` objects representing each layer of
|
||||
the Dockerfile.
|
||||
Possible exceptions:
|
||||
- `dockerfile.ParseError`: The Dockerfile was not parseable.
|
||||
|
||||
```python
|
||||
>>> dockerfile.parse_string('FROM ubuntu:xenial')
|
||||
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),)
|
||||
```
|
||||
|
||||
## go library
|
||||
|
||||
Slightly more convenient than the api provided by docker/docker? Might not be
|
||||
terribly useful -- the main point of this repository was a python wrapper.
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
go get github.com/asottile/dockerfile
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
[godoc](https://godoc.org/github.com/asottile/dockerfile)
|
16
vendor/github.com/asottile/dockerfile/appveyor.yml
generated
vendored
Normal file
16
vendor/github.com/asottile/dockerfile/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
environment:
|
||||
matrix:
|
||||
- PYTHON: 'C:\Python37'
|
||||
|
||||
install:
|
||||
- 'SET PATH=%PYTHON%;%PYTHON%\Scripts;C:\MinGW\bin;C:\go-x86\bin;%PATH%'
|
||||
- 'SET GOROOT=C:\go-x86'
|
||||
- git submodule update --init
|
||||
- pip install pytest .
|
||||
|
||||
# Not a C# project
|
||||
build: false
|
||||
|
||||
test_script: pytest tests
|
||||
|
||||
cache: '%LOCALAPPDATA%\pip\cache'
|
42
vendor/github.com/asottile/dockerfile/azure-pipelines.yml
generated
vendored
Normal file
42
vendor/github.com/asottile/dockerfile/azure-pipelines.yml
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
trigger:
|
||||
branches:
|
||||
include: [master, test-me-*]
|
||||
tags:
|
||||
include: ['*']
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: self
|
||||
checkoutOptions:
|
||||
submodules: true
|
||||
- repository: asottile
|
||||
type: github
|
||||
endpoint: github
|
||||
name: asottile/azure-pipeline-templates
|
||||
ref: refs/tags/v1.0.1
|
||||
|
||||
jobs:
|
||||
- template: job--pre-commit.yml@asottile
|
||||
- template: job--go-test.yml@asottile
|
||||
parameters:
|
||||
go_versions: ['1.12.17', '1.13.8']
|
||||
os: linux
|
||||
tests: '.' # only test the top level
|
||||
- template: job--python-tox.yml@asottile
|
||||
parameters:
|
||||
toxenvs: [py36]
|
||||
os: linux
|
||||
name_postfix: _go_1_12
|
||||
pre_test:
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
version: '1.12.17'
|
||||
- template: job--python-tox.yml@asottile
|
||||
parameters:
|
||||
toxenvs: [pypy3, py36, py37, py38]
|
||||
os: linux
|
||||
name_postfix: _go_1_13
|
||||
pre_test:
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
version: '1.13.8'
|
95
vendor/github.com/asottile/dockerfile/parse.go
generated
vendored
Normal file
95
vendor/github.com/asottile/dockerfile/parse.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package dockerfile
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/moby/buildkit/frontend/dockerfile/command"
|
||||
"github.com/moby/buildkit/frontend/dockerfile/parser"
|
||||
)
|
||||
|
||||
// Represents a single line (layer) in a Dockerfile.
|
||||
// For example `FROM ubuntu:xenial`
|
||||
type Command struct {
|
||||
Cmd string // lowercased command name (ex: `from`)
|
||||
SubCmd string // for ONBUILD only this holds the sub-command
|
||||
Json bool // whether the value is written in json form
|
||||
Original string // The original source line
|
||||
StartLine int // The original source line number which starts this command
|
||||
EndLine int // The original source line number which ends this command
|
||||
Flags []string // Any flags such as `--from=...` for `COPY`.
|
||||
Value []string // The contents of the command (ex: `ubuntu:xenial`)
|
||||
}
|
||||
|
||||
// A failure in opening a file for reading.
|
||||
type IOError struct {
|
||||
Msg string
|
||||
}
|
||||
|
||||
func (e IOError) Error() string {
|
||||
return e.Msg
|
||||
}
|
||||
|
||||
// A failure in parsing the file as a dockerfile.
|
||||
type ParseError struct {
|
||||
Msg string
|
||||
}
|
||||
|
||||
func (e ParseError) Error() string {
|
||||
return e.Msg
|
||||
}
|
||||
|
||||
// List all legal cmds in a dockerfile
|
||||
func AllCmds() []string {
|
||||
var ret []string
|
||||
for k := range command.Commands {
|
||||
ret = append(ret, k)
|
||||
}
|
||||
sort.Strings(ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
// Parse a Dockerfile from a reader. A ParseError may occur.
|
||||
func ParseReader(file io.Reader) ([]Command, error) {
|
||||
res, err := parser.Parse(file)
|
||||
if err != nil {
|
||||
return nil, ParseError{err.Error()}
|
||||
}
|
||||
|
||||
var ret []Command
|
||||
for _, child := range res.AST.Children {
|
||||
cmd := Command{
|
||||
Cmd: child.Value,
|
||||
Original: child.Original,
|
||||
StartLine: child.StartLine,
|
||||
EndLine: child.EndLine,
|
||||
Flags: child.Flags,
|
||||
}
|
||||
|
||||
// Only happens for ONBUILD
|
||||
if child.Next != nil && len(child.Next.Children) > 0 {
|
||||
cmd.SubCmd = child.Next.Children[0].Value
|
||||
child = child.Next.Children[0]
|
||||
}
|
||||
|
||||
cmd.Json = child.Attributes["json"]
|
||||
for n := child.Next; n != nil; n = n.Next {
|
||||
cmd.Value = append(cmd.Value, n.Value)
|
||||
}
|
||||
|
||||
ret = append(ret, cmd)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Parse a Dockerfile from a filename. An IOError or ParseError may occur.
|
||||
func ParseFile(filename string) ([]Command, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil, IOError{err.Error()}
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
return ParseReader(file)
|
||||
}
|
4
vendor/github.com/asottile/dockerfile/requirements-dev.txt
generated
vendored
Normal file
4
vendor/github.com/asottile/dockerfile/requirements-dev.txt
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
coverage
|
||||
pre-commit
|
||||
pytest
|
||||
setuptools-golang>=1.0.0
|
38
vendor/github.com/asottile/dockerfile/setup.cfg
generated
vendored
Normal file
38
vendor/github.com/asottile/dockerfile/setup.cfg
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
[metadata]
|
||||
name = dockerfile
|
||||
version = 3.1.0
|
||||
description = Parse a dockerfile into a high-level representation using the official go parser.
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
url = https://github.com/asottile/dockerfile
|
||||
author = Anthony Sottile
|
||||
author_email = asottile@umich.edu
|
||||
license = MIT
|
||||
license_file = LICENSE
|
||||
classifiers =
|
||||
License :: OSI Approved :: MIT License
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: Implementation :: CPython
|
||||
Programming Language :: Python :: Implementation :: PyPy
|
||||
|
||||
[options]
|
||||
python_requires = >=3.6.1
|
||||
setup_requires =
|
||||
setuptools-golang>=1.7.0
|
||||
|
||||
[mypy]
|
||||
check_untyped_defs = true
|
||||
disallow_any_generics = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
|
||||
[mypy-testing.*]
|
||||
disallow_untyped_defs = false
|
||||
|
||||
[mypy-tests.*]
|
||||
disallow_untyped_defs = false
|
37
vendor/github.com/asottile/dockerfile/setup.py
generated
vendored
Normal file
37
vendor/github.com/asottile/dockerfile/setup.py
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import os.path
|
||||
import platform
|
||||
import sys
|
||||
|
||||
from setuptools import Extension
|
||||
from setuptools import setup
|
||||
|
||||
if not os.path.exists('vendor/github.com/moby/buildkit/frontend'):
|
||||
print('moby checkout is missing!')
|
||||
print('Run `git submodule update --init`')
|
||||
exit(1)
|
||||
|
||||
if sys.platform != 'win32' and platform.python_implementation() == 'CPython':
|
||||
try:
|
||||
import wheel.bdist_wheel
|
||||
except ImportError:
|
||||
cmdclass = {}
|
||||
else:
|
||||
class bdist_wheel(wheel.bdist_wheel.bdist_wheel):
|
||||
def finalize_options(self) -> None:
|
||||
self.py_limited_api = f'cp3{sys.version_info[1]}'
|
||||
super().finalize_options()
|
||||
|
||||
cmdclass = {'bdist_wheel': bdist_wheel}
|
||||
else:
|
||||
cmdclass = {}
|
||||
|
||||
setup(
|
||||
ext_modules=[
|
||||
Extension(
|
||||
'dockerfile', ['pylib/main.go'],
|
||||
py_limited_api=True, define_macros=[('Py_LIMITED_API', None)],
|
||||
),
|
||||
],
|
||||
cmdclass=cmdclass,
|
||||
build_golang={'root': 'github.com/asottile/dockerfile'},
|
||||
)
|
18
vendor/github.com/asottile/dockerfile/tox.ini
generated
vendored
Normal file
18
vendor/github.com/asottile/dockerfile/tox.ini
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
[tox]
|
||||
envlist = py36,py37,py38,pypy3,pre-commit
|
||||
|
||||
[testenv]
|
||||
deps = -rrequirements-dev.txt
|
||||
commands =
|
||||
coverage erase
|
||||
coverage run -m pytest {posargs:tests}
|
||||
coverage report --show-missing --fail-under 100
|
||||
pre-commit install
|
||||
|
||||
[testenv:pre-commit]
|
||||
skip_install = true
|
||||
deps = pre-commit
|
||||
commands = pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
[pep8]
|
||||
ignore = E265,E501,W504
|
Reference in New Issue
Block a user