-
Notifications
You must be signed in to change notification settings - Fork 135
/
update.go
34 lines (28 loc) · 914 Bytes
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package queue
import (
"fmt"
"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/pkg/api"
"github.com/armadaproject/armada/pkg/client"
)
type UpdateAPI func(queue Queue) error
func Update(getConnectionDetails client.ConnectionDetails) UpdateAPI {
return func(queue Queue) error {
connectionDetails, err := getConnectionDetails()
if err != nil {
return fmt.Errorf("failed to obtain api connection details: %s", err)
}
conn, err := client.CreateApiConnection(connectionDetails)
if err != nil {
return fmt.Errorf("failed to connect to api because %s", err)
}
defer conn.Close()
ctx, cancel := common.ContextWithDefaultTimeout()
defer cancel()
client := api.NewSubmitClient(conn)
if _, err = client.UpdateQueue(ctx, queue.ToAPI()); err != nil {
return fmt.Errorf("failed to create queue with name %s. %s", queue.Name, err)
}
return nil
}
}