Comments (3)
While I was adding some other stuff to this repo I'd thought to pick up some other issues. This one is quite strange for me:
I agree the usage example is a bit minimal. But the python code itself is actually quite nicely documented:
class DockerfileParser(object):
def __init__(self, path=None,
cache_content=False,
env_replace=True,
parent_env=None,
fileobj=None,
build_args=None):
"""
Initialize source of Dockerfile
:param path: path to (directory with) Dockerfile; if not provided,
and fileobj is not provided, the current working
directory will be used
:param cache_content: cache Dockerfile content inside DockerfileParser
:param env_replace: return content with variables replaced
:param parent_env: python dict of inherited env vars from parent image
:param fileobj: seekable file-like object containing Dockerfile content
as bytes (will be truncated on write)
:param build_args: python dict of build args used when building image
"""
The thing you are asking for (I think) is the cache_content
input variable.
But there are two things that strike me as odd:
- why would you not want to edit the existing file? The only example I can think of is if you want to keep your original dockerfile and save an edited copy. But either way: you'd need two dockerfile parser instances (one to read, and one to edit/write). The
cache_content
variable seems useless to me. - As far as I can see: the
cache_content
variable doesn't work. It was added 7 years ago: My guess is something broke in the meantime. But honestly: I think it is clutter that should be removed.
But I am curious if there are any use cases that I'm missing since it was added with a reason.
from dockerfile-parse.
I am currently using this package for only loading the Dockerfile, to run static analysis on it (linting). So I was struggling a bit, that Dockerfile file is being created (rewritten) on file system even though I did not want that. If someone else is having similar problem, passing tempfile (tempfile.NamedTemporaryFile()
) as fileobj
argument helped.
from dockerfile-parse.
I didn't know this was the case, and was surprised to find this out. I was already confused about why the library didn't just have a parse_file
function that returns something that's just Plain Old Data.
Semi-related: I didn't realize the parsing was lazy-- I thought I could just create the DockerfileParser
within the context manager, and then access its fields later.
Would y'all be opposed to me adding such an alternative API? It would be type-annotated and based on dataclasses
. That requires 3.7, but 3.6 is EOL'd even by RHEL.
from dockerfile-parse.
Related Issues (20)
- [packit] Propose update failed for release 0.0.17
- Proposal - add more complex FROM clause parsing HOT 4
- Parser ignores RUN statements if comments are in them HOT 2
- Handle escape directive for Dockerfiles HOT 2
- dockerfile-parse creates a Dockerfile file HOT 3
- ARG's are not inherited from a parent stage - only the last stage is considered HOT 7
- Add support for dockerfile stages HOT 2
- Add support for updating global ARGs
- make dockerfile-parse an RPM available on src.fedoraproject.org/projects/rpms/ HOT 4
- Interpret shell substitution for build arguments HOT 1
- Base image is incorrect when FROM statement has --platform HOT 3
- Dockerfiles with different file names are not supported HOT 5
- Incompatibility with pytest 7.2.0 HOT 1
- Support heredocs
- Make readme render on PyPI HOT 1
- ARGs are not handled in FROM instruction HOT 6
- Keeping comments in the parsed result HOT 3
- What if "apt-get" becomes an instruction? HOT 6
- Incorrectly appending 'Dockerfile' to path HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerfile-parse.