From a9ce1815b33e7b1cf85be142ae4590d91dff5378 Mon Sep 17 00:00:00 2001
From: "Forster, Aaron" <Aaron.P.Forster@nordstrom.com>
Date: Tue, 21 Nov 2017 21:59:51 -0800
Subject: [PATCH 1/2] Added intellij and eclipse files to .gitignore.

---
 .gitignore | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)

diff --git a/.gitignore b/.gitignore
index 39f1a96..77e3f41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,146 @@ _testmain.go
 *.prof
 *.json
 /cmd/grafana-backup/grafana-backup
+
+
+# Ignored the compiled binary
+grafana-backup
+
+# Created by https://www.gitignore.io/api/go,eclipse,intellij+all
+
+### Eclipse ###
+
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+.recommenders
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# PyDev specific (Python IDE for Eclipse)
+*.pydevproject
+
+# CDT-specific (C/C++ Development Tooling)
+.cproject
+
+# Java annotation processor (APT)
+.factorypath
+
+# PDT-specific (PHP Development Tools)
+.buildpath
+
+# sbteclipse plugin
+.target
+
+# Tern plugin
+.tern-project
+
+# TeXlipse plugin
+.texlipse
+
+# STS (Spring Tool Suite)
+.springBeans
+
+# Code Recommenders
+.recommenders/
+
+# Scala IDE specific (Scala & Java development for Eclipse)
+.cache-main
+.scala_dependencies
+.worksheet
+
+### Eclipse Patch ###
+# Eclipse Core
+.project
+
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+### Go ###
+# Binaries for programs and plugins
+*.exe
+*.dll
+*.so
+*.dylib
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
+.glide/
+
+### Intellij+all ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/dictionaries
+
+# Sensitive or high-churn files:
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.xml
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+
+# Gradle:
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# CMake
+cmake-build-debug/
+
+# Mongo Explorer plugin:
+.idea/**/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Ruby plugin and RubyMine
+/.rakeTasks
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+### Intellij+all Patch ###
+# Ignores the whole idea folder
+# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+
+.idea/
+
+# End of https://www.gitignore.io/api/go,eclipse,intellij+all

From 8bff2b43a7e755b3bbeb54a3548caed2865d4847 Mon Sep 17 00:00:00 2001
From: "Forster, Aaron" <Aaron.P.Forster@nordstrom.com>
Date: Tue, 21 Nov 2017 22:00:59 -0800
Subject: [PATCH 2/2] Added the ability to check environment variables for
 server URL and token.

---
 main.go | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/main.go b/main.go
index c6d0dde..dc7ae50 100644
--- a/main.go
+++ b/main.go
@@ -51,6 +51,10 @@ var (
 	// The args after flags.
 	argCommand string
 	argPath    = "*"
+
+	// Environment variables to read from
+	tokenKey = "GRAFANA_TOKEN" // Becomes flagServerKey
+	urlKey   = "GRAFANA_URL"   // Becomes flagServerURL
 )
 
 var cancel = make(chan os.Signal, 1)
@@ -62,10 +66,24 @@ func main() {
 	// TODO parse config here
 
 	flag.Parse()
+	// We need at minimum a command to execute so throw the printUsage if we don't have > 0 args
 	if flag.NArg() == 0 {
 		printUsage()
 		os.Exit(2)
 	}
+
+	// Set Token and URL from environment variables if they are present.
+	varToken := os.Getenv(tokenKey)
+	varURL := os.Getenv(urlKey)
+
+	if varToken != "" {
+		*flagServerKey = varToken
+	}
+
+	if varURL != "" {
+		*flagServerURL = varURL
+	}
+	
 	var args = flag.Args()
 	// First mandatory argument is command.
 	argCommand = args[0]