diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/src/config.c b/src/config.c index d3c8a66..ec676b7 100644 --- a/src/config.c +++ b/src/config.c @@ -261,37 +261,55 @@ cb_authentication_provider(enum grecs_callback_command cmd, grecs_value_t *value, void *cb_data) { - char *s; + char *type; + char *arg = NULL; if (cmd != grecs_callback_set_value) { grecs_error(locus, 0, "Unexpected block statement"); return 1; } - if (!value || value->type != GRECS_TYPE_ARRAY || value->v.arg.c != 2) { - grecs_error(locus, 0, "expected two values"); - return 1; - } - if (value->v.arg.v[0]->type != GRECS_TYPE_STRING) { - grecs_error(&value->v.arg.v[0]->locus, 0, - "first argument not a string"); - return 1; - } - if (value->v.arg.v[1]->type != GRECS_TYPE_STRING) { - grecs_error(&value->v.arg.v[1]->locus, 0, - "second argument not a string"); + if (!value) { + grecs_error(locus, 0, "expected one to two values"); return 1; } + if (value->type == GRECS_TYPE_ARRAY) { + if (value->v.arg.c != 2) { + grecs_error(locus, 0, "expected one to two values"); + return 1; + } + if (value->v.arg.v[0]->type != GRECS_TYPE_STRING) { + grecs_error(&value->v.arg.v[0]->locus, 0, + "first argument not a string"); + return 1; + } + if (value->v.arg.v[1]->type != GRECS_TYPE_STRING) { + grecs_error(&value->v.arg.v[1]->locus, 0, + "second argument not a string"); + return 1; + } - s = value->v.arg.v[0]->v.string; + type = value->v.arg.v[0]->v.string; + arg = value->v.arg.v[1]->v.string; + } else if (value->type == GRECS_TYPE_STRING) { + type = value->v.string; + arg = NULL; + } - if (strcmp(s, "file") == 0) { + if (strcmp(type, "file") == 0) { + if (arg) { + grecs_error(locus, 0, "requered argument missing"); + return 1; + } authentication_provider = authp_file; free(access_file_name); access_file_name = grecs_strdup(value->v.arg.v[1]->v.string); - } else if (strcmp(s, "instance-store") == 0) { + } else if (strcmp(type, "instance-store") == 0) { authentication_provider = authp_instance; free(access_key); - access_key = grecs_strdup(value->v.arg.v[1]->v.string); + if (arg) + access_key = grecs_strdup(arg); + else + access_key = NULL; } else { grecs_error(&value->locus, 0, "unknown provider"); } @@ -320,6 +338,22 @@ cb_access_file(enum grecs_callback_command cmd, return 0; } +static struct grecs_keyword instance_store_kw[] = { + { "base-url", "URL", + "Base URL of the instance store", + grecs_type_string, GRECS_DFLT, &instance_store_base_url }, + { "port", "NUMBER", + "Port number", + grecs_type_ushort, GRECS_DFLT, &instance_store_port }, + { "document-path", "PATH", + "Path to the instance identity document file", + grecs_type_ushort, GRECS_DFLT, &instance_store_document_path }, + { "credentials-path", "PATH", + "Path to the instance store credentials directory", + grecs_type_ushort, GRECS_DFLT, &instance_store_credentials_path }, + { NULL } +}; + static struct grecs_keyword eclat_kw[] = { { "default-endpoint", "hostname", "Set default EC2 endpoint", @@ -370,6 +404,10 @@ static struct grecs_keyword eclat_kw[] = { { "translate", NULL, "Use ID translation by default", grecs_type_bool, GRECS_DFLT, &translation_enabled }, + { "instance-store", NULL, + "Configure instance store parameters", + grecs_type_section, GRECS_DFLT, + NULL, 0, NULL, NULL, instance_store_kw }, { NULL } }; |