Skip to content

Commit

Permalink
Releasing version 2.4.15 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mross22 authored Jan 26, 2018
1 parent 668fb0a commit 67b1062
Show file tree
Hide file tree
Showing 39 changed files with 2,582 additions and 1,701 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a
Changelog <http://keepachangelog.com/>`__.

2.4.15 - 2018-01-25
---------------------
Added
~~~~~~~~~~
* Support for using the ``ObjectReadWithoutList`` public access type when creating and updating buckets
* Support for managing dynamic groups (oci iam dynamic-group)
* Support for instance principal auth (using --auth instance_principal option)

2.4.14 - 2018-01-11
--------------------
Added
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Jinja2==2.9.6
jmespath==0.9.3
ndg-httpsclient==0.4.2
mock==2.0.0
oci==1.3.12
oci==1.3.13
packaging==16.8
pluggy==0.4.0
py==1.4.33
Expand All @@ -30,4 +30,5 @@ sphinx==1.6.4
sphinx-rtd-theme==0.2.5b1
terminaltables==3.1.0
tox==2.9.1
vcrpy==1.11.1
virtualenv==15.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def open_relative(*path):


requires = [
'oci==1.3.12',
'oci==1.3.13',
'arrow==0.10.0',
'certifi',
'click==6.7',
Expand Down
17 changes: 14 additions & 3 deletions src/oci_cli/bin/OciTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ $ociSubcommands = @{
'db system' = 'get launch list patch terminate update'
'db system-shape' = 'list'
'db version' = 'list'
'iam' = 'availability-domain compartment customer-secret-key group policy region region-subscription tag tag-namespace user'
'iam' = 'availability-domain compartment customer-secret-key dynamic-group group policy region region-subscription tag tag-namespace user'
'iam availability-domain' = 'list'
'iam compartment' = 'create get list update'
'iam customer-secret-key' = 'create delete list update'
'iam dynamic-group' = 'create delete get list update'
'iam group' = 'add-user create delete get list list-users remove-user update'
'iam policy' = 'create delete get list update'
'iam region' = 'list'
Expand Down Expand Up @@ -195,6 +196,11 @@ $ociCommandsToLongParams = @{
'iam customer-secret-key delete' = 'customer-secret-key-id force from-json help if-match user-id'
'iam customer-secret-key list' = 'from-json help user-id'
'iam customer-secret-key update' = 'customer-secret-key-id display-name from-json help if-match user-id'
'iam dynamic-group create' = 'compartment-id description from-json help matching-rule max-wait-seconds name wait-for-state wait-interval-seconds'
'iam dynamic-group delete' = 'dynamic-group-id force from-json help if-match max-wait-seconds wait-for-state wait-interval-seconds'
'iam dynamic-group get' = 'dynamic-group-id from-json help'
'iam dynamic-group list' = 'all compartment-id from-json help limit page page-size'
'iam dynamic-group update' = 'description dynamic-group-id from-json help if-match matching-rule max-wait-seconds wait-for-state wait-interval-seconds'
'iam group add-user' = 'from-json group-id help user-id'
'iam group create' = 'compartment-id defined-tags description freeform-tags from-json help max-wait-seconds name wait-for-state wait-interval-seconds'
'iam group delete' = 'force from-json group-id help if-match max-wait-seconds wait-for-state wait-interval-seconds'
Expand Down Expand Up @@ -255,9 +261,9 @@ $ociCommandsToLongParams = @{
'lb certificate list' = 'from-json help load-balancer-id'
'lb health-checker get' = 'backend-set-name from-json help load-balancer-id'
'lb health-checker update' = 'backend-set-name from-json help interval-in-millis load-balancer-id max-wait-seconds port protocol response-body-regex retries return-code timeout-in-millis url-path wait-for-state wait-interval-seconds'
'lb listener create' = 'default-backend-set-name from-json help load-balancer-id max-wait-seconds name port protocol ssl-certificate-name ssl-verify-depth ssl-verify-peer-certificate wait-for-state wait-interval-seconds'
'lb listener create' = 'connection-configuration-idle-timeout default-backend-set-name from-json help load-balancer-id max-wait-seconds name port protocol ssl-certificate-name ssl-verify-depth ssl-verify-peer-certificate wait-for-state wait-interval-seconds'
'lb listener delete' = 'force from-json help listener-name load-balancer-id max-wait-seconds wait-for-state wait-interval-seconds'
'lb listener update' = 'default-backend-set-name force from-json help listener-name load-balancer-id max-wait-seconds port protocol ssl-certificate-name ssl-verify-depth ssl-verify-peer-certificate wait-for-state wait-interval-seconds'
'lb listener update' = 'connection-configuration-idle-timeout default-backend-set-name force from-json help listener-name load-balancer-id max-wait-seconds port protocol ssl-certificate-name ssl-verify-depth ssl-verify-peer-certificate wait-for-state wait-interval-seconds'
'lb load-balancer create' = 'backend-sets certificates compartment-id display-name from-json help is-private listeners max-wait-seconds shape-name subnet-ids wait-for-state wait-interval-seconds'
'lb load-balancer delete' = 'force from-json help load-balancer-id max-wait-seconds wait-for-state wait-interval-seconds'
'lb load-balancer get' = 'from-json help load-balancer-id'
Expand Down Expand Up @@ -476,6 +482,11 @@ $ociCommandsToShortParams = @{
'iam customer-secret-key delete' = '? h'
'iam customer-secret-key list' = '? h'
'iam customer-secret-key update' = '? h'
'iam dynamic-group create' = '? c h'
'iam dynamic-group delete' = '? h'
'iam dynamic-group get' = '? h'
'iam dynamic-group list' = '? c h'
'iam dynamic-group update' = '? h'
'iam group add-user' = '? h'
'iam group create' = '? c h'
'iam group delete' = '? h'
Expand Down
17 changes: 17 additions & 0 deletions src/oci_cli/cli_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding: utf-8
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

CLI_RC_FALLBACK_LOCATION = '~/.oci/cli-defaults'
CLI_RC_DEFAULT_LOCATION = '~/.oci/oci_cli_rc'
CLI_RC_CANNED_QUERIES_SECTION_NAME = 'OCI_CLI_CANNED_QUERIES'
CLI_RC_COMMAND_ALIASES_SECTION_NAME = 'OCI_CLI_COMMAND_ALIASES'
CLI_RC_PARAM_ALIASES_SECTION_NAME = 'OCI_CLI_PARAM_ALIASES'
CLI_RC_GENERIC_SETTINGS_SECTION_NAME = 'OCI_CLI_SETTINGS'

OCI_CLI_PROFILE_ENV_VAR = 'OCI_CLI_PROFILE'
CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY = 'default_profile'
CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP = 'use_click_help'

OCI_CLI_AUTH_ENV_VAR = 'OCI_CLI_AUTH'
OCI_CLI_AUTH_INSTANCE_PRINCIPAL = 'instance_principal'
OCI_CLI_AUTH_API_KEY = 'api_key'
52 changes: 28 additions & 24 deletions src/oci_cli/cli_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from . import help_text_producer
from . import cli_util

from . import cli_constants

# Enable WARN logging to surface important warnings attached to loading
# defaults, automatic coercion, or fallback values/endpoints that may impact
# the user's security.
Expand All @@ -31,21 +33,12 @@

BMCS_DEPRECATION_NOTICE = """WARNING: Invoking the CLI using 'bmcs' is deprecated and will be removed in future versions, starting in March 2018. To avoid interruption at that time, please move to invoking the CLI using 'oci' instead."""

CLI_RC_FALLBACK_LOCATION = '~/.oci/cli-defaults'
CLI_RC_DEFAULT_LOCATION = '~/.oci/oci_cli_rc'
CLI_RC_CANNED_QUERIES_SECTION_NAME = 'OCI_CLI_CANNED_QUERIES'
CLI_RC_COMMAND_ALIASES_SECTION_NAME = 'OCI_CLI_COMMAND_ALIASES'
CLI_RC_PARAM_ALIASES_SECTION_NAME = 'OCI_CLI_PARAM_ALIASES'
CLI_RC_GENERIC_SETTINGS_SECTION_NAME = 'OCI_CLI_SETTINGS'

OCI_CLI_PROFILE_ENV_VAR = 'OCI_CLI_PROFILE'
CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY = 'default_profile'
CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP = 'use_click_help'
OCI_CLI_AUTH_CHOICES = [cli_constants.OCI_CLI_AUTH_API_KEY, cli_constants.OCI_CLI_AUTH_INSTANCE_PRINCIPAL]


def eager_load_cli_rc_file(ctx, param, value):
expanded_rc_default_location = os.path.expandvars(os.path.expanduser(CLI_RC_DEFAULT_LOCATION))
expanded_rc_fallback_location = os.path.expandvars(os.path.expanduser(CLI_RC_FALLBACK_LOCATION))
expanded_rc_default_location = os.path.expandvars(os.path.expanduser(cli_constants.CLI_RC_DEFAULT_LOCATION))
expanded_rc_fallback_location = os.path.expandvars(os.path.expanduser(cli_constants.CLI_RC_FALLBACK_LOCATION))

file_location = os.path.expandvars(os.path.expanduser(value))
ctx.obj = {
Expand Down Expand Up @@ -92,7 +85,7 @@ def populate_aliases_canned_queries_and_settings(ctx, parser_without_defaults):


def populate_settings(ctx, parser_without_defaults):
raw_settings = get_section_without_defaults(parser_without_defaults, CLI_RC_GENERIC_SETTINGS_SECTION_NAME)
raw_settings = get_section_without_defaults(parser_without_defaults, cli_constants.CLI_RC_GENERIC_SETTINGS_SECTION_NAME)

settings = {}
if raw_settings:
Expand All @@ -103,7 +96,7 @@ def populate_settings(ctx, parser_without_defaults):


def populate_command_aliases(ctx, parser_without_defaults):
raw_command_aliases = get_section_without_defaults(parser_without_defaults, CLI_RC_COMMAND_ALIASES_SECTION_NAME)
raw_command_aliases = get_section_without_defaults(parser_without_defaults, cli_constants.CLI_RC_COMMAND_ALIASES_SECTION_NAME)

# Global aliases, e.g. a "ls=list" mapping would mean someone could do "compute image ls" or "os bucket ls" or "network subnet ls". These aliases
# must be a single word only
Expand All @@ -130,7 +123,7 @@ def populate_command_aliases(ctx, parser_without_defaults):


def populate_parameter_aliases(ctx, parser_without_defaults):
raw_parameter_aliases = get_section_without_defaults(parser_without_defaults, CLI_RC_PARAM_ALIASES_SECTION_NAME)
raw_parameter_aliases = get_section_without_defaults(parser_without_defaults, cli_constants.CLI_RC_PARAM_ALIASES_SECTION_NAME)

canonical_param_to_alias = {}

Expand Down Expand Up @@ -169,7 +162,7 @@ def populate_parameter_aliases(ctx, parser_without_defaults):


def populate_canned_queries(ctx, parser_without_defaults):
raw_canned_queries = get_section_without_defaults(parser_without_defaults, CLI_RC_CANNED_QUERIES_SECTION_NAME)
raw_canned_queries = get_section_without_defaults(parser_without_defaults, cli_constants.CLI_RC_CANNED_QUERIES_SECTION_NAME)

if raw_canned_queries:
ctx.obj['canned_queries'] = dict(raw_canned_queries)
Expand Down Expand Up @@ -201,7 +194,7 @@ def get_section_without_defaults(parser_without_defaults, section_name):
default=Sentinel(DEFAULT_PROFILE), show_default=False,
help='The profile in the config file to load. This profile will also be used to locate any default parameter values which have been specified in the OCI CLI-specific configuration file. [default: DEFAULT]')
@click.option('--cli-rc-file', '--defaults-file',
default=CLI_RC_DEFAULT_LOCATION, show_default=True,
default=cli_constants.CLI_RC_DEFAULT_LOCATION, show_default=True,
is_eager=True, callback=eager_load_cli_rc_file,
help='The path to the OCI CLI-specific configuration file, containing parameter default values and other configuration information such as command aliases and predefined queries. The --defaults-file option is deprecated and you should use the --cli-rc-file option instead.')
@click.option('--opc-request-id', '--opc-client-request-id', '--request-id', 'request_id',
Expand All @@ -215,6 +208,7 @@ def get_section_without_defaults(parser_without_defaults, section_name):
Queries can be entered directly on the command line or referenced from the [OCI_CLI_COMMAND_ALIASES] section of your configuration file by using the syntax query://<query_name>, for example query://get_id_and_name
""")
@click.option('--raw-output', is_flag=True, help='If the output of a given query is a single string value, this will return the string without surrounding quotes')
@click.option('--auth', type=click.Choice(choices=OCI_CLI_AUTH_CHOICES), help='The type of auth to use for the API request. By default the API key in your config file will be used. This value can also be provided in the {auth_env_var} environment variable.'.format(auth_env_var=cli_constants.OCI_CLI_AUTH_ENV_VAR))
@click.option('--generate-full-command-json-input', is_flag=True, is_eager=True, help="""Prints out a JSON document which represents all possible options that can be provided to this command.
This JSON document can be saved to a file, modified with the appropriate option values, and then passed back via the --from-json option. This provides an alternative to typing options out on the command line.""")
Expand All @@ -224,7 +218,7 @@ def get_section_without_defaults(parser_without_defaults, section_name):
@click.option('-d', '--debug', is_flag=True, help='Show additional debug information.')
@click.option('-?', '-h', '--help', is_flag=True, help='Show this message and exit.')
@click.pass_context
def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint, cert_bundle, output, query, raw_output, generate_full_command_json_input, generate_param_json_input, debug, help):
def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint, cert_bundle, output, query, raw_output, auth, generate_full_command_json_input, generate_param_json_input, debug, help):
if ctx.command_path == 'bmcs':
click.echo(click.style(BMCS_DEPRECATION_NOTICE, fg='red'), file=sys.stderr)

Expand All @@ -241,13 +235,22 @@ def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint,
#
# --profile cannot be specified as a regular default because we use it to determine which
# section of the default file to read from
if OCI_CLI_PROFILE_ENV_VAR in os.environ:
profile = os.environ[OCI_CLI_PROFILE_ENV_VAR]
elif 'settings' in ctx.obj and CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY in ctx.obj['settings']:
profile = ctx.obj['settings'][CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY]
if cli_constants.OCI_CLI_PROFILE_ENV_VAR in os.environ:
profile = os.environ[cli_constants.OCI_CLI_PROFILE_ENV_VAR]
elif 'settings' in ctx.obj and cli_constants.CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY in ctx.obj['settings']:
profile = ctx.obj['settings'][cli_constants.CLI_RC_GENERIC_SETTINGS_DEFAULT_PROFILE_KEY]
else:
profile = DEFAULT_PROFILE

if auth is None:
# if --auth is not supplied, fallback accordingly:
# - if OCI_CLI_AUTH exists, use that
if cli_constants.OCI_CLI_AUTH_ENV_VAR in os.environ:
if os.environ[cli_constants.OCI_CLI_AUTH_ENV_VAR] in OCI_CLI_AUTH_CHOICES:
auth = os.environ[cli_constants.OCI_CLI_AUTH_ENV_VAR]
else:
raise click.BadParameter('invalid choice: {arg_value}. (choose from {choices})'.format(arg_value=os.environ[cli_constants.OCI_CLI_AUTH_ENV_VAR], choices=', '.join(OCI_CLI_AUTH_CHOICES)), param_hint='OCI_CLI_AUTH')

initial_dict = {
'config_file': config_file,
'profile': profile,
Expand All @@ -261,7 +264,8 @@ def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint,
'raw_output': raw_output,
'generate_full_command_json_input': generate_full_command_json_input,
'generate_param_json_input': generate_param_json_input,
'debug': debug
'debug': debug,
'auth': auth
}

if not ctx.obj:
Expand All @@ -273,7 +277,7 @@ def cli(ctx, config_file, profile, defaults_file, request_id, region, endpoint,

if help:
ctx.obj['help'] = True
if is_top_level_help(ctx) and not cli_util.parse_boolean(ctx.obj.get('settings', {}).get(CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP, False)):
if is_top_level_help(ctx) and not cli_util.parse_boolean(ctx.obj.get('settings', {}).get(cli_constants.CLI_RC_GENERIC_SETTINGS_USE_CLICK_HELP, False)):
help_text_producer.render_help_text(ctx, [sys.argv[1]])


Expand Down
4 changes: 2 additions & 2 deletions src/oci_cli/cli_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from __future__ import print_function
import click
from .cli_root import cli, CLI_RC_CANNED_QUERIES_SECTION_NAME, CLI_RC_COMMAND_ALIASES_SECTION_NAME, CLI_RC_PARAM_ALIASES_SECTION_NAME
from .cli_root import cli
from .cli_constants import CLI_RC_CANNED_QUERIES_SECTION_NAME, CLI_RC_COMMAND_ALIASES_SECTION_NAME, CLI_RC_PARAM_ALIASES_SECTION_NAME, CLI_RC_DEFAULT_LOCATION
from . import cli_util
from .cli_root import CLI_RC_DEFAULT_LOCATION

import base64
import hashlib
Expand Down
Loading

0 comments on commit 67b1062

Please sign in to comment.