Skip to content

Commit

Permalink
Merge branch 'release-1.34.3'
Browse files Browse the repository at this point in the history
* release-1.34.3:
  Bumping version to 1.34.3
  Update changelog based on model updates
  Remove codestar examples following the deprecation of the service on July 31, 2024. (#8874)
  Fix license formatting issues
  Format base *.py files at top level awscli directory
  Add ruff config for awscli
  • Loading branch information
aws-sdk-python-automation committed Aug 21, 2024
2 parents 9c01d8d + e906e8d commit 0ac6015
Show file tree
Hide file tree
Showing 50 changed files with 1,614 additions and 1,432 deletions.
32 changes: 32 additions & 0 deletions .changes/1.34.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"category": "``ec2``",
"description": "DescribeInstanceStatus now returns health information on EBS volumes attached to Nitro instances",
"type": "api-change"
},
{
"category": "``entityresolution``",
"description": "Increase the mapping attributes in Schema to 35.",
"type": "api-change"
},
{
"category": "``glue``",
"description": "Add optional field JobRunQueuingEnabled to CreateJob and UpdateJob APIs.",
"type": "api-change"
},
{
"category": "``lambda``",
"description": "Release FilterCriteria encryption for Lambda EventSourceMapping, enabling customers to encrypt their filter criteria using a customer-owned KMS key.",
"type": "api-change"
},
{
"category": "``securityhub``",
"description": "Security Hub documentation and definition updates",
"type": "api-change"
},
{
"category": "``ses``",
"description": "Enable email receiving customers to provide SES with access to their S3 buckets via an IAM role for \"Deliver to S3 Action\"",
"type": "api-change"
}
]
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
exclude: "\
^(\
.github|\
.changes|\
docs/|\
awscli/examples|\
CHANGELOG.rst\
)"
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: 'https://github.com/PyCQA/isort'
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format

11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
CHANGELOG
=========

1.34.3
======

* api-change:``ec2``: DescribeInstanceStatus now returns health information on EBS volumes attached to Nitro instances
* api-change:``entityresolution``: Increase the mapping attributes in Schema to 35.
* api-change:``glue``: Add optional field JobRunQueuingEnabled to CreateJob and UpdateJob APIs.
* api-change:``lambda``: Release FilterCriteria encryption for Lambda EventSourceMapping, enabling customers to encrypt their filter criteria using a customer-owned KMS key.
* api-change:``securityhub``: Security Hub documentation and definition updates
* api-change:``ses``: Enable email receiving customers to provide SES with access to their S3 buckets via an IAM role for "Deliver to S3 Action"


1.34.2
======

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include README.rst
include LICENSE.txt
include requirements.txt
include UPGRADE_PY3.md
include .pre-commit-config.yaml
recursive-include awscli/examples *.rst *.txt
recursive-include awscli/data *.json
recursive-include awscli/topics *.rst *.json
19 changes: 14 additions & 5 deletions awscli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
----
A Universal Command Line Environment for Amazon Web Services.
"""

import os

__version__ = '1.34.2'
__version__ = '1.34.3'

#
# Get our data path to be added to botocore's search path
Expand All @@ -40,8 +41,16 @@
}


SCALAR_TYPES = set([
'string', 'float', 'integer', 'long', 'boolean', 'double',
'blob', 'timestamp'
])
SCALAR_TYPES = set(
[
'string',
'float',
'integer',
'long',
'boolean',
'double',
'blob',
'timestamp',
]
)
COMPLEX_TYPES = set(['structure', 'map', 'list'])
1 change: 0 additions & 1 deletion awscli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@

from awscli.clidriver import main


if __name__ == "__main__":
sys.exit(main())
97 changes: 57 additions & 40 deletions awscli/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@

from botocore.configloader import raw_config_parse

from awscli.compat import compat_shell_quote
from awscli.commands import CLICommand
from awscli.compat import compat_shell_quote
from awscli.utils import emit_top_level_args_parsed_event


LOG = logging.getLogger(__name__)


class InvalidAliasException(Exception):
pass


class AliasLoader(object):
def __init__(self,
alias_filename=os.path.expanduser(
os.path.join('~', '.aws', 'cli', 'alias'))):
class AliasLoader:
def __init__(
self,
alias_filename=os.path.expanduser(
os.path.join('~', '.aws', 'cli', 'alias')
),
):
"""Interface for loading and interacting with alias file
:param alias_filename: The name of the file to load aliases from.
Expand All @@ -47,8 +49,7 @@ def _build_aliases(self):

def _load_aliases(self):
if os.path.exists(self._filename):
return raw_config_parse(
self._filename, parse_subsections=False)
return raw_config_parse(self._filename, parse_subsections=False)
return {'toplevel': {}}

def _cleanup_alias_values(self, aliases):
Expand All @@ -63,7 +64,7 @@ def get_aliases(self):
return self._aliases.get('toplevel', {})


