Code Monkey home page Code Monkey logo

frigate's Introduction

Frigate

Frigate is a tool for automatically generating documentation for your Helm charts.

Features:

  • Render documentation from your Chart.yaml and values.yaml files.
  • Supports outputting as markdown, reStructuredText and HTML.
  • Sphinx extension for including in Python documentation.

Installation

$ pip install frigate

Usage

$ frigate gen path/to/chart

Chart
==========

Chart description.

...

Pre-commit-hook

Into the repository you want to have the pre-commit hook installed, run:

cat <<EOF >> .pre-commit-config.yaml
- repo: https://github.com/rapidsai/frigate
  rev: v0.4.0 #  pre-commit autoupdate  - to keep the version up to date
  hooks:
    - id: frigate
EOF

Parameters

You can add extra parameters with :

- repo: https://github.com/rapidsai/frigate
  rev: v0.4.0 #  pre-commit autoupdate  - to keep the version up to date
  hooks:
    - id: frigate
      args:
        - --output=README.rst
        - --format=rst
        - --no-credits
        - --no-deps

frigate's People

Contributors

ajaythorve avatar ajschmidt8 avatar ayodeawe avatar consideratio avatar dillon-cullinan avatar edwardtheharris avatar jacobtomlinson avatar jjacobelli avatar jrottenberg avatar ktaletsk avatar mike-wendt avatar msadang avatar raul1991 avatar raydouglass avatar tomaugspurger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

frigate's Issues

Fix typos in the documentation

  • I saw a word extent instead of extend
  • the template given on the doc uses markdown.jinja which should markdown.jinja2
  • The word .friagte should be changed to .frigate

I could not edit the doc page since that is giving me a 404. May be we should correct that url ?

Nevertheless this tool is awesome.

Support for semantic versioned charts

Frigate doesn't seem to work if a chart requirement is not specified directly, and instead uses a range:

We have this in our Chart.yaml:

  - name: common
    version: ^1
    repository: oci://registry.xxx.com/charts

Helm update runs fine:

Saving 1 charts
Downloading common from repo oci://registry.xxx.com/charts
Pulled: registry.xxx.com/charts/common:1.7.4

Frigate fails with:

    shutil.unpack_archive(dependency_path, tmpdirname)
  File "/usr/lib/python3.10/shutil.py", line 1271, in unpack_archive
    func(filename, extract_dir, **kwargs)
  File "/usr/lib/python3.10/shutil.py", line 1199, in _unpack_tarfile
    tarobj = tarfile.open(filename)
  File "/usr/lib/python3.10/tarfile.py", line 1622, in open
    return func(name, "r", fileobj, **kwargs)
  File "/usr/lib/python3.10/tarfile.py", line 1688, in gzopen
    fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
  File "/usr/lib/python3.10/gzip.py", line 174, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
FileNotFoundError: [Errno 2] No such file or directory: './charts/common-^1.tgz'

There is a ./charts/common-1.7.4.tgz.

"Object of type Date is not Json Serializable"

I have encountered this error when one of chart had a date field.

Reading about it shows that we need to pass in an ISO string using a custom decoder.

I don't face it anymore with that fix so I can send a pull request for it.

Frigate ignores Case Sensitivity

I've noticed that Frigate ignores Uppercase words in my comments:

values.yaml

myKey: BIG  # Can be either BIG or SMALL

Markdown:

| Parameter                | Description             | Default        |
| ------------------------ | ----------------------- | -------------- |
| `myKey` | Can be either big or small | `"BIG"` |

Is this expected/required or would a PR to rectify this be OK? I can try taking a look

Support for a pre-packaged chart in frigate

In my case , I usually update my chart ie pack it properly (including its dependent charts) so I would like frigate to just go through them and just dump the values from them that way it already does. The only thing would be to NOT run the repo update and the dep update commands.

One thing to note here is that the above commands only slow down the whole recursion drastically (I had to wait for 20 mins). With this improvement I also would like to propose a flag called --no-update which would not invoke the the aforementioned commands during the traversal.

Support for commented out values

Dear maintainers,

We are happy using your tool for quick and beautiful documentation generation. However, in our case, we use multiple layers of Helm configuration. Thus, we keep some of the values.yaml entries commented out in the base layer, so other layers would have to define that configuration themselves, and developers could have a look at the configuration example and understand what configuration is possible. For example, there is a short excerpt from our base values.yaml file

# Resources are INTENTIONALLY commented out, as they need to be provided by the microservice chart
#  resources:
#    limits:
#      cpu: 1 # Number of max CPU that can be used in a Pod
#      memory: 1Gi # Max amount of memory that can be used in a Pod
#    requests:
#      cpu: 1 # Requested amount of CPU for a pod
#      memory: 1Gi # Requested amount of memory for a pod

# Readiness & liveness probes are mandatory
  livenessProbe:
    initialDelaySeconds: 30 # Delay after which to start liveliness probe
    timeoutSeconds: 5 # Timeout length between liveliness probes

