Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • slapos slapos
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Merge requests 122
    • Merge requests 122
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slaposslapos
  • Merge requests
  • !152

Closed
Created Apr 06, 2017 by Boxiang Sun@DaetalusDeveloper
  • Report abuse
Report abuse

Fix the 'configuration._' not defined error when not provide '_' parameter.

  • Overview 0
  • Commits 1
  • Changes 2

There will be an error when we don't provide _ in webrunner. The instance-parameter:configuration is something like '''!py!{'full_address_list': [], '_': '{}'}'''

This commit process it by these steps:

  1. Remove the !py prefix by str[4:].
  2. Use double quotes replace single quotes within the str.
  3. Get the dict {'full_address_list': [], '_': '{}'}
  4. Get the value of the '_' key, in this case, it is a string "{}". Use json to convert it to a dict {}.

Notes:

  • Use eval or ast.literal_eval can do it in 1 or 2 steps. But it is unsafe and can not process json string which contains true, false, etc.
  • The test suite was passed in here with this commit: https://lab.nexedi.com/Daetalus/slapos/commit/6e15fa38f6164b91af23a2a1fd3c7ab5e9118e31 . The commit includes in here contains some formatting.

Please let me know if there has trouble to hardcode the str[4:] or there has corner case that I didn't cover.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: jstestnode
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7