class AliasCommandInjector(object):
class AliasCommandInjector:
def __init__(self, session, alias_loader):
"""Injects alias commands for a command table
Expand All @@ -77,22 +78,26 @@ def __init__(self, session, alias_loader):
self._alias_loader = alias_loader

def inject_aliases(self, command_table, parser):
for alias_name, alias_value in \
self._alias_loader.get_aliases().items():
for (
alias_name,
alias_value,
) in self._alias_loader.get_aliases().items():
if alias_value.startswith('!'):
alias_cmd = ExternalAliasCommand(alias_name, alias_value)
else:
service_alias_cmd_args = [
alias_name, alias_value, self._session, command_table,
parser
alias_name,
alias_value,
self._session,
command_table,
parser,
]
# If the alias name matches something already in the
# command table provide the command it is about
# to clobber as a possible reference that it will
# need to proxy to.
if alias_name in command_table:
service_alias_cmd_args.append(
command_table[alias_name])
service_alias_cmd_args.append(command_table[alias_name])
alias_cmd = ServiceAliasCommand(*service_alias_cmd_args)
command_table[alias_name] = alias_cmd

Expand Down Expand Up @@ -126,13 +131,17 @@ def name(self, value):


class ServiceAliasCommand(BaseAliasCommand):
UNSUPPORTED_GLOBAL_PARAMETERS = [
'debug',
'profile'
]

def __init__(self, alias_name, alias_value, session, command_table,
parser, shadow_proxy_command=None):
UNSUPPORTED_GLOBAL_PARAMETERS = ('debug', 'profile')

def __init__(
self,
alias_name,
alias_value,
session,
command_table,
parser,
shadow_proxy_command=None,
):
"""Command for a `toplevel` subcommand alias
:type alias_name: string
Expand Down Expand Up @@ -163,7 +172,7 @@ def __init__(self, alias_name, alias_value, session, command_table,
to this command as opposed to proxy to itself in the command
table
"""
super(ServiceAliasCommand, self).__init__(alias_name, alias_value)
super().__init__(alias_name, alias_value)
self._session = session
self._command_table = command_table
self._parser = parser
Expand All @@ -172,14 +181,18 @@ def __init__(self, alias_name, alias_value, session, command_table,
def __call__(self, args, parsed_globals):
alias_args = self._get_alias_args()
parsed_alias_args, remaining = self._parser.parse_known_args(
alias_args)
alias_args
)
self._update_parsed_globals(parsed_alias_args, parsed_globals)
# Take any of the remaining arguments that were not parsed out and
# prepend them to the remaining args provided to the alias.
remaining.extend(args)
LOG.debug(
'Alias %r passing on arguments: %r to %r command',
self._alias_name, remaining, parsed_alias_args.command)
self._alias_name,
remaining,
parsed_alias_args.command,
)
# Pass the update remaining args and global args to the service command
# the alias proxied to.
command = self._command_table[parsed_alias_args.command]
Expand All @@ -190,9 +203,9 @@ def __call__(self, args, parsed_globals):
# a built-in command.
if shadow_name == parsed_alias_args.command:
LOG.debug(
'Using shadowed command object: %s '
'for alias: %s', self._shadow_proxy_command,
self._alias_name
'Using shadowed command object: %s for alias: %s',
self._shadow_proxy_command,
self._alias_name,
)
command = self._shadow_proxy_command
return command(remaining, parsed_globals)
Expand All @@ -202,21 +215,23 @@ def _get_alias_args(self):
alias_args = shlex.split(self._alias_value)
except ValueError as e:
raise InvalidAliasException(
'Value of alias "%s" could not be parsed. '
'Received error: %s when parsing:\n%s' % (
self._alias_name, e, self._alias_value)
f'Value of alias "{self._alias_name}" could not be parsed. '
f'Received error: {e} when parsing:\n{self._alias_value}'
)

alias_args = [arg.strip(os.linesep) for arg in alias_args]
LOG.debug(
'Expanded subcommand alias %r with value: %r to: %r',
self._alias_name, self._alias_value, alias_args
self._alias_name,
self._alias_value,
alias_args,
)
return alias_args

def _update_parsed_globals(self, parsed_alias_args, parsed_globals):
global_params_to_update = self._get_global_parameters_to_update(
parsed_alias_args)
parsed_alias_args
)
# Emit the top level args parsed event to ensure all possible
# customizations that typically get applied are applied to the
# global parameters provided in the alias before updating
Expand All @@ -241,9 +256,10 @@ def _get_global_parameters_to_update(self, parsed_alias_args):
if self._parser.get_default(parsed_param) != value:
if parsed_param in self.UNSUPPORTED_GLOBAL_PARAMETERS:
raise InvalidAliasException(
'Global parameter "--%s" detected in alias "%s" '
'which is not support in subcommand aliases.' % (
parsed_param, self._alias_name))
f'Global parameter "--{parsed_param}" detected in alias '
f'"{self._alias_name}" which is not support in '
'subcommand aliases.'
)
else:
global_params_to_update.append(parsed_param)
return global_params_to_update
Expand Down Expand Up @@ -272,12 +288,13 @@ def __init__(self, alias_name, alias_value, invoker=subprocess.call):
self._invoker = invoker

def __call__(self, args, parsed_globals):
command_components = [
self._alias_value[1:]
]
command_components = [self._alias_value[1:]]
command_components.extend(compat_shell_quote(a) for a in args)
command = ' '.join(command_components)
LOG.debug(
'Using external alias %r with value: %r to run: %r',
self._alias_name, self._alias_value, command)
self._alias_name,
self._alias_value,
command,
)
return self._invoker(command, shell=True)
Loading

0 comments on commit 0ac6015

Please sign in to comment.