diff --git a/README.md b/README.md index 9b125c3..010a87d 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,32 @@ -# chambr +# realm [![release](https://github.com/steviebps/rein/actions/workflows/go.yml/badge.svg)](https://github.com/steviebps/rein/actions/workflows/go.yml) -```go get -u github.com/steviebps/chambr``` +```go get -u github.com/steviebps/realm``` ## starter configs ### a basic chamber file -```wget -O $HOME/.chambr/masterChamber.json https://raw.githubusercontent.com/steviebps/rein/master/configs/masterChamber.json``` +```wget -O $HOME/.realm/masterChamber.json https://raw.githubusercontent.com/steviebps/rein/master/configs/masterChamber.json``` ## example commands ### build -```chambr build -o /path/to/your/directory``` +```realm build -o /path/to/your/directory``` with forced directory creation -```chambr build -o /path/to/your/directory --force``` +```realm build -o /path/to/your/directory --force``` #### Pipe into an archive: -```chambr build | tar zcf archive.tar.gz -T -``` +```realm build | tar zcf archive.tar.gz -T -``` ### print #### Pretty prints your global chamber to stdout: -```chambr print -p``` +```realm print -p``` #### Print your global chamber to file: -```chambr print -o /path/to/your/file.json``` +```realm print -o /path/to/your/file.json``` diff --git a/cmd/build.go b/cmd/build.go index 64f4c7b..b3f88b2 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -6,9 +6,9 @@ import ( "path/filepath" "github.com/spf13/cobra" - "github.com/steviebps/rein/internal/logger" - rein "github.com/steviebps/rein/pkg" - "github.com/steviebps/rein/utils" + "github.com/steviebps/realm/internal/logger" + realm "github.com/steviebps/realm/pkg" + "github.com/steviebps/realm/utils" ) var chamberName string @@ -21,7 +21,7 @@ var buildCmd = &cobra.Command{ Use: "build", Short: "Build chambers with inherited toggles", Long: `Build command will take your chamber configs and compile them with their inherited values`, - Example: "rein build -o /path/to/your/directory", + Example: "realm build -o /path/to/your/directory", Run: func(cmd *cobra.Command, args []string) { outputDir, _ := cmd.Flags().GetString("output-dir") forceCreateDir, _ := cmd.Flags().GetBool("force") @@ -44,7 +44,7 @@ var buildCmd = &cobra.Command{ os.Mkdir(fullPath, 0700) } else { buildCmdError(fmt.Sprintf("Directory %v does not exist", fullPath)) - logger.InfoString(fmt.Sprintf("\nTry running: \"rein build --output-dir %v --force\" to force create the directory", outputDir)) + logger.InfoString(fmt.Sprintf("\nTry running: \"realm build --output-dir %v --force\" to force create the directory", outputDir)) os.Exit(1) } } @@ -64,9 +64,9 @@ func getOutputDirectory(outputDir string) (string, error) { return filepath.Abs(outputDir) } -func build(parent *rein.Chamber, fullPath string, version string, cmd *cobra.Command) { +func build(parent *realm.Chamber, fullPath string, version string, cmd *cobra.Command) { - parent.TraverseAndBuild(func(c rein.Chamber) bool { + parent.TraverseAndBuild(func(c realm.Chamber) bool { searchingByName := chamberName != "" foundByName := chamberName == c.Name diff --git a/cmd/get.go b/cmd/get.go index fe31fa0..ca6d9a6 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -5,8 +5,8 @@ import ( "os" "github.com/spf13/cobra" - "github.com/steviebps/rein/internal/logger" - rein "github.com/steviebps/rein/pkg" + "github.com/steviebps/realm/internal/logger" + realm "github.com/steviebps/realm/pkg" ) var getCmdError = logger.ErrorWithPrefix("Error running get command: ") @@ -22,7 +22,7 @@ var getCmd = &cobra.Command{ toggle, _ := cmd.Flags().GetString("toggle") chamberName, _ = cmd.Flags().GetString("chamber") - globalChamber.TraverseAndBuild(func(c rein.Chamber) bool { + globalChamber.TraverseAndBuild(func(c realm.Chamber) bool { if c.Name == chamberName { value = c.GetToggleValue(toggle, version) } diff --git a/cmd/print.go b/cmd/print.go index 09953df..85847b0 100644 --- a/cmd/print.go +++ b/cmd/print.go @@ -5,8 +5,8 @@ import ( "os" "github.com/spf13/cobra" - "github.com/steviebps/rein/internal/logger" - "github.com/steviebps/rein/utils" + "github.com/steviebps/realm/internal/logger" + "github.com/steviebps/realm/utils" ) var printCmdError = logger.ErrorWithPrefix("Error running print command: ") diff --git a/cmd/root.go b/cmd/root.go index 6ab417b..3183b8f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,21 +9,21 @@ import ( "github.com/spf13/cobra" homedir "github.com/mitchellh/go-homedir" - "github.com/steviebps/rein/internal/logger" - rein "github.com/steviebps/rein/pkg" - utils "github.com/steviebps/rein/utils" + "github.com/steviebps/realm/internal/logger" + realm "github.com/steviebps/realm/pkg" + utils "github.com/steviebps/realm/utils" ) var home string var cfgFile string -var globalChamber = rein.Chamber{Toggles: map[string]*rein.Toggle{}, Children: []*rein.Chamber{}} +var globalChamber = realm.Chamber{Toggles: map[string]*realm.Toggle{}, Children: []*realm.Chamber{}} -// Version the version of rein +// Version the version of realm var Version = "development" // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "rein", + Use: "realm", Short: "Local and remote configuration management", Long: `CLI for managing application configuration of local and remote JSON files`, PersistentPreRun: configPreRun, @@ -35,7 +35,7 @@ var rootCmd = &cobra.Command{ // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { if err := rootCmd.Execute(); err != nil { - logger.ErrorString(fmt.Sprintf("Error while starting rein: %v", err)) + logger.ErrorString(fmt.Sprintf("Error while starting realm: %v", err)) os.Exit(1) } } @@ -51,7 +51,7 @@ func init() { } rootCmd.SetVersionTemplate(`{{printf "%s\n" .Version}}`) - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "rein configuration file") + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "realm configuration file") rootCmd.PersistentFlags().String("app-version", "", "runs all commands with a specified version") } @@ -59,15 +59,15 @@ func init() { func initConfig() { if cfgFile != "" { // Use config file from the flag. - rein.SetConfigFile(cfgFile) + realm.SetConfigFile(cfgFile) } else { - rein.AddConfigPath("./") - rein.AddConfigPath(home + "/.rein/") - rein.SetConfigName("rein.json") + realm.AddConfigPath("./") + realm.AddConfigPath(home + "/.realm/") + realm.SetConfigName("realm.json") } // If a config file is found, read it in. - if err := rein.ReadInConfig(false); err != nil { + if err := realm.ReadInConfig(false); err != nil { logger.ErrorString(err.Error()) os.Exit(1) } @@ -81,7 +81,7 @@ func retrieveRemoteConfig(url string) (*http.Response, error) { func configPreRun(cmd *cobra.Command, args []string) { var jsonFile io.ReadCloser var err error - chamberFile := rein.StringValue("chamber", "") + chamberFile := realm.StringValue("chamber", "") validURL, url := utils.IsURL(chamberFile) if validURL { diff --git a/configs/rein.json b/configs/realm.json similarity index 100% rename from configs/rein.json rename to configs/realm.json diff --git a/examples/go/main.go b/examples/go/main.go index 0c2d896..c935556 100644 --- a/examples/go/main.go +++ b/examples/go/main.go @@ -5,11 +5,11 @@ import ( "log" "net/http" - rein "github.com/steviebps/rein/pkg" + realm "github.com/steviebps/realm/pkg" ) func handler(w http.ResponseWriter, r *http.Request) { - message := rein.StringValue("message", "DEFAULT") + message := realm.StringValue("message", "DEFAULT") w.Write([]byte(message)) } @@ -17,21 +17,21 @@ func main() { mux := http.NewServeMux() mux.HandleFunc("/", handler) - rein.SetVersion("v1.0.0") + realm.SetVersion("v1.0.0") - if err := rein.AddConfigPath("./"); err != nil { + if err := realm.AddConfigPath("./"); err != nil { log.Fatal(err) } - if err := rein.SetConfigName("chambers.json"); err != nil { + if err := realm.SetConfigName("chambers.json"); err != nil { log.Fatal(err) } - if err := rein.ReadInConfig(true); err != nil { + if err := realm.ReadInConfig(true); err != nil { log.Fatal(err) } - port := rein.Float64Value("port", 3000) + port := realm.Float64Value("port", 3000) log.Println("Listening on :", port) err := http.ListenAndServe(fmt.Sprintf(":%d", int(port)), mux) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index f1b2d97..573ac47 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -3,7 +3,7 @@ package logger import ( "fmt" - "github.com/steviebps/rein/internal/colors" + "github.com/steviebps/realm/internal/colors" ) func ErrorString(e string) { diff --git a/main.go b/main.go index 9b513f2..66fac04 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ limitations under the License. */ package main -import "github.com/steviebps/rein/cmd" +import "github.com/steviebps/realm/cmd" func main() { cmd.Execute() diff --git a/pkg/chamber.go b/pkg/chamber.go index d341487..18bd7b6 100644 --- a/pkg/chamber.go +++ b/pkg/chamber.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "encoding/json" diff --git a/pkg/chamber_test.go b/pkg/chamber_test.go index 3125fa2..dcc5d21 100644 --- a/pkg/chamber_test.go +++ b/pkg/chamber_test.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "testing" diff --git a/pkg/override.go b/pkg/override.go index 517b7fc..2752130 100644 --- a/pkg/override.go +++ b/pkg/override.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "encoding/json" diff --git a/pkg/override_test.go b/pkg/override_test.go index 33b7044..48b0598 100644 --- a/pkg/override_test.go +++ b/pkg/override_test.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "bytes" diff --git a/pkg/rein.go b/pkg/realm.go similarity index 99% rename from pkg/rein.go rename to pkg/realm.go index 50d5567..9649dc5 100644 --- a/pkg/rein.go +++ b/pkg/realm.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "errors" @@ -9,7 +9,7 @@ import ( "sync" "github.com/fsnotify/fsnotify" - "github.com/steviebps/rein/utils" + "github.com/steviebps/realm/utils" "golang.org/x/mod/semver" ) diff --git a/pkg/toggle.go b/pkg/toggle.go index 352cc31..5ffd7c7 100644 --- a/pkg/toggle.go +++ b/pkg/toggle.go @@ -1,4 +1,4 @@ -package rein +package realm import ( "encoding/json" @@ -9,7 +9,7 @@ import ( ) // Toggle is a feature switch/toggle structure for holding -// its name, value, type and any overrides to be parsed by the applicable rein sdk +// its name, value, type and any overrides to be parsed by the applicable realm sdk type Toggle struct { Name string `json:"name"` ToggleType string `json:"type"`