Skip to content

Instantly share code, notes, and snippets.

@joelrebel
Created March 5, 2024 17:11
Show Gist options
  • Save joelrebel/f2798842e537ea297938113cca2d3e67 to your computer and use it in GitHub Desktop.
Save joelrebel/f2798842e537ea297938113cca2d3e67 to your computer and use it in GitHub Desktop.
diff --git a/cmd/add-versioned-attributes-fleetdb/main.go b/cmd/add-versioned-attributes-fleetdb/main.go
index f005f83..faa02e9 100644
--- a/cmd/add-versioned-attributes-fleetdb/main.go
+++ b/cmd/add-versioned-attributes-fleetdb/main.go
@@ -45,6 +45,22 @@ func init() {
}
}
+func noauthHSSClient(ctx context.Context) (*serverservice.Client, error) {
+ // init retryable http client
+ retryableClient := retryablehttp.NewClient()
+ retryableClient.RetryMax = 0
+
+ // requests taking longer than timeout value should be canceled.
+ client := retryableClient.StandardClient()
+ client.Timeout = 2 * time.Second
+
+ return serverservice.NewClientWithToken(
+ "dummy",
+ "http://localhost:8000",
+ client,
+ )
+}
+
func newServerServiceClient(ctx context.Context, target string) (*serverservice.Client, error) {
// init retryable http client
retryableClient := retryablehttp.NewClient()
@@ -59,7 +75,7 @@ func newServerServiceClient(ctx context.Context, target string) (*serverservice.
return nil, err
}
- token := "xxx"
+ token := os.Getenv("TOKEN")
// setup oauth configuration
oauthConfig := clientcredentials.Config{
ClientID: "alloy-deprovision-client",
@@ -94,7 +110,7 @@ func main() {
}
fmt.Printf("Connecting to ServerService")
- serverServiceClient, err := newServerServiceClient(context.Background(), "https://server-service.equinixmetal.net")
+ serverServiceClient, err := noauthHSSClient(context.Background())
if err != nil {
panic(err)
}
@@ -127,15 +143,15 @@ func main() {
fmt.Println()
fmt.Printf("start processing server %v\n", serverID)
- server, _, err := serverServiceClient.Get(context.Background(), serverID)
+ _, _, err := serverServiceClient.Get(context.Background(), serverID)
if err != nil {
panic(fmt.Sprintf("Error Get server %v from HSS: %v", serverID, err))
}
// Test migrating db13 first.
- if server.FacilityCode != "dc13" {
- continue
- }
+ // if server.FacilityCode != "dc13" {
+ // continue
+ // }
hssServerComponents, _, err := serverServiceClient.GetComponents(context.Background(), serverID, nil)
if err != nil {
diff --git a/cmd/go.mod b/cmd/go.mod
index f38f182..badd7eb 100644
--- a/cmd/go.mod
+++ b/cmd/go.mod
@@ -1,6 +1,6 @@
module enrollmodule
-go 1.21.6
+go 1.23
require (
github.com/coreos/go-oidc v2.2.1+incompatible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment