kubernetes-sigs/kubespray

eliminate all instances of `default` filter in roles => var should have a default defined only once

Open

#11,822 建立於 2024年12月19日

在 GitHub 查看
 (13 留言) (0 反應) (1 負責人)HTML (4,419 fork)batch import
good first issuehelp wanted

倉庫指標

Star
 (10,380 star)
PR 合併指標
 (平均合併 25天) (30 天內合併 26 個 PR)

描述

We have lots of instances of this pattern:

"{{ some_var | d(some_default_value) }}"

Where the same value is repeated multiples places in the code base -> that default should be defined only once.

We should instead define those defaults in roles defaults/ directories, either

  • in the role where it's used
  • in kubespray-defaults (main.yml) if it's used in several roles.

Where possible, the default definition should also be accompanied by a comment defining the use of the variable, and possibly a commented examples for variable with a complex internal structure.

The two benefits:

  • the code is more readable when not littered with default filters
  • variables are defined in one place

(by the way, this also apply to variable which we check with is defined -> we shouldn't have to do that if we define a default) There is no need to tackle every instance at once, but this is pretty good way to start working on the code base for new contributors.

/help /good-first-issue

貢獻者指南