commit aws-c-sdkutils for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package aws-c-sdkutils for openSUSE:Factory checked in at 2024-08-09 16:14:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/aws-c-sdkutils (Old) and /work/SRC/openSUSE:Factory/.aws-c-sdkutils.new.7232 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "aws-c-sdkutils" Fri Aug 9 16:14:49 2024 rev:5 rq:1192593 version:0.1.19 Changes: -------- --- /work/SRC/openSUSE:Factory/aws-c-sdkutils/aws-c-sdkutils.changes 2024-06-06 12:32:20.247859423 +0200 +++ /work/SRC/openSUSE:Factory/.aws-c-sdkutils.new.7232/aws-c-sdkutils.changes 2024-08-09 16:15:21.544672329 +0200 @@ -1,0 +2,14 @@ +Wed Aug 7 13:37:56 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com> + +- Update to version 0.1.19 + * Lets make string array const input by @DmitriyMusatkin in (#44) +- from version 0.1.18 + * Switch to more efficient functions for json parsing + by @DmitriyMusatkin in (#43) +- from version 0.1.17 + * clang-format 18 by @graebm in (#40) + * Update MacOS to arm64 by @waahm7 in (#41) + * Add support for string array request parameter to + endpoint resolution by @DmitriyMusatkin in (#42) + +------------------------------------------------------------------- Old: ---- v0.1.16.tar.gz New: ---- v0.1.19.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ aws-c-sdkutils.spec ++++++ --- /var/tmp/diff_new_pack.HGIlRk/_old 2024-08-09 16:15:23.292745293 +0200 +++ /var/tmp/diff_new_pack.HGIlRk/_new 2024-08-09 16:15:23.296745460 +0200 @@ -20,7 +20,7 @@ %define library_pkg 1_0_0 %define library_soversion 1 Name: aws-c-sdkutils -Version: 0.1.16 +Version: 0.1.19 Release: 0 Summary: AWS C SDK Utils License: Apache-2.0 ++++++ v0.1.16.tar.gz -> v0.1.19.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/.github/workflows/ci.yml new/aws-c-sdkutils-0.1.19/.github/workflows/ci.yml --- old/aws-c-sdkutils-0.1.16/.github/workflows/ci.yml 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/.github/workflows/ci.yml 2024-08-03 00:36:14.000000000 +0200 @@ -6,7 +6,7 @@ - 'main' env: - BUILDER_VERSION: v0.9.55 + BUILDER_VERSION: v0.9.62 BUILDER_SOURCE: releases BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net PACKAGE_NAME: aws-c-sdkutils @@ -119,8 +119,17 @@ run: | python .\aws-c-sdkutils\build\deps\aws-c-common\scripts\appverifier_ctest.py --build_directory .\aws-c-sdkutils\build\aws-c-sdkutils - osx: - runs-on: macos-12 # latest + macos: + runs-on: macos-14 # latest + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" + chmod a+x builder + ./builder build -p ${{ env.PACKAGE_NAME }} + + macos-x64: + runs-on: macos-14-large # latest steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/.github/workflows/clang-format.yml new/aws-c-sdkutils-0.1.19/.github/workflows/clang-format.yml --- old/aws-c-sdkutils-0.1.16/.github/workflows/clang-format.yml 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/.github/workflows/clang-format.yml 2024-08-03 00:36:14.000000000 +0200 @@ -5,14 +5,12 @@ jobs: clang-format: - runs-on: ubuntu-20.04 # latest + runs-on: ubuntu-24.04 # latest steps: - name: Checkout Sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: clang-format lint - uses: DoozyX/clang-format-lint-action@v0.3.1 - with: - # List of extensions to check - extensions: c,h + run: | + ./format-check.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/format-check.py new/aws-c-sdkutils-0.1.19/format-check.py --- old/aws-c-sdkutils-0.1.16/format-check.py 1970-01-01 01:00:00.000000000 +0100 +++ new/aws-c-sdkutils-0.1.19/format-check.py 2024-08-03 00:36:14.000000000 +0200 @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +import argparse +import os +from pathlib import Path +import re +from subprocess import list2cmdline, run +from tempfile import NamedTemporaryFile + +CLANG_FORMAT_VERSION = '18.1.6' + +INCLUDE_REGEX = re.compile( + r'^(include|source|tests|verification)/.*\.(c|h|inl)$') +EXCLUDE_REGEX = re.compile(r'^$') + +arg_parser = argparse.ArgumentParser(description="Check with clang-format") +arg_parser.add_argument('-i', '--inplace-edit', action='store_true', + help="Edit files inplace") +args = arg_parser.parse_args() + +os.chdir(Path(__file__).parent) + +# create file containing list of all files to format +filepaths_file = NamedTemporaryFile(delete=False) +for dirpath, dirnames, filenames in os.walk('.'): + for filename in filenames: + # our regexes expect filepath to use forward slash + filepath = Path(dirpath, filename).as_posix() + if not INCLUDE_REGEX.match(filepath): + continue + if EXCLUDE_REGEX.match(filepath): + continue + + filepaths_file.write(f"{filepath}\n".encode()) +filepaths_file.close() + +# use pipx to run clang-format from PyPI +# this is a simple way to run the same clang-format version regardless of OS +cmd = ['pipx', 'run', f'clang-format=={CLANG_FORMAT_VERSION}', + f'--files={filepaths_file.name}'] +if args.inplace_edit: + cmd += ['-i'] +else: + cmd += ['--Werror', '--dry-run'] + +print(f"{Path.cwd()}$ {list2cmdline(cmd)}") +if run(cmd).returncode: + exit(1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/format-check.sh new/aws-c-sdkutils-0.1.19/format-check.sh --- old/aws-c-sdkutils-0.1.16/format-check.sh 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/format-check.sh 1970-01-01 01:00:00.000000000 +0100 @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z $CLANG_FORMAT ]] ; then - CLANG_FORMAT=clang-format -fi - -if NOT type $CLANG_FORMAT 2> /dev/null ; then - echo "No appropriate clang-format found." - exit 1 -fi - -FAIL=0 -SOURCE_FILES=`find source include tests -type f \( -name '*.h' -o -name '*.c' \)` -for i in $SOURCE_FILES -do - $CLANG_FORMAT -output-replacements-xml $i | grep -c "<replacement " > /dev/null - if [ $? -ne 1 ] - then - echo "$i failed clang-format check." - FAIL=1 - fi -done - -exit $FAIL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/include/aws/sdkutils/endpoints_rule_engine.h new/aws-c-sdkutils-0.1.19/include/aws/sdkutils/endpoints_rule_engine.h --- old/aws-c-sdkutils-0.1.16/include/aws/sdkutils/endpoints_rule_engine.h 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/include/aws/sdkutils/endpoints_rule_engine.h 2024-08-03 00:36:14.000000000 +0200 @@ -19,7 +19,11 @@ struct aws_endpoints_request_context; struct aws_hash_table; -enum aws_endpoints_parameter_type { AWS_ENDPOINTS_PARAMETER_STRING, AWS_ENDPOINTS_PARAMETER_BOOLEAN }; +enum aws_endpoints_parameter_type { + AWS_ENDPOINTS_PARAMETER_STRING, + AWS_ENDPOINTS_PARAMETER_BOOLEAN, + AWS_ENDPOINTS_PARAMETER_STRING_ARRAY, +}; enum aws_endpoints_resolved_endpoint_type { AWS_ENDPOINTS_RESOLVED_ENDPOINT, AWS_ENDPOINTS_RESOLVED_ERROR }; AWS_EXTERN_C_BEGIN @@ -221,7 +225,6 @@ /* * Add boolean value to request context. - * Note: this function will make a copy of the memory backing the cursors. * The function will override any previous value stored in the context with the * same name. */ @@ -232,6 +235,19 @@ bool value); /* + * Add string array value to request context. + * Note: this function will make a copy of the memory backing the cursors. + * The function will override any previous value stored in the context with the + * same name. + */ +AWS_SDKUTILS_API int aws_endpoints_request_context_add_string_array( + struct aws_allocator *allocator, + struct aws_endpoints_request_context *context, + struct aws_byte_cursor name, + const struct aws_byte_cursor *value_array, + size_t len); + +/* * Resolve an endpoint given request context. * Resolved endpoint is returned through out_resolved_endpoint. * In cases of error out_resolved_endpoint is set to NULL and error is returned. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/include/aws/sdkutils/private/endpoints_types_impl.h new/aws-c-sdkutils-0.1.19/include/aws/sdkutils/private/endpoints_types_impl.h --- old/aws-c-sdkutils-0.1.16/include/aws/sdkutils/private/endpoints_types_impl.h 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/include/aws/sdkutils/private/endpoints_types_impl.h 2024-08-03 00:36:14.000000000 +0200 @@ -71,6 +71,35 @@ AWS_ENDPOINTS_FN_LAST, }; +enum aws_endpoints_value_type { + /* Special value to represent that any value type is expected from resolving an expresion. + Not a valid value for a value type. */ + AWS_ENDPOINTS_VALUE_ANY, + + AWS_ENDPOINTS_VALUE_NONE, + AWS_ENDPOINTS_VALUE_STRING, + AWS_ENDPOINTS_VALUE_BOOLEAN, + AWS_ENDPOINTS_VALUE_OBJECT, /* Generic type returned by some functions. json string under the covers. */ + AWS_ENDPOINTS_VALUE_NUMBER, + AWS_ENDPOINTS_VALUE_ARRAY, + + AWS_ENDPOINTS_VALUE_SIZE +}; + +/* concrete type value */ +struct aws_endpoints_value { + enum aws_endpoints_value_type type; + union { + struct aws_owning_cursor owning_cursor_string; + bool boolean; + struct aws_owning_cursor owning_cursor_object; + double number; + struct aws_array_list array; + } v; + /* Value is a reference to another value, no need to clean it up. */ + bool is_ref; +}; + struct aws_endpoints_parameter { struct aws_allocator *allocator; @@ -80,10 +109,7 @@ struct aws_byte_cursor built_in; bool has_default_value; - union { - struct aws_byte_cursor string; - bool boolean; - } default_value; + struct aws_endpoints_value default_value; bool is_required; struct aws_byte_cursor documentation; @@ -210,21 +236,6 @@ ****************************** */ -enum aws_endpoints_value_type { - /* Special value to represent that any value type is expected from resolving an expresion. - Note a valid value for a value type. */ - AWS_ENDPOINTS_VALUE_ANY, - - AWS_ENDPOINTS_VALUE_NONE, - AWS_ENDPOINTS_VALUE_STRING, - AWS_ENDPOINTS_VALUE_BOOLEAN, - AWS_ENDPOINTS_VALUE_OBJECT, /* Generic type returned by some functions. json string under the covers. */ - AWS_ENDPOINTS_VALUE_NUMBER, - AWS_ENDPOINTS_VALUE_ARRAY, - - AWS_ENDPOINTS_VALUE_SIZE -}; - struct aws_endpoints_request_context { struct aws_allocator *allocator; struct aws_ref_count ref_count; @@ -232,18 +243,6 @@ struct aws_hash_table values; }; -/* concrete type value */ -struct aws_endpoints_value { - enum aws_endpoints_value_type type; - union { - struct aws_owning_cursor owning_cursor_string; - bool boolean; - struct aws_owning_cursor owning_cursor_object; - double number; - struct aws_array_list array; - } v; -}; - /* wrapper around aws_endpoints_value to store it more easily in hash table*/ struct aws_endpoints_scope_value { struct aws_allocator *allocator; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/source/endpoints_rule_engine.c new/aws-c-sdkutils-0.1.19/source/endpoints_rule_engine.c --- old/aws-c-sdkutils-0.1.16/source/endpoints_rule_engine.c 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/source/endpoints_rule_engine.c 2024-08-03 00:36:14.000000000 +0200 @@ -186,13 +186,10 @@ switch (value->type) { case AWS_ENDPOINTS_PARAMETER_STRING: - val->value.type = AWS_ENDPOINTS_VALUE_STRING; - val->value.v.owning_cursor_string = - aws_endpoints_non_owning_cursor_create(value->default_value.string); - break; case AWS_ENDPOINTS_PARAMETER_BOOLEAN: - val->value.type = AWS_ENDPOINTS_VALUE_BOOLEAN; - val->value.v.boolean = value->default_value.boolean; + case AWS_ENDPOINTS_PARAMETER_STRING_ARRAY: + val->value = value->default_value; + val->value.is_ref = true; break; default: AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Unexpected parameter type."); @@ -310,8 +307,21 @@ } case AWS_ENDPOINTS_EXPR_ARRAY: { out_value->type = AWS_ENDPOINTS_VALUE_ARRAY; - /* TODO: deep copy */ - out_value->v.array = expr->e.array; + { + size_t len = aws_array_list_length(&expr->e.array); + aws_array_list_init_dynamic(&out_value->v.array, allocator, len, sizeof(struct aws_endpoints_value)); + for (size_t i = 0; i < len; ++i) { + struct aws_endpoints_expr expr_elem; + aws_array_list_get_at(&expr->e.array, &expr_elem, i); + struct aws_endpoints_value val; + if (s_resolve_expr(allocator, &expr_elem, scope, &val)) { + AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Failed to resolve array element."); + aws_endpoints_value_clean_up(out_value); + goto on_error; + } + aws_array_list_set_at(&out_value->v.array, &val, i); + } + } break; } case AWS_ENDPOINTS_EXPR_REFERENCE: { @@ -325,14 +335,9 @@ out_value->type = AWS_ENDPOINTS_VALUE_NONE; } else { struct aws_endpoints_scope_value *aws_endpoints_scope_value = element->value; + *out_value = aws_endpoints_scope_value->value; - if (aws_endpoints_scope_value->value.type == AWS_ENDPOINTS_VALUE_STRING) { - /* Value will not own underlying mem and instead its owned - by the scope, so set it to NULL. */ - out_value->v.owning_cursor_string.string = NULL; - } else if (aws_endpoints_scope_value->value.type == AWS_ENDPOINTS_VALUE_OBJECT) { - out_value->v.owning_cursor_object.string = NULL; - } + out_value->is_ref = true; } break; } @@ -450,6 +455,8 @@ struct aws_endpoints_value *value, struct aws_byte_cursor path_cur, struct aws_endpoints_value *out_value) { + (void)allocator; + (void)scope; AWS_PRECONDITION(value->type == AWS_ENDPOINTS_VALUE_ARRAY); @@ -461,25 +468,20 @@ goto on_error; } - if (index < aws_array_list_length(&value->v.array)) { + if (index >= aws_array_list_length(&value->v.array)) { out_value->type = AWS_ENDPOINTS_VALUE_NONE; return AWS_OP_SUCCESS; } - struct aws_endpoints_expr *expr = NULL; - if (aws_array_list_get_at_ptr(&value->v.array, (void **)&expr, (size_t)index)) { + struct aws_endpoints_value *val = NULL; + if (aws_array_list_get_at_ptr(&value->v.array, (void **)&val, (size_t)index)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Failed to index into resolved value"); goto on_error; } - struct aws_endpoints_value val; - if (s_resolve_expr(allocator, expr, scope, &val)) { - AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Failed to resolve val."); - aws_endpoints_value_clean_up(&val); - goto on_error; - } + *out_value = *val; + out_value->is_ref = true; - *out_value = val; return AWS_OP_SUCCESS; on_error: @@ -597,7 +599,10 @@ goto on_error; } } else { - AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Invalid value type for pathing through."); + AWS_LOGF_ERROR( + AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, + "Invalid value type for pathing through. type %d", + scope_value->value.type); goto on_error; } @@ -737,6 +742,34 @@ return AWS_OP_SUCCESS; } +int aws_endpoints_request_context_add_string_array( + struct aws_allocator *allocator, + struct aws_endpoints_request_context *context, + struct aws_byte_cursor name, + const struct aws_byte_cursor *values, + size_t len) { + + struct aws_endpoints_scope_value *val = aws_endpoints_scope_value_new(allocator, name); + val->value.type = AWS_ENDPOINTS_VALUE_ARRAY; + aws_array_list_init_dynamic(&val->value.v.array, allocator, len, sizeof(struct aws_endpoints_value)); + + for (size_t i = 0; i < len; ++i) { + struct aws_endpoints_value elem = { + .is_ref = false, + .type = AWS_ENDPOINTS_VALUE_STRING, + .v.owning_cursor_object = aws_endpoints_owning_cursor_from_cursor(allocator, values[i])}; + + aws_array_list_set_at(&val->value.v.array, &elem, i); + } + + if (aws_hash_table_put(&context->values, &val->name.cur, val, NULL)) { + aws_endpoints_scope_value_destroy(val); + return aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_INIT_FAILED); + }; + + return AWS_OP_SUCCESS; +} + /* ****************************** * Rule engine. @@ -1126,7 +1159,6 @@ result = aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_RULESET_EXHAUSTED); on_done: - AWS_LOGF_DEBUG(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Resolved endpoint with status %d", result); s_scope_clean_up(&scope); return result; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/source/endpoints_ruleset.c new/aws-c-sdkutils-0.1.19/source/endpoints_ruleset.c --- old/aws-c-sdkutils-0.1.16/source/endpoints_ruleset.c 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/source/endpoints_ruleset.c 2024-08-03 00:36:14.000000000 +0200 @@ -14,6 +14,7 @@ /* parameter types */ static struct aws_byte_cursor s_string_type_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("string"); static struct aws_byte_cursor s_boolean_type_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("boolean"); +static struct aws_byte_cursor s_string_array_type_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("stringArray"); /* rule types */ static struct aws_byte_cursor s_endpoint_type_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("endpoint"); @@ -52,7 +53,7 @@ AWS_PRECONDITION(out_cursor); if (parameter->type == AWS_ENDPOINTS_PARAMETER_STRING) { - *out_cursor = parameter->default_value.string; + *out_cursor = parameter->default_value.v.owning_cursor_string.cur; return AWS_OP_SUCCESS; }; @@ -67,7 +68,7 @@ AWS_PRECONDITION(out_bool); if (parameter->type == AWS_ENDPOINTS_PARAMETER_BOOLEAN) { - *out_bool = ¶meter->default_value.boolean; + *out_bool = ¶meter->default_value.v.boolean; return AWS_OP_SUCCESS; }; @@ -225,7 +226,7 @@ AWS_ZERO_STRUCT(*out_reference); - struct aws_json_value *ref_node = aws_json_value_get_from_object(node, aws_byte_cursor_from_c_str("ref")); + struct aws_json_value *ref_node = aws_json_value_get_from_object_c_str(node, "ref"); if (ref_node != NULL && aws_json_value_get_string(ref_node, out_reference)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to parse ref."); AWS_ZERO_STRUCT(*out_reference); @@ -328,7 +329,7 @@ AWS_ZERO_STRUCT(*function); - struct aws_json_value *fn_node = aws_json_value_get_from_object(node, aws_byte_cursor_from_c_str("fn")); + struct aws_json_value *fn_node = aws_json_value_get_from_object_c_str(node, "fn"); if (fn_node == NULL) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Node is not a function."); goto on_error; @@ -357,7 +358,7 @@ goto on_error; } - struct aws_json_value *argv_node = aws_json_value_get_from_object(node, aws_byte_cursor_from_c_str("argv")); + struct aws_json_value *argv_node = aws_json_value_get_from_object_c_str(node, "argv"); if (argv_node == NULL || !aws_json_value_is_array(argv_node)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "No argv or unexpected type."); goto on_error; @@ -394,7 +395,7 @@ /* required fields */ struct aws_byte_cursor type_cur; - struct aws_json_value *type_node = aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("type")); + struct aws_json_value *type_node = aws_json_value_get_from_object_c_str(value, "type"); if (type_node == NULL || aws_json_value_get_string(type_node, &type_cur)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract parameter type."); goto on_error; @@ -405,6 +406,8 @@ type = AWS_ENDPOINTS_PARAMETER_STRING; } else if (aws_byte_cursor_eq_ignore_case(&type_cur, &s_boolean_type_cur)) { type = AWS_ENDPOINTS_PARAMETER_BOOLEAN; + } else if (aws_byte_cursor_eq_ignore_case(&type_cur, &s_string_array_type_cur)) { + type = AWS_ENDPOINTS_PARAMETER_STRING_ARRAY; } else { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for parameter."); goto on_error; @@ -412,8 +415,7 @@ parameter->type = type; - struct aws_json_value *documentation_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("documentation")); + struct aws_json_value *documentation_node = aws_json_value_get_from_object_c_str(value, "documentation"); /* TODO: spec calls for documentation to be required, but several test-cases are missing docs on parameters */ @@ -425,7 +427,7 @@ } /* optional fields */ - struct aws_json_value *built_in_node = aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("builtIn")); + struct aws_json_value *built_in_node = aws_json_value_get_from_object_c_str(value, "builtIn"); if (built_in_node != NULL) { if (aws_json_value_get_string(built_in_node, ¶meter->built_in)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for built-in parameter field."); @@ -433,8 +435,7 @@ } } - struct aws_json_value *required_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("required")); + struct aws_json_value *required_node = aws_json_value_get_from_object_c_str(value, "required"); if (required_node != NULL) { if (!aws_json_value_is_boolean(required_node)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for required parameter field."); @@ -443,34 +444,59 @@ aws_json_value_get_boolean(required_node, ¶meter->is_required); } - struct aws_json_value *default_node = aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("default")); + struct aws_json_value *default_node = aws_json_value_get_from_object_c_str(value, "default"); parameter->has_default_value = default_node != NULL; if (default_node != NULL) { - if (type == AWS_ENDPOINTS_PARAMETER_STRING && - aws_json_value_get_string(default_node, ¶meter->default_value.string)) { - AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for default parameter value."); - goto on_error; - } else if ( - type == AWS_ENDPOINTS_PARAMETER_BOOLEAN && - aws_json_value_get_boolean(default_node, ¶meter->default_value.boolean)) { + if (type == AWS_ENDPOINTS_PARAMETER_STRING && aws_json_value_is_string(default_node)) { + struct aws_byte_cursor cur; + aws_json_value_get_string(default_node, &cur); + parameter->default_value.type = AWS_ENDPOINTS_VALUE_STRING; + parameter->default_value.v.owning_cursor_string = aws_endpoints_non_owning_cursor_create(cur); + } else if (type == AWS_ENDPOINTS_PARAMETER_BOOLEAN && aws_json_value_is_boolean(default_node)) { + parameter->default_value.type = AWS_ENDPOINTS_VALUE_BOOLEAN; + aws_json_value_get_boolean(default_node, ¶meter->default_value.v.boolean); + } else if (type == AWS_ENDPOINTS_PARAMETER_STRING_ARRAY && aws_json_value_is_array(default_node)) { + parameter->default_value.type = AWS_ENDPOINTS_VALUE_ARRAY; + size_t len = aws_json_get_array_size(default_node); + aws_array_list_init_dynamic( + ¶meter->default_value.v.array, wrapper->allocator, len, sizeof(struct aws_endpoints_value)); + for (size_t i = 0; i < len; ++i) { + struct aws_json_value *element = aws_json_get_array_element(default_node, i); + if (!aws_json_value_is_string(element)) { + AWS_LOGF_ERROR( + AWS_LS_SDKUTILS_ENDPOINTS_PARSING, + "Unexpected type for default parameter value. String array parameter must have string " + "elements"); + goto on_error; + } + + struct aws_byte_cursor cur; + aws_json_value_get_string(element, &cur); + + struct aws_endpoints_value val = { + .is_ref = false, + .type = AWS_ENDPOINTS_VALUE_STRING, + .v.owning_cursor_string = aws_endpoints_non_owning_cursor_create(cur)}; + + aws_array_list_set_at(¶meter->default_value.v.array, &val, i); + } + } else { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for default parameter value."); goto on_error; } } - struct aws_json_value *deprecated_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("deprecated")); + struct aws_json_value *deprecated_node = aws_json_value_get_from_object_c_str(value, "deprecated"); if (deprecated_node != NULL) { struct aws_json_value *deprecated_message_node = - aws_json_value_get_from_object(deprecated_node, aws_byte_cursor_from_c_str("message")); + aws_json_value_get_from_object_c_str(deprecated_node, "message"); if (deprecated_message_node != NULL && aws_json_value_get_string(deprecated_message_node, ¶meter->deprecated_message)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected value for deprecated message."); goto on_error; } - struct aws_json_value *deprecated_since_node = - aws_json_value_get_from_object(deprecated_node, aws_byte_cursor_from_c_str("since")); + struct aws_json_value *deprecated_since_node = aws_json_value_get_from_object_c_str(deprecated_node, "since"); if (deprecated_since_node != NULL && aws_json_value_get_string(deprecated_since_node, ¶meter->deprecated_since)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected value for deprecated since."); @@ -510,8 +536,7 @@ goto on_error; } - struct aws_json_value *assign_node = - aws_json_value_get_from_object(condition_node, aws_byte_cursor_from_c_str("assign")); + struct aws_json_value *assign_node = aws_json_value_get_from_object_c_str(condition_node, "assign"); if (assign_node != NULL && aws_json_value_get_string(assign_node, &condition.assign)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected value for assign."); goto on_error; @@ -589,7 +614,7 @@ AWS_PRECONDITION(data_rule); data_rule->allocator = allocator; - struct aws_json_value *url_node = aws_json_value_get_from_object(rule_node, aws_byte_cursor_from_c_str("url")); + struct aws_json_value *url_node = aws_json_value_get_from_object_c_str(rule_node, "url"); if (url_node == NULL || aws_json_value_is_string(url_node)) { data_rule->url.type = AWS_ENDPOINTS_EXPR_STRING; aws_json_value_get_string(url_node, &data_rule->url.e.string); @@ -612,8 +637,7 @@ } } - struct aws_json_value *properties_node = - aws_json_value_get_from_object(rule_node, aws_byte_cursor_from_c_str("properties")); + struct aws_json_value *properties_node = aws_json_value_get_from_object_c_str(rule_node, "properties"); if (properties_node != NULL) { aws_byte_buf_init(&data_rule->properties, allocator, 0); @@ -638,12 +662,11 @@ aws_hash_callback_string_destroy, s_callback_headers_destroy); - struct aws_json_value *headers_node = - aws_json_value_get_from_object(rule_node, aws_byte_cursor_from_c_str("headers")); + struct aws_json_value *headers_node = aws_json_value_get_from_object_c_str(rule_node, "headers"); if (headers_node != NULL) { if (s_init_members_from_json(allocator, headers_node, &data_rule->headers, s_on_headers_key)) { - AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract parameters."); + AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract headers."); goto on_error; } } @@ -708,7 +731,7 @@ AWS_PRECONDITION(rule_node); AWS_PRECONDITION(rule_data); - struct aws_json_value *rules_node = aws_json_value_get_from_object(rule_node, aws_byte_cursor_from_c_str("rules")); + struct aws_json_value *rules_node = aws_json_value_get_from_object_c_str(rule_node, "rules"); if (rules_node == NULL || !aws_json_value_is_array(rules_node)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Rules node is missing or unexpected type."); return aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_PARSE_FAILED); @@ -739,7 +762,7 @@ /* Required fields */ struct aws_byte_cursor type_cur; - struct aws_json_value *type_node = aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("type")); + struct aws_json_value *type_node = aws_json_value_get_from_object_c_str(value, "type"); if (type_node == NULL || aws_json_value_get_string(type_node, &type_cur)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract rule type."); return aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_PARSE_FAILED); @@ -761,8 +784,7 @@ AWS_ZERO_STRUCT(rule); rule.type = type; - struct aws_json_value *conditions_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("conditions")); + struct aws_json_value *conditions_node = aws_json_value_get_from_object_c_str(value, "conditions"); if (conditions_node == NULL || !aws_json_value_is_array(conditions_node)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Conditions node missing."); goto on_error; @@ -779,8 +801,7 @@ switch (type) { case AWS_ENDPOINTS_RULE_ENDPOINT: { - struct aws_json_value *endpoint_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("endpoint")); + struct aws_json_value *endpoint_node = aws_json_value_get_from_object_c_str(value, "endpoint"); if (endpoint_node == NULL || s_parse_endpoints_rule_data_endpoint(wrapper->allocator, endpoint_node, &rule.rule_data.endpoint)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract endpoint rule data."); @@ -789,8 +810,7 @@ break; } case AWS_ENDPOINTS_RULE_ERROR: { - struct aws_json_value *error_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("error")); + struct aws_json_value *error_node = aws_json_value_get_from_object_c_str(value, "error"); if (error_node == NULL || s_parse_endpoints_rule_data_error(wrapper->allocator, error_node, &rule.rule_data.error)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract error rule data."); @@ -810,8 +830,7 @@ } /* Optional fields */ - struct aws_json_value *documentation_node = - aws_json_value_get_from_object(value, aws_byte_cursor_from_c_str("documentation")); + struct aws_json_value *documentation_node = aws_json_value_get_from_object_c_str(value, "documentation"); if (documentation_node != NULL) { if (aws_json_value_get_string(documentation_node, &rule.documentation)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract parameter documentation."); @@ -845,7 +864,7 @@ ruleset->json_root = root; - struct aws_json_value *version_node = aws_json_value_get_from_object(root, aws_byte_cursor_from_c_str("version")); + struct aws_json_value *version_node = aws_json_value_get_from_object_c_str(root, "version"); if (version_node == NULL || aws_json_value_get_string(version_node, &ruleset->version)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract version."); aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_RULESET); @@ -860,8 +879,7 @@ } #endif - struct aws_json_value *service_id_node = - aws_json_value_get_from_object(root, aws_byte_cursor_from_c_str("serviceId")); + struct aws_json_value *service_id_node = aws_json_value_get_from_object_c_str(root, "serviceId"); if (service_id_node != NULL && aws_json_value_get_string(service_id_node, &ruleset->service_id)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract serviceId."); @@ -878,8 +896,7 @@ NULL, s_callback_endpoints_parameter_destroy); - struct aws_json_value *parameters_node = - aws_json_value_get_from_object(root, aws_byte_cursor_from_c_str("parameters")); + struct aws_json_value *parameters_node = aws_json_value_get_from_object_c_str(root, "parameters"); if (parameters_node == NULL || s_init_members_from_json(allocator, parameters_node, &ruleset->parameters, s_on_parameter_key)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Failed to extract parameters."); @@ -887,7 +904,7 @@ goto on_error; } - struct aws_json_value *rules_node = aws_json_value_get_from_object(root, aws_byte_cursor_from_c_str("rules")); + struct aws_json_value *rules_node = aws_json_value_get_from_object_c_str(root, "rules"); if (rules_node == NULL || !aws_json_value_is_array(rules_node)) { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_PARSING, "Unexpected type for rules node."); aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_PARSE_FAILED); @@ -914,12 +931,12 @@ struct aws_endpoints_ruleset *ruleset = data; - aws_json_value_destroy(ruleset->json_root); - aws_hash_table_clean_up(&ruleset->parameters); aws_array_list_deep_clean_up(&ruleset->rules, s_on_rule_array_element_clean_up); + aws_json_value_destroy(ruleset->json_root); + aws_mem_release(ruleset->allocator, ruleset); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/source/endpoints_standard_lib.c new/aws-c-sdkutils-0.1.19/source/endpoints_standard_lib.c --- old/aws-c-sdkutils-0.1.16/source/endpoints_standard_lib.c 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/source/endpoints_standard_lib.c 2024-08-03 00:36:14.000000000 +0200 @@ -94,7 +94,8 @@ goto on_done; } } else { - AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Invalid value type for pathing through."); + AWS_LOGF_ERROR( + AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Invalid value type for pathing through. type: %d", argv_value.type); result = aws_raise_error(AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_FAILED); goto on_done; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/source/endpoints_types_impl.c new/aws-c-sdkutils-0.1.19/source/endpoints_types_impl.c --- old/aws-c-sdkutils-0.1.16/source/endpoints_types_impl.c 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/source/endpoints_types_impl.c 2024-08-03 00:36:14.000000000 +0200 @@ -11,6 +11,8 @@ #include <aws/sdkutils/private/endpoints_types_impl.h> #include <aws/sdkutils/private/endpoints_util.h> +void s_endpoints_value_clean_up_cb(void *value); + uint64_t aws_endpoints_fn_name_hash[AWS_ENDPOINTS_FN_LAST]; void aws_endpoints_rule_engine_init(void) { @@ -85,6 +87,10 @@ return; } + if (parameter->has_default_value && parameter->type == AWS_ENDPOINTS_PARAMETER_STRING_ARRAY) { + aws_array_list_deep_clean_up(¶meter->default_value.v.array, s_endpoints_value_clean_up_cb); + } + aws_mem_release(parameter->allocator, parameter); } @@ -189,6 +195,7 @@ return; } aws_string_destroy(scope_value->name.string); + aws_endpoints_value_clean_up(&scope_value->value); aws_mem_release(scope_value->allocator, scope_value); } @@ -198,6 +205,10 @@ void aws_endpoints_value_clean_up(struct aws_endpoints_value *aws_endpoints_value) { AWS_PRECONDITION(aws_endpoints_value); + if (aws_endpoints_value->is_ref) { + goto on_done; + } + if (aws_endpoints_value->type == AWS_ENDPOINTS_VALUE_STRING) { aws_string_destroy(aws_endpoints_value->v.owning_cursor_string.string); } @@ -207,13 +218,14 @@ } if (aws_endpoints_value->type == AWS_ENDPOINTS_VALUE_ARRAY) { - aws_array_list_deep_clean_up(&aws_endpoints_value->v.array, aws_endpoints_value_clean_up_cb); + aws_array_list_deep_clean_up(&aws_endpoints_value->v.array, s_endpoints_value_clean_up_cb); } +on_done: AWS_ZERO_STRUCT(*aws_endpoints_value); } -void aws_endpoints_value_clean_up_cb(void *value) { +void s_endpoints_value_clean_up_cb(void *value) { struct aws_endpoints_value *aws_endpoints_value = value; aws_endpoints_value_clean_up(aws_endpoints_value); } @@ -224,15 +236,35 @@ struct aws_endpoints_value *to) { to->type = from->type; + to->is_ref = false; if (to->type == AWS_ENDPOINTS_VALUE_STRING) { - to->v.owning_cursor_string = aws_endpoints_owning_cursor_create(allocator, from->v.owning_cursor_string.string); + to->v.owning_cursor_string = + aws_endpoints_owning_cursor_from_cursor(allocator, from->v.owning_cursor_string.cur); } else if (to->type == AWS_ENDPOINTS_VALUE_BOOLEAN) { to->v.boolean = from->v.boolean; + } else if (to->type == AWS_ENDPOINTS_VALUE_ARRAY) { + size_t len = aws_array_list_length(&from->v.array); + aws_array_list_init_dynamic(&to->v.array, allocator, len, sizeof(struct aws_endpoints_value)); + for (size_t i = 0; i < len; ++i) { + struct aws_endpoints_value val; + aws_array_list_get_at(&from->v.array, &val, i); + + struct aws_endpoints_value to_val; + if (aws_endpoints_deep_copy_parameter_value(allocator, &val, &to_val)) { + AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Unexpected array element type."); + goto on_error; + } + + aws_array_list_set_at(&to->v.array, &to_val, i); + } } else { AWS_LOGF_ERROR(AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, "Unexpected value type."); return aws_raise_error(AWS_ERROR_INVALID_STATE); } - return AWS_OP_SUCCESS; + +on_error: + aws_endpoints_value_clean_up(to); + return AWS_OP_ERR; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/tests/CMakeLists.txt new/aws-c-sdkutils-0.1.19/tests/CMakeLists.txt --- old/aws-c-sdkutils-0.1.16/tests/CMakeLists.txt 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/tests/CMakeLists.txt 2024-08-03 00:36:14.000000000 +0200 @@ -87,6 +87,7 @@ add_test_case(test_endpoints_valid_hostlabel) add_test_case(test_endpoints_condition_mem_clean_up) add_test_case(test_endpoints_custom) +add_test_case(test_endpoints_string_array) add_test_case(endpoints_uri_normalize_path) add_test_case(endpoints_byte_buf_init_from_resolved_templated_string) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/tests/endpoints_rule_engine_tests.c new/aws-c-sdkutils-0.1.19/tests/endpoints_rule_engine_tests.c --- old/aws-c-sdkutils-0.1.16/tests/endpoints_rule_engine_tests.c 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/tests/endpoints_rule_engine_tests.c 2024-08-03 00:36:14.000000000 +0200 @@ -114,6 +114,11 @@ struct aws_endpoints_request_context *context; }; +enum { + /* something is really wrong if there is more than 4 elems during the test */ + MAX_STRING_ARRAY_ELEMENTS = 4 +}; + static int s_on_parameter_key( const struct aws_byte_cursor *key, const struct aws_json_value *value, @@ -125,23 +130,27 @@ if (aws_json_value_is_string(value)) { struct aws_byte_cursor cur; - if (aws_json_value_get_string(value, &cur) || - aws_endpoints_request_context_add_string(wrapper->allocator, wrapper->context, *key, cur)) { - goto on_error; - } + ASSERT_SUCCESS(aws_json_value_get_string(value, &cur)); + ASSERT_SUCCESS(aws_endpoints_request_context_add_string(wrapper->allocator, wrapper->context, *key, cur)); return AWS_OP_SUCCESS; } else if (aws_json_value_is_boolean(value)) { bool b; - if (aws_json_value_get_boolean(value, &b) || - aws_endpoints_request_context_add_boolean(wrapper->allocator, wrapper->context, *key, b)) { - goto on_error; + ASSERT_SUCCESS(aws_json_value_get_boolean(value, &b)); + ASSERT_SUCCESS(aws_endpoints_request_context_add_boolean(wrapper->allocator, wrapper->context, *key, b)); + return AWS_OP_SUCCESS; + } else if (aws_json_value_is_array(value)) { + struct aws_byte_cursor strings[MAX_STRING_ARRAY_ELEMENTS]; + size_t len = aws_json_get_array_size(value); + ASSERT_TRUE(len <= MAX_STRING_ARRAY_ELEMENTS); + for (size_t i = 0; i < len; ++i) { + struct aws_json_value *str = aws_json_get_array_element(value, i); + ASSERT_SUCCESS(aws_json_value_get_string(str, &strings[i])); } + ASSERT_SUCCESS( + aws_endpoints_request_context_add_string_array(wrapper->allocator, wrapper->context, *key, strings, len)); return AWS_OP_SUCCESS; - } else { - goto on_error; } -on_error: return AWS_OP_ERR; } @@ -274,7 +283,6 @@ aws_json_value_get_from_object(endpoint, aws_byte_cursor_from_c_str("url")); struct aws_byte_cursor expected_url; aws_json_value_get_string(expected_url_node, &expected_url); - AWS_LOGF_DEBUG(0, PRInSTR " " PRInSTR, AWS_BYTE_CURSOR_PRI(url), AWS_BYTE_CURSOR_PRI(expected_url)); ASSERT_TRUE(aws_byte_cursor_eq(&url, &expected_url)); struct aws_byte_cursor properties; @@ -485,3 +493,12 @@ return AWS_OP_SUCCESS; } + +AWS_TEST_CASE(test_endpoints_string_array, s_test_endpoints_string_array) +static int s_test_endpoints_string_array(struct aws_allocator *allocator, void *ctx) { + (void)ctx; + + ASSERT_SUCCESS(eval_expected(allocator, aws_byte_cursor_from_c_str("string_array.json"))); + + return AWS_OP_SUCCESS; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/tests/resources/test-cases/partition-fn.json new/aws-c-sdkutils-0.1.19/tests/resources/test-cases/partition-fn.json --- old/aws-c-sdkutils-0.1.16/tests/resources/test-cases/partition-fn.json 2024-04-22 18:32:19.000000000 +0200 +++ new/aws-c-sdkutils-0.1.19/tests/resources/test-cases/partition-fn.json 2024-08-03 00:36:14.000000000 +0200 @@ -122,4 +122,4 @@ } } ] - } \ No newline at end of file + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/tests/resources/test-cases/string_array.json new/aws-c-sdkutils-0.1.19/tests/resources/test-cases/string_array.json --- old/aws-c-sdkutils-0.1.16/tests/resources/test-cases/string_array.json 1970-01-01 01:00:00.000000000 +0100 +++ new/aws-c-sdkutils-0.1.19/tests/resources/test-cases/string_array.json 2024-08-03 00:36:14.000000000 +0200 @@ -0,0 +1,45 @@ +{ + "version": "1.0", + "testCases": [ + { + "documentation": "Default array values used", + "params": {}, + "expect": { + "endpoint": { + "url": "https://example.com/defaultValue1" + } + } + }, + { + "documentation": "Empty array", + "params": { + "stringArrayParam": [] + }, + "expect": { + "error": "no array values set" + } + }, + { + "documentation": "Static value", + "params": { + "stringArrayParam": ["staticValue1"] + }, + "expect": { + "endpoint": { + "url": "https://example.com/staticValue1" + } + } + }, + { + "documentation": "bound value from input", + "params": { + "stringArrayParam": ["key1", "key2", "key3", "key4"] + }, + "expect": { + "endpoint": { + "url": "https://example.com/key1" + } + } + } + ] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aws-c-sdkutils-0.1.16/tests/resources/valid-rules/string_array.json new/aws-c-sdkutils-0.1.19/tests/resources/valid-rules/string_array.json --- old/aws-c-sdkutils-0.1.16/tests/resources/valid-rules/string_array.json 1970-01-01 01:00:00.000000000 +0100 +++ new/aws-c-sdkutils-0.1.19/tests/resources/valid-rules/string_array.json 2024-08-03 00:36:14.000000000 +0200 @@ -0,0 +1,38 @@ +{ + "version": "1.0", + "parameters": { + "stringArrayParam": { + "type": "stringArray", + "required": true, + "default": ["defaultValue1", "defaultValue2"], + "documentation": "docs" + } + }, + "rules": [ + { + "documentation": "Template first array value into URI if set", + "conditions": [ + { + "fn": "getAttr", + "argv": [ + { + "ref": "stringArrayParam" + }, + "[0]" + ], + "assign": "arrayValue" + } + ], + "endpoint": { + "url": "https://example.com/{arrayValue}" + }, + "type": "endpoint" + }, + { + "conditions": [], + "documentation": "error fallthrough", + "error": "no array values set", + "type": "error" + } + ] +}
participants (1)
-
Source-Sync