Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EnvPlugin = api.Plugin{ Name: "env", Setup: func(build api.PluginBuild) { build.OnResolve(api.OnResolveOptions{Filter: `^env$`}, func(args api.OnResolveArgs) (api.OnResolveResult, error) { return api.OnResolveResult{ Path: args.Path, Namespace: "env-ns", }, nil }) build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: "env-ns"}, func(args api.OnLoadArgs) (api.OnLoadResult, error) { mappings := make(map[string]string) for _, item := range os.Environ() { if equals := strings.IndexByte(item, '='); equals != -1 { mappings[item[:equals]] = item[equals+1:] } } bytes, err := json.Marshal(mappings) if err != nil { return api.OnLoadResult{}, err } contents := string(bytes) return api.OnLoadResult{ Contents: &contents, Loader: api.LoaderJSON, }, nil }) }, }
EnvPlugin reads environment variable
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.