Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
slapos slapos
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 122
    • Merge requests 122
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slaposslapos
  • Merge requests
  • !46

Open
Created Feb 15, 2016 by Kirill Smelkov@kirrOwner
  • Report abuse
Report abuse

slapos/recipe/slapconfiguration: Propagate SR defaults to configuration dict

  • Overview 20
  • Commits 2
  • Changes 1

Currently in slapos / slapconfiguration-recipe we have 2 ways to access instance parameters:

configuration dict,

and

configuration.<key>

for every valid key in configuration dict.

An SR could also provide default value for a key, e.g. like helloworld SR does for name parameter:

https://lab.nexedi.com/nexedi/slapos/blob/3c552c05/software/helloworld/instance.cfg.in#L38

and if such parameter is not provided in instance parameters, the default will be used...

... Though currently it only works for configuration. way of access: if a default value was provided by SR with

configuration.key = ... 

it will be available via configuration.key, but configuration dict will not have key entry at all.

This looks non-consistent to me, so imho in addition to propagating

configuration {} -> configuration.<key>

on parameters receive, we should also propagate

configuration.<key> -> configuration {} defaults

so that at any time two pictures (configuration {} and set of configuration.) agree between each other.

NOTE The fix also works for slapconfiguration.serialised case, where we obtain parameters as { _ -> json } and json-decode them to python dict after receive.

The reason it works is that we apply defaults after parameters
decode, so e.g. the following

# in SR
configuration.name = John Doe 

# instance parameters
_ = { "aaa": "bbb" }

will result in the following `configuration` dict:

{ 'aaa': 'bbb', 'name': 'John Doe' }

/cc @vpelletier, @alain.takoudjou, @rafael, @Tyagov

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: y/slapconfiguration-defaults
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7