style&chore: modity Makefile and some code style

1. add .prow.sh
2. add a symlink in Makefile related to release-tools.
3. modify some code style to pass fmt test.

Signed-off-by: Meinhard Zhou <zhouenhua@bytedance.com>
This commit is contained in:
Meinhard Zhou 2022-03-13 17:12:09 +08:00
parent a62f221f93
commit 3e07ae4e60
8 changed files with 43 additions and 25 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.idea/
.vscode/

27
.prow.sh Executable file
View File

@ -0,0 +1,27 @@
#! /bin/bash
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# A Prow job can override these defaults, but this shouldn't be necessary.
# disable e2e tests for now
CSI_PROW_E2E_REPO=none
# Only these tests make sense for unit test
: ${CSI_PROW_TESTS:="unit"}
. release-tools/prow.sh
main

View File

@ -1,5 +1,5 @@
FROM debian:9.13
COPY ./output/nvmfplugin .
COPY ./bin/nvmfplugin .
ENTRYPOINT ["./nvmfplugin"]
ENTRYPOINT ["/nvmfplugin"]

View File

@ -13,18 +13,10 @@
# limitations under the License.
CMDS=nvmfplugin
REV=$(shell git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD)
all: build
build-%:
mkdir -p output
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./output/$* ./cmd/nvmfplugin/$*.go
include release-tools/build.make
container-%: build-%
docker build -t $*:latest -f Dockerfile --label revision=$(REV) .
build: ${CMDS:%=build-%}
container: ${CMDS:%=container-%}
clean:
-rm -rf output/
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin
export GOPATH GOBIN

View File

@ -38,7 +38,7 @@ func NewControllerServer(d *driver) *ControllerServer {
// You should realize your volume provider here, such as requesting the Cloud to create an NVMf block and
// returning specific information to you
func (c *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
return nil, status.Errorf(codes.Unimplemented,"CreateVolume should implement by yourself. ")
return nil, status.Errorf(codes.Unimplemented, "CreateVolume should implement by yourself. ")
}
func (c *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {

View File

@ -44,14 +44,14 @@ func getNVMfDiskMounter(nvmfInfo *nvmfDiskInfo, req *csi.NodePublishVolumeReques
mountOptions := req.GetVolumeCapability().GetMount().GetMountFlags()
return &nvmfDiskMounter{
nvmfDiskInfo : nvmfInfo,
readOnly: readOnly,
fsType: fsType,
nvmfDiskInfo: nvmfInfo,
readOnly: readOnly,
fsType: fsType,
mountOptions: mountOptions,
mounter: &mount.SafeFormatAndMount{Interface: mount.New(""), Exec: exec.New()},
exec: exec.New(),
targetPath: req.GetTargetPath(),
connector: getConnector(nvmfInfo),
mounter: &mount.SafeFormatAndMount{Interface: mount.New(""), Exec: exec.New()},
exec: exec.New(),
targetPath: req.GetTargetPath(),
connector: getConnector(nvmfInfo),
}
}

View File

@ -40,7 +40,7 @@ func AttachDisk(req *csi.NodePublishVolumeRequest, nm nvmfDiskMounter) (string,
return "", fmt.Errorf("Heuristic determination of mount point failed:%v", err)
}
if !notMounted {
klog.Infof("AttachDisk: VolumeID: %s, Path: %s is already mounted, device: %s", req.VolumeId, nm.targetPath)
klog.Infof("AttachDisk: VolumeID: %s, Path: %s is already mounted, device: %s", req.VolumeId, nm.targetPath, nm.DeviceUUID)
return "", nil
}

View File

@ -79,6 +79,4 @@ func ReadLinesFromFile(file *os.File) (lines []string, err error) {
}
}
}
return lines, nil
}