-
Notifications
You must be signed in to change notification settings - Fork 2
/
resource_images.go
47 lines (39 loc) · 1.03 KB
/
resource_images.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
35
36
37
38
39
40
41
42
43
44
45
46
47
package fly
import "context"
func (client *Client) GetLatestImageTag(ctx context.Context, repository string, snapshotId *string) (string, error) {
query := `
query($repository: String!, $snapshotId: ID) {
latestImageTag(repository: $repository, snapshotId: $snapshotId)
}
`
req := client.NewRequest(query)
req.Var("repository", repository)
req.Var("snapshotId", snapshotId)
ctx = ctxWithAction(ctx, "get_latest_image_tag")
data, err := client.RunWithContext(ctx, req)
if err != nil {
return "", err
}
return data.LatestImageTag, nil
}
func (client *Client) GetLatestImageDetails(ctx context.Context, image string) (*ImageVersion, error) {
query := `
query($image: String!) {
latestImageDetails(image: $image){
registry
repository
tag
version
digest
}
}
`
req := client.NewRequest(query)
ctx = ctxWithAction(ctx, "get_latest_image_details")
req.Var("image", image)
data, err := client.RunWithContext(ctx, req)
if err != nil {
return nil, err
}
return &data.LatestImageDetails, nil
}