From 9ba150953e6ef5af4681495a2d888aebd9d8c534 Mon Sep 17 00:00:00 2001 From: Tony Grosinger Date: Tue, 6 Dec 2022 08:38:17 -0800 Subject: [PATCH] Make the config file a required argument When running in a container we should not attempt to look in the homedir for a config file. The user should explicitly mount it into the container and pass it to the program. --- README.md | 2 +- digitalocean-dynamic-ip.go | 13 ++----------- go.mod | 2 -- go.sum | 2 -- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ecef432..e13331f 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ The `ipv4CheckUrl` and `ipv6CheckUrl` configuration settings are optional. If se ./digitalocean-dynamic-ip ``` -Optionally, you can create the configuration file with any name wherever you want, and pass it as a command line argument: +Configuration file location must be specified as a positional argument: ```bash #run: diff --git a/digitalocean-dynamic-ip.go b/digitalocean-dynamic-ip.go index b53e4ac..06c3f40 100644 --- a/digitalocean-dynamic-ip.go +++ b/digitalocean-dynamic-ip.go @@ -13,8 +13,6 @@ import ( "net/url" "os" "strconv" - - homedir "github.com/mitchellh/go-homedir" ) func checkError(err error) { @@ -117,16 +115,11 @@ func GetConfig() ClientConfig { log.SetOutput(os.Stdout) } - configFile := "" if len(flag.Args()) == 0 { - var err error - configFile, err = homedir.Dir() - checkError(err) - configFile += "/.digitalocean-dynamic-ip.json" - } else { - configFile = flag.Args()[0] + logError("Missing required argument with config file path.") } + configFile := flag.Args()[0] log.Printf("Using Config file: %s", configFile) getfile, err := ioutil.ReadFile(configFile) @@ -142,8 +135,6 @@ func usage() { "-h | -help\n\tShow this help message\n"+ "-d | -debug\n\tPrint debug messages to standard output\n"+ "[config_file]\n\tlocation of the configuration file\n\n"+ - "If the [config_file] parameter is not passed, then the default\n"+ - "config location of ~/.digitalocean-dynamic-ip.json will be used.\n\n"+ "example usages:\n\t%[1]s -help\n"+ "\t%[1]s\n"+ "\t%[1]s %[2]s\n"+ diff --git a/go.mod b/go.mod index dd16a23..fdff553 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/anaganisk/digitalocean-dynamic-dns-ip -require github.com/mitchellh/go-homedir v1.1.0 - go 1.8 diff --git a/go.sum b/go.sum index ae38d14..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=