Skip to content

Commit

Permalink
Merge pull request #430 from linode/dev
Browse files Browse the repository at this point in the history
Release v5.35.0
  • Loading branch information
lgarber-akamai authored Apr 3, 2023
2 parents 916859c + 351806c commit 23a4480
Show file tree
Hide file tree
Showing 63 changed files with 1,548 additions and 3,062 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
4 changes: 2 additions & 2 deletions .github/workflows/e2e-suite-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

# Check out merge commit
- name: Checkout PR
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.slash_command.sha }}

Expand All @@ -40,7 +40,7 @@ jobs:
python-version: '3.x'

- name: Install Python deps
run: pip install -r requirements.txt -r requirements-dev.txt wheel boto
run: pip install -r requirements.txt -r requirements-dev.txt wheel boto3

- name: Install the CLI
run: make install
Expand Down
32 changes: 15 additions & 17 deletions .github/workflows/e2e-suite.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
name: E2E Test Suite
name: Integration Tests
on:
workflow_dispatch: null
push:
branches:
- main
- dev
jobs:
integration_tests:
integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # pin@v2
uses: actions/checkout@v3

- name: Update system packages
run: sudo apt-get update -y

- name: Install system deps
run: sudo apt-get install -y build-essential bats parallel netcat

- name: Setup Python
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # pin@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Python deps
run: pip install wheel
run: pip install wheel boto3

- name: Update cert
run: pip install certifi -U

- name: Install the CLI
- name: Install deps
run: pip install -r requirements.txt -r requirements-dev.txt

- name: Install Package
run: make install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download submodules
run: git submodule init && git submodule update

- name: Run the E2E test suite
run: echo "y" | ./test/test-runner.sh --allow-delete-resources --from-env --no-parallel
# We do not have multiple CLI testing accounts at the moment
- name: Run the integration test suite
run: make testint
env:
TOKEN_1: ${{ secrets.LINODE_TOKEN }}
TOKEN_2: ${{ secrets.LINODE_TOKEN }}
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # pin@v2
uses: actions/checkout@v3

- name: setup python 3
uses: actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6 # pin@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/remote-release-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
# We want to checkout the main branch
ref: 'main'
fetch-depth: 0

- name: Get previous tag
Expand All @@ -38,7 +40,7 @@ jobs:
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
with:
target_commitish: 'main'
token: ${{ steps.generate_token.outputs.token }}
body: Built from Linode OpenAPI spec ${{
github.event.client_payload.spec_version }}
body: Built from Linode OpenAPI spec ${{ github.event.client_payload.spec_version }}
tag_name: ${{ steps.semvers.outputs.v_minor }}
9 changes: 6 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # pin@v2
uses: actions/checkout@v3

- name: Update system packages
run: sudo apt-get update -y

- name: Setup Python
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # pin@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Python wheel
run: pip install wheel
run: pip install wheel boto3

- name: Update cert
run: pip install certifi -U

- name: Install deps
run: pip install -r requirements.txt -r requirements-dev.txt
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-release
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM python:3.9-slim-buster

COPY --from=builder /src/dist /dist

