Skip to content

Commit

Permalink
feat: inject build stage info into binary & patch some deploy file ch…
Browse files Browse the repository at this point in the history
…ange

Signed-off-by: Huweicai <[email protected]>
  • Loading branch information
Huweicai committed Aug 31, 2022
1 parent cc98cf7 commit 6256c78
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
15 changes: 12 additions & 3 deletions build/build_cfs_csi_driver.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/sh

RootPath=$(cd $(dirname $0) ; pwd)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${RootPath}/bin/cfs-csi-driver ../cmd && echo "build cfs-csi-driver success"

RootPath=$(
cd $(dirname $0)
pwd
)
echo ${RootPath}

CommitID=$(git rev-parse --short=8 HEAD)
Branch=$(git symbolic-ref --short -q HEAD)
BuildTime=$(date +%Y-%m-%dT%H:%M)

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-gcflags=-trimpath=$(pwd) -asmflags=-trimpath=$(pwd) \
-ldflags="-s -w -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime} -X main.Branch=${Branch} " \
-o ${RootPath}/bin/cfs-csi-driver ../cmd && echo "build cfs-csi-driver success"
11 changes: 10 additions & 1 deletion cmd/cubefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
Expand All @@ -34,12 +35,20 @@ var (
conf cubefs.Config
)

// injected while compile
var (
CommitID = ""
BuildTime = ""
Branch = ""
)

func init() {
_ = flag.Set("logtostderr", "true")
}

func main() {
_ = flag.CommandLine.Parse([]string{})
fmt.Printf("System build info: BuildTime: [%s], Branch [%s], CommitID [%s]\n", BuildTime, Branch, CommitID)

cmd := &cobra.Command{
Use: "cfs-csi-driver --endpoint=<endpoint> --nodeid=<nodeid> --drivername=<drivername> --version=<version>",
Short: "CSI based CFS driver",
Expand Down
1 change: 0 additions & 1 deletion deploy/csi-controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ spec:
securityContext:
privileged: true
args:
- --provisioner=csi.cubefs.com
- --csi-address=$(ADDRESS)
env:
- name: TZ
Expand Down
6 changes: 6 additions & 0 deletions deploy/csi-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ rules:
- apiGroups: [ "storage.k8s.io" ]
resources: [ "storageclasses" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "csinodes" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "volumeattachments" ]
verbs: [ "get", "list", "watch", "create", "update", "delete", "patch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "volumeattachments/status" ]
verbs: [ "patch" ]
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
1 change: 0 additions & 1 deletion deploy/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: cfs-sc
namespace: default
provisioner: csi.cubefs.com
allowVolumeExpansion: true
reclaimPolicy: Delete
Expand Down

0 comments on commit 6256c78

Please sign in to comment.