Skip to content

Commit

Permalink
Tweak environment variable names (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
silas authored Oct 15, 2024
1 parent 90e47d0 commit 661d0ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions internal/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (

func newUpgrade() *cobra.Command {
cmd := &cobra.Command{
Use: "upgrade",
Short: "Run all schema upgrades",
Args: args(),
Use: "upgrade",
Short: "Run all schema upgrades",
Aliases: []string{"up"},
Args: args(),
RunE: func(cmd *cobra.Command, args []string) error {
m, err := newMigrations(cmd, true)
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions internal/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func newMigrations(cmd *cobra.Command, load bool) (*migrations.Migrations, error
m.Config.Project = project
}
if m.Config.Project == "" {
m.Config.Project = os.Getenv(constants.EnvProject)
m.Config.Project = os.Getenv(constants.EnvProjectId)
}
if m.Config.Project == "" {
m.Config.Project = os.Getenv(constants.EnvGoogleCloudProject)
}

instanceId, err := cmd.Flags().GetString(flagInstance)
Expand All @@ -74,7 +77,7 @@ func newMigrations(cmd *cobra.Command, load bool) (*migrations.Migrations, error
m.Config.InstanceId = instanceId
}
if m.Config.InstanceId == "" {
m.Config.InstanceId = os.Getenv(constants.EnvInstance)
m.Config.InstanceId = os.Getenv(constants.EnvInstanceId)
}

databaseId, err := cmd.Flags().GetString(flagDatabase)
Expand All @@ -85,7 +88,7 @@ func newMigrations(cmd *cobra.Command, load bool) (*migrations.Migrations, error
m.Config.DatabaseId = databaseId
}
if m.Config.DatabaseId == "" {
m.Config.DatabaseId = os.Getenv(constants.EnvDatabase)
m.Config.DatabaseId = os.Getenv(constants.EnvDatabaseId)
}

if flagSet(cmd, flagEmulator) {
Expand Down
7 changes: 4 additions & 3 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const (

EnvEmulatorHost = "SPANNER_EMULATOR_HOST"
EnvEmulatorHostDefault = "127.0.0.1:9010"
EnvProject = "SPANNER_PROJECT"
EnvInstance = "SPANNER_INSTANCE"
EnvDatabase = "SPANNER_DATABASE"
EnvGoogleCloudProject = "GOOGLE_CLOUD_PROJECT"
EnvProjectId = "SPANNER_PROJECT_ID"
EnvInstanceId = "SPANNER_INSTANCE_ID"
EnvDatabaseId = "SPANNER_DATABASE_ID"
)

0 comments on commit 661d0ec

Please sign in to comment.