/
client.go
51 lines (44 loc) · 1.43 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
// Copyright (c) 2018, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
package client
import (
"os"
ociargs "github.com/sylabs/singularity/internal/pkg/runtime/engines/oci/rpc"
args "github.com/sylabs/singularity/internal/pkg/runtime/engines/singularity/rpc"
client "github.com/sylabs/singularity/internal/pkg/runtime/engines/singularity/rpc/client"
)
// RPC holds the state necessary for remote procedure calls.
type RPC struct {
client.RPC
}
// MkdirAll calls the mkdir RPC using the supplied arguments.
func (t *RPC) MkdirAll(path string, perm os.FileMode) (int, error) {
arguments := &args.MkdirArgs{
Path: path,
Perm: perm,
}
var reply int
err := t.Client.Call(t.Name+".MkdirAll", arguments, &reply)
return reply, err
}
// Symlink calls the mkdir RPC using the supplied arguments.
func (t *RPC) Symlink(old string, new string) (int, error) {
arguments := &ociargs.SymlinkArgs{
Old: old,
New: new,
}
var reply int
err := t.Client.Call(t.Name+".Symlink", arguments, &reply)
return reply, err
}
// Touch calls the touch RPC using the supplied arguments.
func (t *RPC) Touch(path string) (int, error) {
arguments := &ociargs.TouchArgs{
Path: path,
}
var reply int
err := t.Client.Call(t.Name+".Touch", arguments, &reply)
return reply, err
}