Skip to content

CRUD for EnvironmentVariables from Project's admin #4899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/builds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,4 @@ The *Sphinx* and *Mkdocs* builders set the following RTD-specific environment va
.. tip::

In case extra environment variables are needed to the build process (like secrets, tokens, etc),
you can add them going to **Admin > Environment Variables** in your project.
you can add them going to **Admin > Environment Variables** in your project. See :doc:`guides/environment-variables`.
37 changes: 37 additions & 0 deletions docs/guides/environment-variables.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
I Need Secrets (or Environment Variables) in my Build
=====================================================

It may happen that your documentation depends on an authenticated service to be built properly.
In this case, you will require some secrets to access these services.

Read the Docs provides a way to define environment variables for your project to be used in the build process.
All these variables will be exposed to all the commands executed when building your documentation.

To define an environment variable, you need to

#. Go to your project **Admin > Environment Variables**
#. Click on "Add Environment Variable" button
#. Input a ``Name`` and ``Value`` (your secret needed here)
#. Click "Save" button

.. note::

Values will never be exposed to users, even to owners of the project. Once you create an environment variable you won't be able to see its value anymore because of security purposes.

After adding an environment variable from your project's admin, you can access it from your build process using Python, for example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 addition.


.. code-block:: python

# conf.py
import os
import requests

# Access to our custom environment variables
username = os.environ.get('USERNAME')
password = os.environ.get('PASSWORD')

# Request a username/password protected URL
response = requests.get(
'https://httpbin.org/basic-auth/username/password',
auth=(username, password),
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
{% endblock %}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need copy here saying "The value here is not shown for security purposes" or similar. Otherwise it's a weird UI.

{% block project_edit_content %}

<p>
{% blocktrans trimmed %}
The value of the environment variable is not shown here for sercurity purposes.
{% endblocktrans %}
</p>

<form method="post" action="{% url 'projects_environmentvariables_delete' project_slug=project.slug environmentvariable_pk=environmentvariable.pk %}">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we want to communicate on Environment Variable detail page to the user?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to explain that "These environment variables are available to all build steps." This is another place to keep UI prose copy short.

{% csrf_token %}
<input type="submit" value="{% trans "Delete" %}">
Expand Down