So I would like to ask if there is a possibility, that you could include a feature for generating documentation for entries that are commented out?

Custom fields in Charts.yaml "not allowed" in helm version >= 3.2.2

Helm documentation about the Chart.yaml file describes:

As of v3.3.2, additional fields are not allowed. The recommended approach is to add custom metadata in annotations.

This is relevant for frigate's use of custom fields in a Chart.yaml file, I've seen long_description and footnote for example. So far, it seems that including additional fields hasn't broken something though. For example, using helm v3.9.0, I can still call helm template on a Chart.yaml with long_description inside it, so maybe their documentation was too strict?

Overall though, this is a big risk, and I think its a much better practice for frigate to not use these keys but instead used an annotation key/value. That way, the key would clarify that this configuration was frigate associated, something that has confused me up until today when I've seen this config in a Chart.yaml.

long_description: |
This is the default chart created with ``helm create nginx``.
Descriptions have then been added to all items in ``values.yaml`` and a ``.frigate.jinja2`` template has been included to enrich it.
Frigate has then been used to generate both the ``README.rst`` in that directory as well as the example in the Sphinx docs.
Generating the README.rst
-------------------------
.. code-block:: console
$ frigate gen ../frigate/tests/mockcharts/rich > ../frigate/tests/mockcharts/rich/README.rst
Sphinx docs directive
---------------------
.. code-block:: rst
.. frigate:: ../frigate/tests/mockcharts/rich
footnotes: |
Footnotes
---------
It is also possible to include a footnotes section which is placed after the parameters table in your documentation.
This is a good location for information which you want to include but may not be of primary interest to users.

Use `main` as the default branch

If possible, I suggest that main is the default branch used by this project, instead of the branch branch-0.6.

If not, I as a contributor ends up with questions like:

  • Should I open a PR to the main branch, or the branch-0.6 branch?
  • Should I include the documentation commit in branch-0.6 that isn't part of main?
  • How does the gh CLI i use to quickly make commits work now, hmm...

To switch the default branch of this project, visit https://github.com/rapidsai/frigate/settings/branches. You can either delete the current main and rename the branch-0.6 branch, or you can just switch the default branch from branch-0.6 to main, and then have it be updated to include the documentation commit that branch-0.6 has that main doesn't yet have.

Btw, I also note that #23 is a PR that looks to merge into branch-0.3, which would be very irrelevant now to do.

Parsing values with YAML bar operator fails.

When generating document for fields with bar operator (|), frigate fails:

Sample:

myField: | # cant document this

Error:

Traceback (most recent call last):
  File "/usr/local/bin/frigate", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/frigate/cli.py", line 25, in gen
    click.echo(frigate.gen.gen(filename, output_format, credits=no_credits))
  File "/usr/local/lib/python3.8/site-packages/frigate/gen.py", line 161, in gen
    return template.render(**chart, values=traverse(values), credits=credits)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/frigate/templates/markdown.jinja2", line 1, in top-level template code
    {% extends "base.jinja2" %}
  File "/usr/local/lib/python3.8/site-packages/frigate/templates/base.jinja2", line 4, in top-level template code
    {% block table %}{% endblock %}
  File "/usr/local/lib/python3.8/site-packages/frigate/templates/markdown.jinja2", line 21, in block "table"
    {% for (param, comment, default) in values -%}
  File "/usr/local/lib/python3.8/site-packages/frigate/gen.py", line 122, in traverse
    for value in traverse(default, root=newroot):
  File "/usr/local/lib/python3.8/site-packages/frigate/gen.py", line 134, in traverse
    comment = get_comment(tree, key)
  File "/usr/local/lib/python3.8/site-packages/frigate/gen.py", line 63, in get_comment
    if comment is not None and comment.start_mark.line == linecol[0]:
AttributeError: 'str' object has no attribute 'start_mark'

Get the description added from the comment added above the variable

is there anyway to get the description added from the comment added above the variable

| Parameter                | Description             | Default        |
| ------------------------ | ----------------------- | -------------- |
| `imagePullPolicy` |  | `"Always"` |

# Can it ready the description from 

# Image pull policy description. is there a way to read this?
imagePullPolicy: Always # Now its reading from if its the same line as the variable

How to disable the formatting for the helm chart name ?

First of all, Damn! this tool is fantastic just does what it says, perfectly.

Now, the issue is that the helm chart initial character gets rendered as upper case. Is there a flag to disable it ?

Example:

description: Helm chart for foo-bar
name: foo-bar
version: 0.9.0-15

Expectation

Chart name to be rendered as is

Actual

chart name is rendered as Foo-bar

.rst output is broken if chart has large parameter names

Outputting to .rst format produces incorrectly formatted table which results in table not being rendered in Sphinx. This happen if there are any parameter strings that are longer than a header length. For example, grab the Postgres Helm chart from Bitnami:

