Skip to content

Commit fa95e86

Browse files
authored
Merge pull request #776 from cprivitere/main
🐛 Fix CI Cleanup
2 parents e1334ef + c8a6282 commit fa95e86

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

.github/workflows/cleanup.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ name: Cleanup
22
on:
33
schedule:
44
- cron: "0 */2 * * *" # TODO: Run every 4 hours to soak test, should be less frequent before merge (weekly/daily/???)
5+
workflow_dispatch:
56
jobs:
67
cleanup:
78
name: Cleanup any orphaned CI Resources
89
runs-on: ubuntu-latest
910
steps:
10-
- name: checkout
11-
uses: actions/checkout@v4
12-
- uses: actions/setup-go@v5
13-
with:
14-
go-version-file: './go.mod'
15-
- name: Run the cleanup tool
16-
run: go run ./cmd/ci-clean
17-
env:
18-
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
19-
PROJECT_ID: ${{ secrets.PROJECT_ID }}
11+
- name: checkout
12+
uses: actions/checkout@v4
13+
- uses: actions/setup-go@v5
14+
with:
15+
go-version-file: "./go.mod"
16+
- name: Run the cleanup tool
17+
run: go run ./cmd/ci-clean
18+
env:
19+
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
20+
PROJECT_ID: ${{ secrets.PROJECT_ID }}

internal/emlb/emlb.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type EMLB struct {
7676
client *lbaas.APIClient
7777
metro string
7878
projectID string
79-
tokenExchanger *TokenExchanger
79+
TokenExchanger *TokenExchanger
8080
}
8181

