github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/pfsconfjsonpacked/main.go (about) 1 // Copyright (c) 2015-2021, NVIDIA CORPORATION. 2 // SPDX-License-Identifier: Apache-2.0 3 4 package main 5 6 import ( 7 "encoding/json" 8 "fmt" 9 "log" 10 "os" 11 12 "github.com/swiftstack/ProxyFS/conf" 13 "github.com/swiftstack/ProxyFS/transitions" 14 ) 15 16 func main() { 17 args := os.Args[1:] 18 19 // Read in the program's os.Arg[1]-specified (and required) .conf file 20 if len(args) == 0 { 21 log.Fatalf("no .conf file specified") 22 } 23 24 confMap, confErr := conf.MakeConfMapFromFile(args[0]) 25 if nil != confErr { 26 log.Fatalf("failed to load config: %v", confErr) 27 } 28 29 // Update confMap with any extra os.Args supplied 30 confErr = confMap.UpdateFromStrings(args[1:]) 31 if nil != confErr { 32 log.Fatalf("failed to load config overrides: %v", confErr) 33 } 34 35 confErr = transitions.UpgradeConfMapIfNeeded(confMap) 36 if nil != confErr { 37 log.Fatalf("failed to upgrade config: %v", confErr) 38 } 39 40 confMapJSONPacked, _ := json.Marshal(confMap) 41 42 fmt.Printf("%v", string(confMapJSONPacked[:])) 43 }