ovh.go 853 B

1234567891011121314151617181920212223242526272829303132333435
  1. package config
  2. import (
  3. "log"
  4. "path/filepath"
  5. "github.com/ovh/go-ovh/ovh"
  6. )
  7. var OVHClient *ovh.Client
  8. // InitOVHClient initializes the OVH client using the configuration file
  9. func InitOVHClient() {
  10. // Get absolute path to ovh.conf in current directory
  11. configPath, err := filepath.Abs("./ovh.conf")
  12. if err != nil {
  13. log.Fatalf("Error getting config path: %v", err)
  14. }
  15. // Create client using config file
  16. client, err := ovh.NewClient(
  17. "ovh-eu", // Endpoint
  18. "", // Application key (will be loaded from config)
  19. "", // Application secret (will be loaded from config)
  20. "", // Consumer key (will be loaded from config)
  21. )
  22. log.Printf("client: %v", client)
  23. if err != nil {
  24. log.Fatalf("Error creating OVH client: %v", err)
  25. }
  26. log.Printf("OVH client initialized with config from: %s", configPath)
  27. OVHClient = client
  28. }