Skip to content

Commit

Permalink
Fix incorrect client URL when parsing arguments incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmingoia committed Oct 18, 2024
1 parent 86d885e commit 0737148
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cmd/provider_cmd_rootly.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
)

func newCmdRootlyImporter(options ImportOptions) *cobra.Command {
url := ""
token := ""
cmd := &cobra.Command{
Use: "rootly",
Short: "Import current state to Terraform configuration from Rootly",
Long: "Import current state to Terraform configuration from Rootly",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newRootlyProvider()
err := Import(provider, options, []string{token})
err := Import(provider, options, []string{url, token})
if err != nil {
return err
}
Expand All @@ -25,6 +26,7 @@ func newCmdRootlyImporter(options ImportOptions) *cobra.Command {

cmd.AddCommand(listCmd(newRootlyProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "environment", "")
cmd.PersistentFlags().StringVarP(&url, "url", "u", "https://api.rootly.com", "env param ROOTLY_API_URL")
cmd.PersistentFlags().StringVarP(&token, "token", "t", "", "env param ROOTLY_API_TOKEN")
return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

const version = "v2.1.0"
const version = "v2.1.1"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down
8 changes: 4 additions & 4 deletions providers/rootly/rootly_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

type RootlyProvider struct { //nolint
terraformutils.Provider
apiKey string
apiUrl string
apiKey string
}

func (p *RootlyProvider) Init(args []string) error {
Expand All @@ -28,8 +28,8 @@ func (p *RootlyProvider) Init(args []string) error {
if apiKey := os.Getenv("ROOTLY_API_TOKEN"); apiKey != "" {
p.apiKey = os.Getenv("ROOTLY_API_TOKEN")
}
if args[0] != "" {
p.apiKey = args[0]
if args[1] != "" {
p.apiKey = args[1]
}
if p.apiKey == "" {
return errors.New("required API key missing")
Expand Down Expand Up @@ -3018,4 +3018,4 @@ func (p *RootlyProvider) GetSupportedService() map[string]terraformutils.Service
"team": &TeamGenerator{},
"webhooks_endpoint": &WebhooksEndpointGenerator{},
}
}
}

0 comments on commit 0737148

Please sign in to comment.