cfengine / design-center

CFEngine community-contributed content
http://cfengine.com/
Other
80 stars 68 forks source link

Issue with single quote (') params with dcapis #446

Open keyurkapasi opened 10 years ago

keyurkapasi commented 10 years ago

Facing issue with parameters having single quote using dcapi codes. It ignore single quote (') and generate runfile without the quote. following is my dcapi code

export CHECKOUT=/root/design-center/tools/cf-sketch export DCJV=$CHECKOUT/config-vagrant.json export CFAPI=$CHECKOUT/cf-dc-api.pl

echo '{ dc_api_version: "3.6.0", request: {define: { "vagrant::System::sysconfig::sysconfig_deb": { "System::sysconfig": { "profile_params" :[ "source /etc/bash.bashrc" ], "bashrc_params_deb" : ["export LS_OPTIONS='--color=auto'", "alias ls='ls $LS_OPTIONS'", "alias ll='ls $LS_OPTIONS -l'", "alias l='ls $LS_OPTIONS -lA'"], "locale_gen" : "en_US.UTF-8 UTF-8", "locale_LANG" : "en_US.UTF-8", "locale_LANGUAGE" : "en_US:en","keyboard_layout_debian" : "de" } } } } }' | $CFAPI $DCJV

The generated runfile and provides the params excluding (') like mentioned

"___001_System_sysconfig_sysconfig_deb_bashrc_params_deb" data => parsejson('["export LS_OPTIONS=--color=auto","alias ls=ls --color=auto","alias ll=ls --color=auto -l","alias l=ls --color=auto -lA"]');

I tried /, \ and many more options but it ignores (') however It works fine with interactive mode. while using interactive mode, it generates runfile using \ like

"__System_sysconfig_1_001_System_sysconfig_sysconfig_deb_bashrc_params_deb" data => parsejson('["export LS_OPTIONS=\'--color=auto\'","alias ls=\'ls $LS_OPTIONS\'"," alias ll=\'ls $LS_OPTIONS -l\'","alias l=\'ls $LS_OPTIONS -lA\'"]);

Anybody has any clue regarding ?

tzz commented 9 years ago

Hi, and sorry for the very late reply (it's due to circumstances beyond my control). I followed your instructions but DC doesn't have a System::sysconfig sketch, so I used System::sysctl with a single quote in the parameters.

So from this JSON:

{
    "System::sysctl":
    {
        "ensured_kv" : { "'net.ipv4.tcp_tw_reuse": 1 },
        "removed_kv" : { "net.ipv4.tcp_tw_reuse": 2 },
        "removed_vars" : [ "bad.entry" ],
        "empty_first" : false
    }
}

I got this in the runfile:

      # array 'ensured_kv' from definition parameter definition from /home/tzz/source/cfengine/design-center/tools/test/../../sketches/system/sysctl/params/example.json, activation ___001_System_sysctl_set
      "___001_System_sysctl_set_ensured_kv" data => parsejson('{"\'net.ipv4.tcp_tw_reuse":1}');

which parses all right. Can you check if this is still a problem with the latest 3.7 beta or from a DC checkout?

shreyu82 commented 8 years ago

Ok thanks, very help full