-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(
config
): global plugins config (#3214)
* base * base refactor * refactor * rename * rename * fix comment * rename file * format * refactor base * format * refactor some imports * imports refactor * fix * fix import * refactor: * changelog * changelog * Update ignite/services/network/networkchain/init.go Co-authored-by: Jerónimo Albi <[email protected]> * base -> baseconfig * refactoring for clarity * v12 -> v1 * fix tests * fix integration * fix name * fix integration * format * Update ignite/cmd/cmd.go Co-authored-by: Jerónimo Albi <[email protected]> * imports * LocateDefault logic * lint fix * refactor and test * finish refactor * revert * move * move * rename * fix tests * fix test * rename * add global * functionality * format * fix error statement for global plugins * typo * chainconfig * imports * fix imports * address review * testdata * better import * fix test * changelog * refactor * simplify * RemoveDuplicates * refactor LoadPlugins * lint * add global flag * add info * add error prints * simplify return * fix test * fix global parse * add integration test * modify test * fix returns * use ignite example plugin * refactor global flag * Fix plugin integration test Add more assertion and use an alternate `.ignite` folder to avoid conflicts with user home. Also fix `plugin add -g` when `.ignite/plugins` doesn't exist. * add removed TODO by mistake * move flags * return err * Update ignite/cmd/plugin.go Co-authored-by: Thomas Bruyelle <[email protected]> * format * fix test * remove yaml tag * Update ignite/cmd/plugin.go Co-authored-by: Thomas Bruyelle <[email protected]> * fix test * test: add key/value pairs to plugin add * add detailed plugin Co-authored-by: Jerónimo Albi <[email protected]> Co-authored-by: Thomas Bruyelle <[email protected]> Co-authored-by: Thomas Bruyelle <[email protected]>
- Loading branch information
1 parent
bdcd0b7
commit 304e5d5
Showing
12 changed files
with
395 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,9 @@ | ||
package config | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/ignite/cli/ignite/pkg/env" | ||
"github.com/ignite/cli/ignite/pkg/xfilepath" | ||
) | ||
|
||
// DirPath returns the path of configuration directory of Ignite. | ||
var DirPath = xfilepath.JoinFromHome(xfilepath.Path(".ignite")) | ||
|
||
// CreateConfigDir creates config directory if it is not created yet. | ||
func CreateConfigDir() error { | ||
path, err := DirPath() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return os.MkdirAll(path, 0o755) | ||
} | ||
var DirPath = xfilepath.Mkdir(env.ConfigDir()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
package env | ||
|
||
import "os" | ||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/ignite/cli/ignite/pkg/xfilepath" | ||
) | ||
|
||
const ( | ||
debug = "IGNT_DEBUG" | ||
debug = "IGNT_DEBUG" | ||
configDir = "IGNT_CONFIG_DIR" | ||
) | ||
|
||
func DebugEnabled() bool { | ||
return os.Getenv(debug) == "1" | ||
} | ||
|
||
func ConfigDir() xfilepath.PathRetriever { | ||
return func() (string, error) { | ||
if dir := os.Getenv(configDir); dir != "" { | ||
if !path.IsAbs(dir) { | ||
panic(fmt.Sprintf("%s must be an absolute path", configDir)) | ||
} | ||
return dir, nil | ||
} | ||
return xfilepath.JoinFromHome(xfilepath.Path(".ignite"))() | ||
} | ||
} | ||
|
||
func SetConfigDir(dir string) { | ||
err := os.Setenv(configDir, dir) | ||
if err != nil { | ||
panic(fmt.Sprintf("set config dir env: %v", err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.