Skip to content

Commit

Permalink
public nodes list JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Dec 20, 2018
1 parent d91e5c4 commit 70c89a9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 39 deletions.
2 changes: 2 additions & 0 deletions cmd/odm/main.go
Expand Up @@ -16,7 +16,9 @@
package main

import "github.com/OpenDroneMap/CloudODM/internal/cmd"
import "github.com/OpenDroneMap/CloudODM/internal/config"

func main() {
config.Initialize("odm")
cmd.Execute()
}
1 change: 1 addition & 0 deletions internal/cmd/node.go
Expand Up @@ -27,6 +27,7 @@ var nodeCmd = &cobra.Command{
Short: "Manage processing nodes",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("node called")
fmt.Println(Verbose)
},
}

Expand Down
41 changes: 2 additions & 39 deletions internal/cmd/root.go
Expand Up @@ -19,12 +19,10 @@ import (
"fmt"
"os"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var cfgFile string
var Verbose bool

var rootCmd = &cobra.Command{
Use: "odm",
Expand All @@ -49,40 +47,5 @@ func Execute() {
}

func init() {
cobra.OnInitialize(initConfig)

// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.odm.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// Search config in home directory with name ".odm" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".odm")
}

viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "show verbose output")
}
31 changes: 31 additions & 0 deletions internal/config/configuration.go
@@ -0,0 +1,31 @@
package config

import (
"fmt"
"os"
"path/filepath"

homedir "github.com/mitchellh/go-homedir"
)

type Configuration struct {
nodes map[string]Node
}

type Node struct {
url string
token string
}

// Initialize the configuration
func Initialize(name string) {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

cfgPath := filepath.Join(home, "."+name+".json")

}
8 changes: 8 additions & 0 deletions public_nodes.json
@@ -0,0 +1,8 @@
[
{
"url": "https://spark1.webodm.net",
"maintainer": "Piero Toffanin <pt@masseranolabs.com>",
"company": "MasseranoLabs LLC",
"website": "https://www.webodm.net"
}
]

0 comments on commit 70c89a9

Please sign in to comment.