Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cmd/baton-sql-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"os"

"path/filepath"

config "github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"github.com/conductorone/baton-sdk/pkg/types"
Expand All @@ -16,10 +18,25 @@ import (

var version = "dev"

func getConfigDir(name string) string {
return filepath.Join(os.Getenv("PROGRAMDATA"), "ConductorOne", name)
}

func main() {
ctx := context.Background()

_, cmd, err := config.DefineConfiguration(ctx, "baton-sql-server", getConnector, cfg)
connectorName := "baton-sql-server"
configPath := os.Getenv("BATON_CONFIG_PATH")
if configPath == "" && os.Getenv("PROGRAMDATA") != "" {
// Set BATON_CONFIG_PATH so that if we're running as a windows service, we use the correct config file
err := os.Setenv("BATON_CONFIG_PATH", filepath.Join(getConfigDir(connectorName), "config.yaml"))
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}

_, cmd, err := config.DefineConfiguration(ctx, connectorName, getConnector, cfg)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
Expand Down
Loading