jrushford commented on a change in pull request #5352: URL: https://github.com/apache/trafficcontrol/pull/5352#discussion_r536421935
########## File path: traffic_ops_ort/plugin_verifier/config/config.go ########## @@ -0,0 +1,90 @@ +package config + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "errors" + "fmt" + "github.com/apache/trafficcontrol/lib/go-log" + "github.com/pborman/getopt/v2" + "os" +) + +type Cfg struct { + CommandArgs []string + LogLocationDebug string + LogLocationError string + LogLocationInfo string + TrafficServerConfigDir string + TrafficServerPluginDir string +} + +var ( + defaultATSConfigDir = "/opt/trafficserver/etc/trafficserver" + defaultATSPluginDir = "/opt/trafficserver/libexec/trafficserver" +) + +func (cfg Cfg) DebugLog() log.LogLocation { return log.LogLocation(cfg.LogLocationDebug) } +func (cfg Cfg) ErrorLog() log.LogLocation { return log.LogLocation(cfg.LogLocationError) } +func (cfg Cfg) InfoLog() log.LogLocation { return log.LogLocation(cfg.LogLocationInfo) } +func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(log.LogLocationNull) } // warn logging is not used. +func (cfg Cfg) EventLog() log.LogLocation { return log.LogLocation(log.LogLocationNull) } // event logging is not used. + +func Usage() { + fmt.Println("\nUsage: plugin_verifier [options] [optional config.file]") + fmt.Println("\t[options]:") + fmt.Println("\t--log-location-debug=[value] | -d [value], where to log debugs, default is empty") + fmt.Println("\t--log-location-error=[value], | -e [value], where to log errors, default is 'stderr'") + fmt.Println("\t--log-location-info=[value] | -i [value], where to log infos, default is 'stderr'") + fmt.Println("\t--trafficserver-config-dir=[value] | -c [value], where to find ATS config files, default is '/opt/trafficserver/etc/trafficserver'") + fmt.Println("\t--trafficserver-plugin-dir=[value] | -p [value], where to find ATS plugins, default is '/opt/trafficserver/libexec/trafficserver'") + fmt.Println("\t--help | -h, this help message\n") + os.Exit(0) +} + +func InitConfig() (Cfg, error) { Review comment: Sure, I overlooked this. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
