Skip to content

Commit 6a839f5

Browse files
committed
Split role and client libraries
Signed-off-by: Jose A. Rivera <[email protected]>
1 parent 3c0bb7b commit 6a839f5

File tree

25 files changed

+1820
-1457
lines changed

25 files changed

+1820
-1457
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# local build dir
2+
build
3+
14
# go coverage data
25
profile.cov
36

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ install:
1515
- pip install --user yamllint
1616

1717
script:
18-
# Lint text-like files
19-
- scripts/lint-text.sh --require-all
2018
# Build container w/ Docker
2119
- ./build.sh

build.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
# Set driver name
6-
DRIVER="${DRIVER:-glusterfs-csi-driver}"
6+
DRIVER="${DRIVER:-glusterfs}"
77

88
# Set which docker repo to tag
99
REPO="${REPO:-gluster/}"
@@ -40,15 +40,16 @@ $RUNTIME_CMD version
4040

4141
#-- Build container
4242
$RUNTIME_CMD $build \
43-
-t "${REPO}${DRIVER}" \
43+
-t "${REPO}${DRIVER}-csi-driver" \
44+
--build-arg DRIVER="$DRIVER" \
4445
"${build_args[@]}" \
45-
-f pkg/glusterfs/Dockerfile \
46+
-f extras/Dockerfile \
4647
. \
4748
|| exit 1
4849

4950
# If running tests, extract profile data
5051
if [ "$RUN_TESTS" -ne 0 ]; then
5152
rm -f profile.cov
52-
$RUNTIME_CMD run --entrypoint cat "${REPO}${DRIVER}" \
53+
$RUNTIME_CMD run --entrypoint cat "${REPO}${DRIVER}-csi-driver" \
5354
/profile.cov > profile.cov
5455
fi

cmd/glusterfs/main.go

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,33 @@
11
package main
22

33
import (
4-
"flag"
54
"fmt"
65
"os"
76

8-
gfd "github.com/gluster/gluster-csi-driver/pkg/glusterfs"
9-
"github.com/gluster/gluster-csi-driver/pkg/glusterfs/utils"
7+
"github.com/gluster/gluster-csi-driver/pkg/command"
8+
"github.com/gluster/gluster-csi-driver/pkg/glusterfs"
9+
)
1010

11-
"github.com/spf13/cobra"
11+
// Driver Identifiers
12+
const (
13+
cmdName = "glusterfs-csi-driver"
14+
CSIDriverDesc = "GlusterFS CSI Driver"
15+
CSIDriverName = "org.gluster.glusterfs"
16+
CSIDriverVersion = "0.0.9"
1217
)
1318

1419
func init() {
15-
// #nosec
16-
_ = flag.Set("logtostderr", "true")
20+
command.Init()
1721
}
1822

1923
func main() {
20-
// #nosec
21-
_ = flag.CommandLine.Parse([]string{})
22-
var config = utils.NewConfig()
23-
24-
cmd := &cobra.Command{
25-
Use: "glusterfs-csi-driver",
26-
Short: "GlusterFS CSI driver",
27-
Run: func(cmd *cobra.Command, args []string) {
28-
handle(config)
29-
},
30-
}
31-
32-
cmd.Flags().AddGoFlagSet(flag.CommandLine)
33-
34-
cmd.PersistentFlags().StringVar(&config.NodeID, "nodeid", "", "CSI node id")
35-
// #nosec
36-
_ = cmd.MarkPersistentFlagRequired("nodeid")
37-
38-
cmd.PersistentFlags().StringVar(&config.Endpoint, "endpoint", "", "CSI endpoint")
39-
40-
cmd.PersistentFlags().StringVar(&config.RestURL, "resturl", "", "glusterd2 rest endpoint")
41-
42-
cmd.PersistentFlags().StringVar(&config.RestUser, "username", "glustercli", "glusterd2 user name")
24+
var config = command.NewConfig(cmdName, CSIDriverName, CSIDriverVersion, CSIDriverDesc)
4325

44-
cmd.PersistentFlags().StringVar(&config.RestSecret, "restsecret", "", "glusterd2 rest user secret")
45-
46-
if err := cmd.Execute(); err != nil {
47-
_, _ = fmt.Fprintf(os.Stderr, "%s", err.Error())
48-
os.Exit(1)
49-
}
50-
}
51-
52-
func handle(config *utils.Config) {
53-
if config.Endpoint == "" {
54-
config.Endpoint = os.Getenv("CSI_ENDPOINT")
55-
}
56-
d := gfd.New(config)
26+
d := glusterfs.New(config, nil)
5727
if d == nil {
5828
fmt.Println("Failed to initialize GlusterFS CSI driver")
5929
os.Exit(1)
6030
}
61-
d.Run()
31+
32+
command.Run(config, d)
6233
}

0 commit comments

Comments
 (0)