git clone https://github.com/bitnami/charts.git
cd charts/bitnami
frigate gen postgresql -o rst > postgresql.rst

Here is the output generated. I am going to omit some rows to highlight the problematic rows:

.. This page has been autogenerated using Frigate.
   https://frigate.readthedocs.io

Postgresql
======================

PostgreSQL (Postgres) is an open source object-relational database known for reliability and data integrity. ACID-compliant, it supports foreign keys, joins, views, triggers and stored procedures.



Configuration
-------------

The following table lists the configurable parameters of the Postgresql chart and their default values.

================================================== ==================================================================================================== ==================================================
Parameter                                          Description                                                                                          Default
================================================== ==================================================================================================== ==================================================
``global.imageRegistry``                                                                                                                                ``""``                                            
``global.imagePullSecrets``                                                                                                                             ``[]``                                            
``global.storageClass``                                                                                                                                 ``""``                                            
``global.postgresql.auth.postgresPassword``                                                                                                             ``""``                                            
``global.postgresql.auth.username``                                                                                                                     ``""``                                            
``global.postgresql.auth.password``                                                                                                                     ``""``                                            

skip some rows

``networkPolicy.ingressRules.primaryAccessOnlyFrom.enabled``                                                                                                      ``false``                                         
``networkPolicy.ingressRules.primaryAccessOnlyFrom.namespaceSelector``                                                                                                      ``{}``                                            
``networkPolicy.ingressRules.primaryAccessOnlyFrom.podSelector``                                                                                                      ``{}``                                            
``networkPolicy.ingressRules.primaryAccessOnlyFrom.customRules``                                                                                                      ``{}``                                            
``networkPolicy.ingressRules.readReplicasAccessOnlyFrom.enabled``                                                                                                      ``false``                                         
``networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector``                                                                                                      ``{}``                                            
``networkPolicy.ingressRules.readReplicasAccessOnlyFrom.podSelector``                                                                                                      ``{}``                                            

You can see that some rows are longer than a generated header for the table. As a result, Sphinx is not going to render the table at all
image

If I manually trim or remove the "offending" lines, table now renders
image

The solution would be to adjust the header so its length is not smaller than the length of the longest parameter

Pre-commit integration

Hello !

Great utility, one way to get more adoption would be to provide an integration with pre-commit.

https://pre-commit.com/

For terraform, for example, I have been using : https://github.com/antonbabenko/pre-commit-terraform

And the modules are always well documented, without worrying about it.

The flow would be :

  1. the chart maintainer installs the pre-commit hook
  2. Update the chart's value, etc
  3. Commit the change
  4. pre-commit kicks in and run frigates, updating the README
  5. User is prompted to add the change on the README.

Subcharts declared in subfolders under charts/ are ignored

Frigate currently only considers Chart.yaml declared dependencies, but ignores subcharts directly located under the charts/ folder. I don't run into issues about this, but it is a broken expectation on how frigate works if I would use frigate on a helm chart wish subcharts and not just chart dependencies.

frigate/frigate/gen.py

Lines 58 to 74 in 4153bf5

root = [] if root is None else root
chart, values = load_chart(chartdir, root=root)
if "dependencies" in chart:
for dependency in chart["dependencies"]:
dependency_name = dependency["name"]
dependency_path = os.path.join(
chartdir, "charts", f"{dependency_name}-{dependency['version']}.tgz",
)
with tempfile.TemporaryDirectory() as tmpdirname:
shutil.unpack_archive(dependency_path, tmpdirname)
dependency_dir = os.path.join(tmpdirname, dependency_name)
update_chart_dependencies(tmpdirname, dependency_name)
_, dependency_values = load_chart_with_dependencies(
dependency_dir, root + [dependency_name]
)
values = squash_duplicate_values(values + dependency_values)

Templates are missing

Looks like there has been a packaging issue as the templates are missing from the package when installed via pip.

$ frigate test
Traceback (most recent call last):
  File "/Users/jtomlinson/miniconda3/envs/frigate-install-test/bin/frigate", line 5, in <module>
    from frigate.cli import cli
  File "/Users/jtomlinson/miniconda3/envs/frigate-install-test/lib/python3.7/site-packages/frigate/cli.py", line 19, in <module>
    type=click.Choice(list_templates()),
  File "/Users/jtomlinson/miniconda3/envs/frigate-install-test/lib/python3.7/site-packages/frigate/utils.py", line 37, in list_templates
    for template in os.listdir(TEMPLATES_PATH):
FileNotFoundError: [Errno 2] No such file or directory: '/Users/jtomlinson/miniconda3/envs/frigate-install-test/lib/python3.7/site-packages/frigate/templates'

Support for descriptions above values.

It would be convenient if we could add description comments above the related value.

# This is someKey.
someKey: value1
Parameter Description Default
someKey This is someKey. "value1"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.