Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# local build dir
build

# go coverage data
profile.cov

Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ install:
- pip install --user yamllint

script:
# Lint text-like files
- scripts/lint-text.sh --require-all
# Build container w/ Docker
- ./build.sh
9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

# Set driver name
DRIVER="${DRIVER:-glusterfs-csi-driver}"
DRIVER="${DRIVER:-glusterfs}"

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

#-- Build container
$RUNTIME_CMD $build \
-t "${REPO}${DRIVER}" \
-t "${REPO}${DRIVER}-csi-driver" \
--build-arg DRIVER="$DRIVER" \
"${build_args[@]}" \
-f pkg/glusterfs/Dockerfile \
-f extras/Dockerfile \
. \
|| exit 1

# If running tests, extract profile data
if [ "$RUN_TESTS" -ne 0 ]; then
rm -f profile.cov
$RUNTIME_CMD run --entrypoint cat "${REPO}${DRIVER}" \
$RUNTIME_CMD run --entrypoint cat "${REPO}${DRIVER}-csi-driver" \
/profile.cov > profile.cov
fi
57 changes: 14 additions & 43 deletions cmd/glusterfs/main.go
Original file line number Diff line number Diff line change
@@ -1,62 +1,33 @@
package main

import (
"flag"
"fmt"
"os"

gfd "github.com/gluster/gluster-csi-driver/pkg/glusterfs"
"github.com/gluster/gluster-csi-driver/pkg/glusterfs/utils"
"github.com/gluster/gluster-csi-driver/pkg/command"
"github.com/gluster/gluster-csi-driver/pkg/glusterfs"
)

"github.com/spf13/cobra"
// Driver Identifiers
const (
cmdName = "glusterfs-csi-driver"
CSIDriverDesc = "GlusterFS CSI Driver"
CSIDriverName = "org.gluster.glusterfs"
CSIDriverVersion = "0.0.9"
)

func init() {
// #nosec
_ = flag.Set("logtostderr", "true")
command.Init()
}

func main() {
// #nosec
_ = flag.CommandLine.Parse([]string{})
var config = utils.NewConfig()

cmd := &cobra.Command{
Use: "glusterfs-csi-driver",
Short: "GlusterFS CSI driver",
Run: func(cmd *cobra.Command, args []string) {
handle(config)
},
}

cmd.Flags().AddGoFlagSet(flag.CommandLine)

cmd.PersistentFlags().StringVar(&config.NodeID, "nodeid", "", "CSI node id")
// #nosec
_ = cmd.MarkPersistentFlagRequired("nodeid")

cmd.PersistentFlags().StringVar(&config.Endpoint, "endpoint", "", "CSI endpoint")

cmd.PersistentFlags().StringVar(&config.RestURL, "resturl", "", "glusterd2 rest endpoint")

cmd.PersistentFlags().StringVar(&config.RestUser, "username", "glustercli", "glusterd2 user name")
var config = command.NewConfig(cmdName, CSIDriverName, CSIDriverVersion, CSIDriverDesc)

cmd.PersistentFlags().StringVar(&config.RestSecret, "restsecret", "", "glusterd2 rest user secret")

if err := cmd.Execute(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%s", err.Error())
os.Exit(1)
}
}

func handle(config *utils.Config) {
if config.Endpoint == "" {
config.Endpoint = os.Getenv("CSI_ENDPOINT")
}
d := gfd.New(config)
d := glusterfs.New(config, nil)
if d == nil {
fmt.Println("Failed to initialize GlusterFS CSI driver")
os.Exit(1)
}
d.Run()

command.Run(config, d)
}
Loading