From ae5001acd1fd29408d5055192513033ddfd46e8f Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Mon, 11 Nov 2024 11:04:54 -0500 Subject: [PATCH] modify env variables --- cmd/substreams/init.go | 12 ++++++------ cmd/substreams/registry-publish.go | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/substreams/init.go b/cmd/substreams/init.go index ee0c6dd2..2c152c81 100644 --- a/cmd/substreams/init.go +++ b/cmd/substreams/init.go @@ -51,11 +51,6 @@ var initCmd = &cobra.Command{ var huhTheme *huh.Theme func init() { - defaultEndpoint := "https://codegen.substreams.dev" - if newValue := os.Getenv("SUBSTREAMS_INIT_CODEGEN_ENDPOINT"); newValue != "" { - defaultEndpoint = newValue - } - initCmd.Flags().String("codegen-endpoint", defaultEndpoint, "Endpoint used to discover code generators") initCmd.Flags().String("state-file", "./generator.json", "File to load/save the state of the code generator") initCmd.Flags().Bool("force-download-cwd", false, "Force download at current dir") rootCmd.AddCommand(initCmd) @@ -111,7 +106,12 @@ func runSubstreamsInitE(cmd *cobra.Command, args []string) error { connect.WithGRPC(), } - initConvoURL := sflags.MustGetString(cmd, "codegen-endpoint") + codegenEndpoint := "https://codegen.substreams.dev" + if newValue := os.Getenv("SUBSTREAMS_CODEGEN_ENDPOINT"); newValue != "" { + codegenEndpoint = newValue + } + + initConvoURL := codegenEndpoint stateFile, stateFileFlagProvided := sflags.MustGetStringProvided(cmd, "state-file") if !strings.HasSuffix(stateFile, ".json") { return fmt.Errorf("state file must have a .json extension") diff --git a/cmd/substreams/registry-publish.go b/cmd/substreams/registry-publish.go index 0a8710e4..d271bd2d 100644 --- a/cmd/substreams/registry-publish.go +++ b/cmd/substreams/registry-publish.go @@ -41,7 +41,9 @@ var registryPublish = &cobra.Command{ func runRegistryPublish(cmd *cobra.Command, args []string) error { apiEndpoint := "https://substreams.dev" - apiEndpoint = os.Getenv("SUBSTREAMS_DEV_ENDPOINT") + if newValue := os.Getenv("SUBSTREAMS_REGISTRY_ENDPOINT"); newValue != "" { + apiEndpoint = newValue + } var apiKey string registryTokenBytes, err := os.ReadFile(registryTokenFilename) @@ -105,7 +107,10 @@ func runRegistryPublish(cmd *cobra.Command, args []string) error { } spkgRegistry := "https://spkg.io" - spkgRegistry = os.Getenv("SPKG_REGISTRY_BASE") + if newValue := os.Getenv("SUBSTREAMS_DOWNLOAD_ENDPOINT"); newValue != "" { + apiEndpoint = newValue + } + readerOptions := []manifest.Option{ manifest.WithRegistryURL(spkgRegistry), }