ToCacheMap converts Vars to an unordered map containing only the static variables
()
| 98 | // ToCacheMap converts Vars to an unordered map containing only the static |
| 99 | // variables |
| 100 | func (vars *Vars) ToCacheMap() (m map[string]any) { |
| 101 | if vars == nil || vars.om == nil { |
| 102 | return nil |
| 103 | } |
| 104 | defer vars.mutex.RUnlock() |
| 105 | vars.mutex.RLock() |
| 106 | m = make(map[string]any, vars.Len()) |
| 107 | for k, v := range vars.All() { |
| 108 | if v.Sh != nil && *v.Sh != "" { |
| 109 | // Dynamic variable is not yet resolved; trigger |
| 110 | // <no value> to be used in templates. |
| 111 | continue |
| 112 | } |
| 113 | if v.Live != nil { |
| 114 | m[k] = v.Live |
| 115 | } else { |
| 116 | m[k] = v.Value |
| 117 | } |
| 118 | } |
| 119 | return m |
| 120 | } |
| 121 | |
| 122 | // Merge loops over other and merges it values with the variables in vars. If |
| 123 | // the include parameter is not nil and its it is an advanced import, the |