RUN pip3 install /dist/*.whl boto==2.49.0
RUN pip3 install /dist/*.whl boto3

RUN useradd -ms /bin/bash cli
USER cli:cli
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ testunit:
testint:
pytest tests/integration/${INTEGRATION_TEST_PATH}

.PHONY: testall
testall:
pytest tests


# Alias for unit; integration tests should be explicit
.PHONY: test
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Upgrading::
Usage
-----

The Linode CLI is invoked with the `linode-cli`. The CLI accepts two primary
arguments, *command* and *action*::
The Linode CLI is invoked with the `linode-cli`. There are two aliases available: `linode` and `lin`.
The CLI accepts two primary arguments, *command* and *action*::

linode-cli <command> <action>

Expand Down
6 changes: 5 additions & 1 deletion linodecli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
"""
Handle incoming command arguments
"""
parser = argparse.ArgumentParser("linode-cli", add_help=False)
parser = argparse.ArgumentParser(
"linode-cli",
add_help=False,
description="The Linode Command Line Interface.\n\nAliases: lin, linode",
)
parsed, args = register_args(parser).parse_known_args()

# output/formatting settings
Expand Down
11 changes: 11 additions & 0 deletions linodecli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@ def handle_command(self, command, action, args):
Given a command, action, and remaining kwargs, finds and executes the
action
"""
if (command, action) in [
("linodes", "ips-list"),
("firewalls", "rules-list"),
] and "--json" not in args:
print(
"This output contains a nested structure that may not properly "
+ "be displayed by linode-cli.",
"A fix is currently on the roadmap but has not yet been implemented.",
"Please use --json for endpoints like this in the meantime.",
file=sys.stderr,
)

try:
operation = self.find_operation(command, action)
Expand Down
12 changes: 10 additions & 2 deletions linodecli/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ def get_fish_completions(ops):
completion_template = Template(
"""# This is a generated file by Linode-CLI! Do not modify!
complete -c linode-cli -n "not __fish_seen_subcommand_from $subcommands" -x -a '$subcommands --help'
complete -c linode -n "not __fish_seen_subcommand_from $subcommands" -x -a '$subcommands --help'
complete -c lin -n "not __fish_seen_subcommand_from $subcommands" -x -a '$subcommands --help'
$command_items"""
)

command_template = Template(
"""complete -c linode-cli -n "__fish_seen_subcommand_from $command" \
-x -a '$actions --help'
complete -c linode -n "__fish_seen_subcommand_from $command" \
-x -a '$actions --help'
complete -c lin -n "__fish_seen_subcommand_from $command" \
-x -a '$actions --help'"""
)

Expand Down Expand Up @@ -84,7 +90,7 @@ def get_bash_completions(ops):
prev="${COMP_WORDS[COMP_CWORD-1]}"
case "${prev}" in
linode-cli)
linode-cli | linode | lin)
COMPREPLY=( $(compgen -W "$actions --help" -- ${cur}) )
return 0
;;
Expand All @@ -94,7 +100,9 @@ def get_bash_completions(ops):
esac
}
complete -F _linode_cli linode-cli"""
complete -F _linode_cli linode-cli
complete -F _linode_cli linode
complete -F _linode_cli lin"""
)

command_template = Template(
Expand Down
36 changes: 22 additions & 14 deletions linodecli/configuration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,28 @@ def _handle_no_default_user(self):
self.config.set("DEFAULT", "default-user", username)
self.config.add_section(username)
self.config.set(username, "token", token)
self.config.set(
username, "region", self.config.get("DEFAULT", "region")
)
self.config.set(
username, "type", self.config.get("DEFAULT", "type")
)
self.config.set(
username, "image", self.config.get("DEFAULT", "image")
)
self.config.set(
username,
"authorized_keys",
self.config.get("DEFAULT", "authorized_keys"),
)

if self.config.has_option("DEFAULT", "region"):
self.config.set(
username, "region", self.config.get("DEFAULT", "region")
)

if self.config.has_option("DEFAULT", "type"):
self.config.set(
username, "type", self.config.get("DEFAULT", "type")
)

if self.config.has_option("DEFAULT", "image"):
self.config.set(
username, "image", self.config.get("DEFAULT", "image")
)

if self.config.has_option("DEFAULT", "authorized_keys"):
self.config.set(
username,
"authorized_keys",
self.config.get("DEFAULT", "authorized_keys"),
)

self.write_config()
else:
Expand Down
14 changes: 14 additions & 0 deletions linodecli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Various helper functions shared across multiple CLI components.
"""

import glob
import os
import re
from pathlib import Path
from urllib.parse import urlparse

API_HOST_OVERRIDE = os.getenv("LINODE_CLI_API_HOST")
Expand Down Expand Up @@ -71,3 +73,15 @@ def register_args_shared(parser):
)

return parser


def expand_globs(pattern: str):
"""
Expand glob pattern (for example, '/some/path/*.txt')
to be a list of path object.
"""
results = glob.glob(pattern, recursive=True)
if len(results) < 1:
print(f"No file found matching pattern {pattern}")

return [Path(x).resolve() for x in results]
Loading

0 comments on commit 23a4480

Please sign in to comment.