github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/model/Env.go (about) 1 // Ultimate Provisioner: UP cmd 2 // Copyright (c) 2019 Stephen Cheng and contributors 3 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ 7 8 package model 9 10 import "github.com/upcmd/up/model/core" 11 12 var ( 13 venvs *core.Cache 14 ) 15 16 type Env struct { 17 Name string 18 Value string 19 } 20 21 type Venv []Env 22 23 type Venvs map[string][]Venv 24 25 func GetVenv(name string) Venv { 26 v := getVenvs().Get(name) 27 if v == nil { 28 return nil 29 } else { 30 return v.(Venv) 31 } 32 33 } 34 35 func PutVenv(name string, venv Venv) { 36 getVenvs().Put(name, venv) 37 } 38 39 func DeleteVenv(name string) { 40 getVenvs().Delete(name) 41 } 42 43 func getVenvs() *core.Cache { 44 if venvs == nil { 45 venvs = core.NewCache() 46 } 47 return venvs 48 }