@@ -2,7 +2,6 @@ package gcp
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"math"
8
7
"os"
@@ -14,7 +13,6 @@ import (
14
13
"cloud.google.com/go/run/apiv2/runpb"
15
14
"github.com/DefangLabs/defang/src/pkg"
16
15
"github.com/DefangLabs/defang/src/pkg/types"
17
- "google.golang.org/api/iterator"
18
16
"google.golang.org/protobuf/types/known/durationpb"
19
17
)
20
18
@@ -97,49 +95,6 @@ func (gcp Gcp) SetupJob(ctx context.Context, jobId, serviceAccount string, conta
97
95
}
98
96
}
99
97
100
- func (gcp Gcp ) FindExecutionWithEtag (etag string ) (* runpb.Execution , error ) {
101
- ctx := context .Background ()
102
-
103
- // Create a Cloud Run Job Executions client
104
- client , err := run .NewExecutionsClient (ctx )
105
- if err != nil {
106
- return nil , fmt .Errorf ("failed to create Cloud Run client: %v" , err )
107
- }
108
- defer client .Close ()
109
-
110
- // List jobs in the region
111
- req := & runpb.ListExecutionsRequest {
112
- Parent : fmt .Sprintf ("projects/%s/locations/%s/jobs/%s" , gcp .ProjectId , gcp .Region , JobNameCD ),
113
- }
114
-
115
- //FIXME: This may need refactoring or architecture changes as we have to scour all
116
- // executions to find the matching etag. For any job there may be a large number of
117
- // executions to look through which may not scale well.
118
-
119
- // Iterate through executions and filter by environment variable
120
- it := client .ListExecutions (ctx , req )
121
- var execution * runpb.Execution
122
- for {
123
- execution , err = it .Next ()
124
- if err == iterator .Done {
125
- break
126
- }
127
- if err != nil {
128
- return nil , fmt .Errorf ("error listing execution: %v" , err )
129
- }
130
-
131
- // Check if the execution has the target environment variable
132
- for _ , container := range execution .Template .Containers {
133
- for _ , entry := range container .Env {
134
- if entry .GetName () == "DEFANG_ETAG" && entry .GetValue () == etag {
135
- return execution , nil
136
- }
137
- }
138
- }
139
- }
140
- return nil , errors .New ("no job found with matching etag" )
141
- }
142
-
143
98
func (gcp Gcp ) Run (ctx context.Context , jobId string , env map [string ]string , cmd ... string ) (string , error ) {
144
99
client , err := run .NewJobsClient (ctx )
145
100
if err != nil {
0 commit comments