added easier use of abstractions
This commit is contained in:
@@ -39,6 +39,12 @@ type Config struct {
|
||||
//NetworkInterfaceIPV6Index int
|
||||
}
|
||||
|
||||
// GetCurrentPath Getting P2PRC Directory from environment variable
|
||||
func GetCurrentPath() (string, error) {
|
||||
curDir := os.Getenv("PWD")
|
||||
return curDir + "/", nil
|
||||
}
|
||||
|
||||
// GetPathP2PRC Getting P2PRC Directory from environment variable
|
||||
func GetPathP2PRC(Envname string) (string, error) {
|
||||
if Envname != "" {
|
||||
@@ -49,7 +55,10 @@ func GetPathP2PRC(Envname string) (string, error) {
|
||||
}
|
||||
curDir := os.Getenv(defaultEnvName)
|
||||
if curDir == "" {
|
||||
return curDir, nil
|
||||
// if the OS env path is not found then you use
|
||||
// the current directory path.
|
||||
currentPath, _ := GetCurrentPath()
|
||||
return currentPath, nil
|
||||
}
|
||||
return curDir + "/", nil
|
||||
}
|
||||
|
||||
@@ -31,17 +31,11 @@ func SetEnvName(EnvName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCurrentPath Getting P2PRC Directory from environment variable
|
||||
func GetCurrentPath() (string, error) {
|
||||
curDir := os.Getenv("PWD")
|
||||
return curDir + "/", nil
|
||||
}
|
||||
|
||||
// SetDefaults This function to be called only during a
|
||||
// make install
|
||||
func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, NoBoilerPlate bool, ConfigUpdate ...*config.Config) (*config.Config, error) {
|
||||
//Setting current directory to default path
|
||||
defaultPath, err := GetCurrentPath()
|
||||
defaultPath, err := config.GetCurrentPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"golang.org/x/crypto/ssh"
|
||||
@@ -61,7 +62,7 @@ func GenerateIPTableFile(rootNodes []p2p.IpAddress) (err error) {
|
||||
|
||||
// CreateIPTableFolderStructure Create folder structure for IPTable
|
||||
func CreateIPTableFolderStructure() (err error) {
|
||||
path, err := GetCurrentPath()
|
||||
path, err := config.GetCurrentPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -87,7 +88,7 @@ func CreateIPTableFolderStructure() (err error) {
|
||||
|
||||
// GenerateDockerFiles Generate default docker files
|
||||
func GenerateDockerFiles() (err error) {
|
||||
path, err := GetCurrentPath()
|
||||
path, err := config.GetCurrentPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -132,7 +133,7 @@ func GenerateDockerFiles() (err error) {
|
||||
|
||||
// GeneratePluginDirectory Generates plugin directory structure
|
||||
func GeneratePluginDirectory() (err error) {
|
||||
path, err := GetCurrentPath()
|
||||
path, err := config.GetCurrentPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -150,7 +151,7 @@ func GeneratePluginDirectory() (err error) {
|
||||
}
|
||||
|
||||
func GenerateClientTrackContainers() (err error) {
|
||||
path, err := GetCurrentPath()
|
||||
path, err := config.GetCurrentPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user