mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
container: distribution as environment variable
Allow distribution to be passed as an environment variable. Fixes #1914 Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
4b0899fd65
commit
1fca2465aa
23
HACKING.md
23
HACKING.md
@ -83,6 +83,29 @@ development environment inside a systemd-nspawn container.
|
||||
host$ ./container ssh
|
||||
```
|
||||
|
||||
6. The default distribution used by the container script is "testing", but you
|
||||
can choose a different distribution (e.g. "stable") in two ways.
|
||||
|
||||
1. Using an environment variable.
|
||||
|
||||
```bash
|
||||
host$ DISTRIBUTION=stable ./container up
|
||||
host$ DISTRIBUTION=stable ./container ssh
|
||||
```
|
||||
|
||||
```bash
|
||||
host$ export DISTRIBUTION=stable
|
||||
host$ ./container up
|
||||
host$ ./container ssh
|
||||
```
|
||||
|
||||
2. Using the `--distribution` option for each command.
|
||||
|
||||
```bash
|
||||
host$ ./container up --distribution=stable
|
||||
host$ ./container ssh --distribution=stable
|
||||
```
|
||||
|
||||
#### Using after Setup
|
||||
|
||||
After logging into the container, the source code is available in `/freedombox`
|
||||
|
||||
20
container
20
container
@ -261,10 +261,16 @@ def parse_arguments():
|
||||
|
||||
distributions = list(URLS.keys())
|
||||
|
||||
distribution = os.environ.get('DISTRIBUTION')
|
||||
|
||||
default_distribution = 'testing'
|
||||
if distribution and distribution in distributions:
|
||||
default_distribution = distribution
|
||||
|
||||
# Up
|
||||
subparser = subparsers.add_parser('up', help='Bring up the container')
|
||||
subparser.add_argument(
|
||||
'--distribution', choices=distributions, default='testing',
|
||||
'--distribution', choices=distributions, default=default_distribution,
|
||||
help='Distribution of the image to download and setup')
|
||||
subparser.add_argument('--image-size', default='16G',
|
||||
help='Disk image size to resize to after download')
|
||||
@ -273,20 +279,20 @@ def parse_arguments():
|
||||
subparser = subparsers.add_parser(
|
||||
'ip', help='Print the IP address of the container.')
|
||||
subparser.add_argument(
|
||||
'--distribution', choices=distributions, default='testing',
|
||||
'--distribution', choices=distributions, default=default_distribution,
|
||||
help='Distribution of the container to print IP address')
|
||||
|
||||
# ssh
|
||||
subparser = subparsers.add_parser('ssh', help='SSH into the container')
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default='testing',
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to SSH into')
|
||||
|
||||
# Run tests
|
||||
subparser = subparsers.add_parser('run-tests',
|
||||
help='Run tests in the container')
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default='testing',
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to run tests')
|
||||
subparser.add_argument(
|
||||
'--pytest-args', nargs='...',
|
||||
@ -295,21 +301,21 @@ def parse_arguments():
|
||||
# Stop
|
||||
subparser = subparsers.add_parser('stop', help='Stop the container')
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default='testing',
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to stop')
|
||||
|
||||
# Destroy
|
||||
subparser = subparsers.add_parser('destroy',
|
||||
help='Destroy the container image')
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default='testing',
|
||||
default=default_distribution,
|
||||
help='Distribution of the image to delete')
|
||||
|
||||
# Update
|
||||
subparser = subparsers.add_parser(
|
||||
'update', help='Update the container image to the latest version')
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default='testing',
|
||||
default=default_distribution,
|
||||
help='Distribution of the image to update')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user