Skip to content

Commit

Permalink
Unpin dependencies in dev requirements file; fix lint (#375)
Browse files Browse the repository at this point in the history
* Unpin dependencies in dev requirements file

* Fix lint

* Migrate pylint config to pyproject.toml

* Update docs
  • Loading branch information
zliang-akamai authored Jun 8, 2023
1 parent 741db29 commit fb79e5a
Show file tree
Hide file tree
Showing 67 changed files with 1,100 additions and 1,127 deletions.
25 changes: 0 additions & 25 deletions .pylintrc

This file was deleted.

4 changes: 2 additions & 2 deletions docs/modules/firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Manage Linode Firewalls.
| `action` | <center>`str`</center> | <center>**Required**</center> | Controls whether traffic is accepted or dropped by this rule. **(Choices: `ACCEPT`, `DROP`)** |
| [`addresses` (sub-options)](#addresses) | <center>`dict`</center> | <center>Optional</center> | Allowed IPv4 or IPv6 addresses. |
| `description` | <center>`str`</center> | <center>Optional</center> | A description for this rule. |
| `ports` | <center>`str`</center> | <center>Optional</center> | A string representing the port or ports on which traffic will be allowed. See U(https://www.linode.com/docs/api/networking/#firewall-create) |
| `ports` | <center>`str`</center> | <center>Optional</center> | A string representing the port or ports on which traffic will be allowed. See https://www.linode.com/docs/api/networking/#firewall-create |
| `protocol` | <center>`str`</center> | <center>Optional</center> | The type of network traffic to allow. |

### addresses
Expand All @@ -104,7 +104,7 @@ Manage Linode Firewalls.
| `action` | <center>`str`</center> | <center>**Required**</center> | Controls whether traffic is accepted or dropped by this rule. **(Choices: `ACCEPT`, `DROP`)** |
| [`addresses` (sub-options)](#addresses) | <center>`dict`</center> | <center>Optional</center> | Allowed IPv4 or IPv6 addresses. |
| `description` | <center>`str`</center> | <center>Optional</center> | A description for this rule. |
| `ports` | <center>`str`</center> | <center>Optional</center> | A string representing the port or ports on which traffic will be allowed. See U(https://www.linode.com/docs/api/networking/#firewall-create) |
| `ports` | <center>`str`</center> | <center>Optional</center> | A string representing the port or ports on which traffic will be allowed. See https://www.linode.com/docs/api/networking/#firewall-create |
| `protocol` | <center>`str`</center> | <center>Optional</center> | The type of network traffic to allow. |

## Return Values
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Manage a Linode Volume.
| `label` | <center>`str`</center> | <center>Optional</center> | The Volume’s label, which is also used in the filesystem_path of the resulting volume. |
| `config_id` | <center>`int`</center> | <center>Optional</center> | When creating a Volume attached to a Linode, the ID of the Linode Config to include the new Volume in. |
| `linode_id` | <center>`int`</center> | <center>Optional</center> | The Linode this volume should be attached to upon creation. If not given, the volume will be created without an attachment. **(Updatable)** |
| `region` | <center>`str`</center> | <center>Optional</center> | The location to deploy the volume in. See U(https://api.linode.com/v4/regions) |
| `region` | <center>`str`</center> | <center>Optional</center> | The location to deploy the volume in. See https://api.linode.com/v4/regions |
| `size` | <center>`int`</center> | <center>Optional</center> | The size of this volume, in GB. Be aware that volumes may only be resized up after creation. **(Updatable)** |
| `attached` | <center>`bool`</center> | <center>Optional</center> | If true, the volume will be attached to a Linode. Otherwise, the volume will be detached. **(Default: `True`; Updatable)** |
| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The amount of time, in seconds, to wait for a volume to have the active status. **(Default: `240`)** |
Expand Down
77 changes: 40 additions & 37 deletions plugins/module_utils/linode_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,45 @@
f"Ansible/{ANSIBLE_VERSION}"
)

LINODE_COMMON_ARGS = dict(
api_token=dict(
type="str",
fallback=(env_fallback, ["LINODE_API_TOKEN", "LINODE_TOKEN"]),
required=True,
no_log=True,
),
api_version=dict(
type="str",
fallback=(env_fallback, ["LINODE_API_VERSION"]),
default="v4",
),
state=dict(
type="str",
required=True,
choices=["present", "absent"],
),
ua_prefix=dict(
type="str",
description="An HTTP User-Agent Prefix to prepend in API requests.",
doc_hide=True,
fallback=(env_fallback, ["LINODE_UA_PREFIX"]),
),
)

LINODE_TAG_ARGS = dict(
tags=dict(type="list", description="The tags to assign to this resource."),
)

LINODE_LABEL_ARGS = dict(
label=dict(
type="str",
required=True,
description="The label to assign to this resource.",
),
)
LINODE_COMMON_ARGS = {
"api_token": {
"type": "str",
"fallback": (env_fallback, ["LINODE_API_TOKEN", "LINODE_TOKEN"]),
"required": True,
"no_log": True,
},
"api_version": {
"type": "str",
"fallback": (env_fallback, ["LINODE_API_VERSION"]),
"default": "v4",
},
"state": {
"type": "str",
"required": True,
"choices": ["present", "absent"],
},
"ua_prefix": {
"type": "str",
"description": "An HTTP User-Agent Prefix to prepend in API requests.",
"doc_hide": True,
"fallback": (env_fallback, ["LINODE_UA_PREFIX"]),
},
}

LINODE_TAG_ARGS = {
"tags": {
"type": "list",
"description": "The tags to assign to this resource.",
},
}

LINODE_LABEL_ARGS = {
"label": {
"type": "str",
"required": True,
"description": "The label to assign to this resource.",
},
}

RESOURCE_NAMES = (
{
Expand Down Expand Up @@ -151,7 +154,7 @@ def __init__(
required_if=required_if,
)

self.results: dict = self.results or dict(changed=False, actions=[])
self.results: dict = self.results or {"changed": False, "actions": []}

# This field may or may not be present depending on the module
timeout_param = self.module.params.get("wait_timeout", 120)
Expand Down
14 changes: 7 additions & 7 deletions plugins/module_utils/linode_database_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
from ansible_specdoc.objects import FieldType, SpecField
from linode_api4 import ApiError

SPEC_UPDATE_WINDOW = dict(
day_of_week=SpecField(
SPEC_UPDATE_WINDOW = {
"day_of_week": SpecField(
type=FieldType.integer,
required=True,
choices=list(range(1, 8)),
description=[
"The day to perform maintenance. 1=Monday, 2=Tuesday, etc."
],
),
duration=SpecField(
"duration": SpecField(
type=FieldType.integer,
required=True,
choices=[1, 3],
description=["The maximum maintenance window time in hours."],
),
frequency=SpecField(
"frequency": SpecField(
type=FieldType.string,
choices=["weekly", "monthly"],
default="weekly",
description=[
"Whether maintenance occurs on a weekly or monthly basis."
],
),
hour_of_day=SpecField(
"hour_of_day": SpecField(
type=FieldType.integer,
required=True,
description=["The hour to begin maintenance based in UTC time."],
),
week_of_month=SpecField(
"week_of_month": SpecField(
type=FieldType.integer,
description=[
"The week of the month to perform monthly frequency updates.",
Expand All @@ -44,7 +44,7 @@
"Must be null for weekly frequency updates.",
],
),
)
}


def validate_allow_list(allow_list: Set[str]) -> None:
Expand Down
19 changes: 8 additions & 11 deletions plugins/modules/account_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from __future__ import absolute_import, division, print_function

# pylint: disable=unused-import
from typing import Any, List, Optional

import ansible_collections.linode.cloud.plugins.module_utils.doc_fragments.account_info as docs
Expand All @@ -23,26 +22,26 @@
SpecReturnValue,
)

spec = dict(
spec = {
# Disable the default values
label=SpecField(type=FieldType.string, required=False, doc_hide=True),
state=SpecField(type=FieldType.string, required=False, doc_hide=True),
)
"label": SpecField(type=FieldType.string, required=False, doc_hide=True),
"state": SpecField(type=FieldType.string, required=False, doc_hide=True),
}

SPECDOC_META = SpecDocMeta(
description=["Get info about a Linode Account."],
requirements=global_requirements,
author=global_authors,
options=spec,
examples=docs.specdoc_examples,
return_values=dict(
account=SpecReturnValue(
return_values={
"account": SpecReturnValue(
description="The account info in JSON serialized form.",
docs_url="https://www.linode.com/docs/api/account/#account-view__response-samples",
type=FieldType.dict,
sample=docs.result_account_samples,
)
),
},
)


Expand All @@ -51,9 +50,7 @@ class Module(LinodeModuleBase):

def __init__(self) -> None:
self.required_one_of: List[str] = []
self.results = dict(
account=None,
)
self.results = {"account": None}

self.module_arg_spec = SPECDOC_META.ansible_spec

Expand Down
30 changes: 14 additions & 16 deletions plugins/modules/api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import ast
import contextlib

# pylint: disable=unused-import
import json
from typing import Any, Optional, Tuple

Expand All @@ -28,44 +26,44 @@
)
from linode_api4 import ApiError

SPEC = dict(
label=SpecField(type=FieldType.string, doc_hide=True),
state=SpecField(type=FieldType.string, doc_hide=True),
path=SpecField(
SPEC = {
"label": SpecField(type=FieldType.string, doc_hide=True),
"state": SpecField(type=FieldType.string, doc_hide=True),
"path": SpecField(
type=FieldType.string,
required=True,
description=[
"The relative path to the endpoint to make a request to.",
'e.g. "linode/instances"',
],
),
method=SpecField(
"method": SpecField(
type=FieldType.string,
required=True,
description=["The HTTP method of the request or response."],
choices=["POST", "PUT", "GET", "DELETE"],
),
body=SpecField(
"body": SpecField(
type=FieldType.dict,
conflicts_with=["body_json"],
description=[
"The body of the request.",
"This is a YAML structure that will be marshalled to JSON.",
],
),
body_json=SpecField(
"body_json": SpecField(
type=FieldType.string,
conflicts_with=["body"],
description=["The body of the request in JSON format."],
),
filters=SpecField(
"filters": SpecField(
type=FieldType.dict,
description=[
"A YAML structure corresponding to the X-Filter request header.",
"See: https://www.linode.com/docs/api/#filtering-and-sorting",
],
),
)
}

SPECDOC_META = SpecDocMeta(
description=[
Expand All @@ -77,16 +75,16 @@
author=global_authors,
options=SPEC,
examples=docs.specdoc_examples,
return_values=dict(
body=SpecReturnValue(
return_values={
"body": SpecReturnValue(
description="The deserialized response body.",
type=FieldType.dict,
sample=docs.result_body_samples,
),
status=SpecReturnValue(
"status": SpecReturnValue(
description="The response status code.", type=FieldType.integer
),
),
},
)


Expand All @@ -95,7 +93,7 @@ class Module(LinodeModuleBase):

def __init__(self) -> None:
self.module_arg_spec = SPECDOC_META.ansible_spec
self.results = dict(body={}, status=0, changed=False)
self.results = {"body": {}, "status": 0, "changed": False}

super().__init__(
module_arg_spec=self.module_arg_spec,
Expand Down
Loading

0 comments on commit fb79e5a

Please sign in to comment.