diff --git a/Makefile b/Makefile index e980ead..2676976 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ config.sh: configure config.mk echo $(SED_ALIAS) >> config.sh echo FUNCTION_SUFFIX=$(FUNCTION_SUFFIX) >> config.sh echo "export CLI_NAME=$(CLI_NAME)" >> config.sh + echo "export SDK_USER_AGENT=$(SDK_USER_AGENT)" >> config.sh echo "export FROM_PATH=$(FROM_PATH)" >> config.sh echo -e "debug()\n{" >> config.sh echo -e '\tif [[ "$$DEBUG_MODE" == "1" ]] ; then echo "$$@" >&2 ; fi\n}' >> config.sh diff --git a/cognac_gen.sh b/cognac_gen.sh index 8668532..68ed082 100755 --- a/cognac_gen.sh +++ b/cognac_gen.sh @@ -557,7 +557,7 @@ EOF done < function.${lang} done else - sed "s|____call_list____|${CALL_LIST}|g;s+____piped_call_list____+${PIPED_CALL_LIST}+;s/____api_version____/${API_VERSION}/g;s/____sdk_version____/${SDK_VERSION}/g;s/____cli_version____/$(cat cli-version)/g;s/____cli_name____/${CLI_NAME}/" <<< "$line" + sed "s|____call_list____|${CALL_LIST}|g;s+____piped_call_list____+${PIPED_CALL_LIST}+;s/____api_version____/${API_VERSION}/g;s/____sdk_version____/${SDK_VERSION}/g;s/____cli_version____/$(cat cli-version)/g;s/____cli_name____/${CLI_NAME}/;s/____sdk_user_agent____/$SDK_USER_AGENT/g" <<< "$line" fi done < $1 } diff --git a/configure b/configure index c1595a3..8484da3 100755 --- a/configure +++ b/configure @@ -18,6 +18,7 @@ SDK_VERSION=0xC061AC CLI_NAME=oapi-cli FUNCTION_SUFFIX=Request FROM_PATH=0 +SDK_USER_AGENT='osc-sdk' FUNCLIST_ARG='' API_SCRIPT='curl -s https://raw.githubusercontent.com/outscale/osc-api/$(API_VERSION)/outscale.yaml | yq $(YQ_ARG) > osc-api.json' DEBUG_MODE=0 @@ -32,11 +33,11 @@ for arg in $@; do --wget-json-search wget json-search.Appimage --gnu-sed-alias use gsed for sed --cli-name=Name set cli name, default: oapi-cli + --sdk-user-agent=user-agent set sdk UserAgent, default: osc-sdk --debug-mode enable debug in cognac (output on stderr) --function-suffix=suffix suffix use to find function in componants, default: Request --funclist-arg=arg arguments to pass to funclist --from-path use paths instead of componant suffix for functions generations - --cli-name=Name set cli name, default: oapi-cli --api-script=script how to generate osc-api.json --yq-go use go version of yq, that use diferents arguments --curl-path=PATH path to curl source root @@ -91,6 +92,8 @@ EOF CLI_NAME=$( echo $arg | cut -f 2 -d '=' ) elif [ "--api-script" = $( echo "$arg" | cut -d '=' -f 1) ]; then API_SCRIPT="$( echo ${!inc} | cut -f 2 -d '=' )" + elif [ "--sdk-user-agent" = $( echo "$arg" | cut -d '=' -f 1) ]; then + SDK_USER_AGENT="$( echo ${!inc} | cut -f 2 -d '=' )" elif [ "--sdk-version" = $( echo "$arg" | cut -d '=' -f 1) ]; then SDK_VERSION=$( echo $arg | cut -f 2 -d '=' ) elif [ "--curl-path" = $( echo "$arg" | cut -d '=' -f 1) ]; then @@ -142,6 +145,7 @@ if [[ "$FUNCTION_SUFFIX" != "Request" && "$FUNCTION_SUFFIX" != "" ]]; then FUNCLIST_ARG="--func-suffix $FUNCTION_SUFFIX $FUNCLIST_ARG" fi +echo SDK_USER_AGENT=$SDK_USER_AGENT >> config.mk echo FUNCLIST_ARG=$FUNCLIST_ARG >> config.mk echo DEBUG_MODE=$DEBUG_MODE >> config.mk echo FROM_PATH=$FROM_PATH >> config.mk diff --git a/lib.c b/lib.c index 50d347a..d0d23f5 100644 --- a/lib.c +++ b/lib.c @@ -506,14 +506,14 @@ int osc_init_sdk_ext(struct osc_env *e, const char *profile, unsigned int flag, *e = (struct osc_env){0}; char *ca = getenv("CURL_CA_BUNDLE"); char *endpoint; - char user_agent[sizeof "osc-sdk-c/" + OSC_SDK_VERSON_L]; + char user_agent[sizeof "____sdk_user_agent____-c/" + OSC_SDK_VERSON_L]; char *cert = getenv("OSC_X509_CLIENT_CERT"); char *sslkey = getenv("OSC_X509_CLIENT_KEY"); char *auth = getenv("OSC_AUTH_METHOD"); char *force_log = cfg_login(cfg); char *force_pass = cfg_pass(cfg); - strcpy(stpcpy(user_agent, "osc-sdk-c/"), osc_sdk_version_str()); + strcpy(stpcpy(user_agent, "____sdk_user_agent____-c/"), osc_sdk_version_str()); e->region = getenv("OSC_REGION"); e->flag = flag; e->auth_method = cfg ? cfg->auth_method : OSC_AKSK_METHOD; diff --git a/main_tpl.c b/main_tpl.c index 097e368..c66bba9 100644 --- a/main_tpl.c +++ b/main_tpl.c @@ -49,7 +49,7 @@ #define OAPI_CLI_VERSION "____cli_version____" -#define OAPI_CLI_UAGENT "____cli_name____/"OAPI_CLI_VERSION"; osc-sdk-c/" +#define OAPI_CLI_UAGENT "____cli_name____/"OAPI_CLI_VERSION"; ____sdk_user_agent____-c/" #define STRY(f, args...) \ do { \ @@ -296,7 +296,7 @@ int main(int ac, char **av) flag |= OSC_INSECURE_MODE; } else if (!strcmp("--version", av[i])) { printf("%s version: %s\n" - "osc-sdk-c version: %s\n" + "____sdk_user_agent____-c version: %s\n" "based on osc-api: %s\n", program_name, OAPI_CLI_VERSION,