forked from parallaxsecond/parsec-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
58 lines (50 loc) · 1.17 KB
/
client.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
48
49
50
51
52
53
54
55
56
57
58
package client
import (
"github.com/docker/parsec/types"
)
// Client is a Parsec client representing a connection and set of API implementations
type Client struct {
*conn
SystemClient
KeyManagerClient
}
// KeyManagerClient is an interface to the key management facilities of Parsec
type KeyManagerClient interface {
KeyGet(keyid types.KeyID) (Key, error)
KeyImport(k Key) error
KeyDelete(keyid types.KeyID) error
KeyList() ([]Key, error)
}
// SystemClient is an interface to the system calls of Parsec
type SystemClient interface {
Version() string
Info() (types.Info, error)
}
// InitClient initializes a Parsec client
func InitClient() (*Client, error) {
client := &Client{
conn: &conn{},
}
err := client.conn.open()
if err != nil {
return nil, err
}
err = client.conn.close()
if err != nil {
return nil, err
}
//TODO version or other init
return client, nil
}
// KeyGet obtains a key from Parsec by KeyID
func (c Client) KeyGet(keyid types.KeyID, attributes types.KeyAttributes) (Key, error) {
k := signingKey{
key: key{
KeyID: keyid,
conn: c.conn,
attributes: attributes,
},
}
//TODO ListKeys to verify presence
return k, nil
}