-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
info.go
40 lines (34 loc) · 905 Bytes
/
info.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
package client
import (
"context"
controlapi "github.com/moby/buildkit/api/services/control"
apitypes "github.com/moby/buildkit/api/types"
"github.com/pkg/errors"
)
type Info struct {
BuildkitVersion BuildkitVersion `json:"buildkitVersion"`
}
type BuildkitVersion struct {
Package string `json:"package"`
Version string `json:"version"`
Revision string `json:"revision"`
}
func (c *Client) Info(ctx context.Context) (*Info, error) {
res, err := c.ControlClient().Info(ctx, &controlapi.InfoRequest{})
if err != nil {
return nil, errors.Wrap(err, "failed to call info")
}
return &Info{
BuildkitVersion: fromAPIBuildkitVersion(res.BuildkitVersion),
}, nil
}
func fromAPIBuildkitVersion(in *apitypes.BuildkitVersion) BuildkitVersion {
if in == nil {
return BuildkitVersion{}
}
return BuildkitVersion{
Package: in.Package,
Version: in.Version,
Revision: in.Revision,
}
}