Skip to content

Commit

Permalink
modify env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Nov 11, 2024
1 parent d5882d6 commit ae5001a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions cmd/substreams/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 7 additions & 2 deletions cmd/substreams/registry-publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
}
Expand Down

0 comments on commit ae5001a

Please sign in to comment.