8282
// NewEMLB creates a new Equinix Metal Load Balancer API client object.
@@ -86,7 +86,7 @@ func NewEMLB(metalAPIKey, projectID, metro string) *EMLB {
8686
emlbConfig.Debug = checkDebugEnabled()
8787

8888
manager.client = lbaas.NewAPIClient(emlbConfig)
89-
manager.tokenExchanger = &TokenExchanger{
89+
manager.TokenExchanger = &TokenExchanger{
9090
metalAPIKey: metalAPIKey,
9191
tokenExchangeURL: loadbalancerTokenExchnageURL,
9292
client: manager.client.GetConfig().HTTPClient,
@@ -286,31 +286,31 @@ func (e *EMLB) DeleteLoadBalancerOrigin(ctx context.Context, machineScope *scope
286286

287287
// GetLoadBalancers returns a Load Balancer Collection of all the Equinix Metal Load Balancers in a project.
288288
func (e *EMLB) GetLoadBalancers(ctx context.Context) (*lbaas.LoadBalancerCollection, *http.Response, error) {
289-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
289+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
290290

291291
LoadBalancerCollection, resp, err := e.client.ProjectsApi.ListLoadBalancers(ctx, e.projectID).Execute()
292292
return LoadBalancerCollection, resp, err
293293
}
294294

295295
// GetLoadBalancerPools returns a Load Balancer Collection of all the Equinix Metal Load Balancers in a project.
296296
func (e *EMLB) GetLoadBalancerPools(ctx context.Context) (*lbaas.LoadBalancerPoolCollection, *http.Response, error) {
297-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
297+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
298298

299299
LoadBalancerPoolCollection, resp, err := e.client.ProjectsApi.ListPools(ctx, e.projectID).Execute()
300300
return LoadBalancerPoolCollection, resp, err
301301
}
302302

303303
// getLoadBalancer Returns a Load Balancer object given an id.
304304
func (e *EMLB) getLoadBalancer(ctx context.Context, id string) (*lbaas.LoadBalancer, *http.Response, error) {
305-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
305+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
306306

307307
LoadBalancer, resp, err := e.client.LoadBalancersApi.GetLoadBalancer(ctx, id).Execute()
308308
return LoadBalancer, resp, err
309309
}
310310

311311
// getLoadBalancerPort Returns a Load Balancer Port object given an id.
312312
func (e *EMLB) getLoadBalancerPort(ctx context.Context, id string, portNumber int32) (*lbaas.LoadBalancerPort, error) {
313-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
313+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
314314

315315
LoadBalancerPort, _, err := e.client.PortsApi.GetLoadBalancerPort(ctx, id, portNumber).Execute()
316316
return LoadBalancerPort, err
@@ -319,7 +319,7 @@ func (e *EMLB) getLoadBalancerPort(ctx context.Context, id string, portNumber in
319319
// EnsureLoadBalancerOrigin takes the devices list of IP addresses in a Load Balancer Origin Pool and ensures an origin
320320
// for the first IPv4 address in the list exists.
321321
func (e *EMLB) ensureLoadBalancerOrigin(ctx context.Context, originID, poolID, lbName string, deviceAddr []corev1.NodeAddress) (*lbaas.LoadBalancerPoolOrigin, error) {
322-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
322+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
323323
log := ctrl.LoggerFrom(ctx)
324324

325325
if originID == "" {
@@ -372,7 +372,7 @@ func (e *EMLB) ensureLoadBalancerOrigin(ctx context.Context, originID, poolID, l
372372

373373
// ensureLoadBalancerPool checks if the poolID exists and if not, creates it.
374374
func (e *EMLB) ensureLoadBalancerPool(ctx context.Context, poolID, lbName string) (*lbaas.LoadBalancerPool, error) {
375-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
375+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
376376

377377
// Pool doesn't exist, so let's create it.
378378
if poolID == "" {
@@ -391,7 +391,7 @@ func (e *EMLB) ensureLoadBalancerPool(ctx context.Context, poolID, lbName string
391391

392392
// ensureLoadBalancer Takes a Load Balancer id and ensures those pools and ensures it exists.
393393
func (e *EMLB) ensureLoadBalancer(ctx context.Context, lbID, lbname string, portNumber int32) (*lbaas.LoadBalancer, *lbaas.LoadBalancerPort, error) {
394-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
394+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
395395

396396
// EMLB doesn't exist, so let's create it.
397397
if lbID == "" {
@@ -470,18 +470,18 @@ func (e *EMLB) createOrigin(ctx context.Context, poolID, originName string, targ
470470

471471
// DeleteLoadBalancer deletes an Equinix Metal Load Balancer given an ID.
472472
func (e *EMLB) DeleteLoadBalancer(ctx context.Context, lbID string) (*http.Response, error) {
473-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
473+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
474474
return e.client.LoadBalancersApi.DeleteLoadBalancer(ctx, lbID).Execute()
475475
}
476476

477477
// DeleteLoadBalancerPool deletes an Equinix Metal Load Balancer Origin Pool given an ID.
478478
func (e *EMLB) DeleteLoadBalancerPool(ctx context.Context, poolID string) (*http.Response, error) {
479-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
479+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
480480
return e.client.PoolsApi.DeleteLoadBalancerPool(ctx, poolID).Execute()
481481
}
482482

483483
func (e *EMLB) updateListenerPort(ctx context.Context, poolID, lbPortID string) (*lbaas.LoadBalancerPort, error) {
484-
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.tokenExchanger)
484+
ctx = context.WithValue(ctx, lbaas.ContextOAuth2, e.TokenExchanger)
485485

486486
// Create a listener port update request that adds the provided load balancer origin pool to the listener port.
487487
portUpdateRequest := lbaas.LoadBalancerPortUpdate{

internal/emlb/emlb_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func TestNewEMLB(t *testing.T) {
188188
g.Expect(emlb.client).To(Not(BeNil()))
189189

190190
// assert tokenExchanger is not nil
191-
g.Expect(emlb.tokenExchanger).To(Not(BeNil()))
191+
g.Expect(emlb.TokenExchanger).To(Not(BeNil()))
192192

193193
// assert project ID is correct
194194
g.Expect(emlb.projectID).To(Equal(projectID))

0 commit comments

Comments
 (0)