mirror of
https://github.com/Xevion/vastly.git
synced 2025-12-09 06:09:03 -06:00
repo init
This commit is contained in:
43
cmd/quickvast/main.go
Normal file
43
cmd/quickvast/main.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"xevion.dev/quickvast/api"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Load .env file
|
||||
if err := godotenv.Load(); err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
|
||||
// Get API key from environment
|
||||
apiKey := os.Getenv("VASTAI_API_KEY")
|
||||
if apiKey == "" {
|
||||
log.Fatal("VASTAI_API_KEY not found in environment")
|
||||
}
|
||||
|
||||
// Create client
|
||||
client := api.NewClient(apiKey)
|
||||
|
||||
// Get instances
|
||||
resp, err := client.GetInstances()
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting instances: %v", err)
|
||||
}
|
||||
|
||||
if len(resp.Instances) == 0 {
|
||||
fmt.Println("No instances found")
|
||||
return
|
||||
}
|
||||
|
||||
// Print instances
|
||||
for _, instance := range resp.Instances {
|
||||
fmt.Printf("Instance %d: %+v\n", instance.ID, instance)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user