Skip to content

Commit

Permalink
Fix version reported by scope
Browse files Browse the repository at this point in the history
  • Loading branch information
noboruma committed Dec 5, 2023
1 parent bf69a5a commit ba294bd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bootstrap-agent-plugins:
.PHONY: agent
agent: go1_20_builder debian_builder deepfenced console_plugins
(cd $(DEEPFENCE_AGENT_DIR) &&\
IMAGE_REPOSITORY="$(IMAGE_REPOSITORY)" DF_IMG_TAG="$(DF_IMG_TAG)" bash build.sh)
IMAGE_REPOSITORY="$(IMAGE_REPOSITORY)" DF_IMG_TAG="$(DF_IMG_TAG)" VERSION="$(VERSION)" bash build.sh)

.PHONY: deepfenced
deepfenced: alpine_builder bootstrap bootstrap-agent-plugins
Expand Down
3 changes: 2 additions & 1 deletion deepfence_agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

GOFLAGS += --ldflags
GOFLAGS += '-extldflags "-static"'
VERSION?=v`git rev-parse --short HEAD`

LN = ln
MKDIR = mkdir
Expand All @@ -41,7 +42,7 @@ agent: tools/apache/scope/vendor
env GOGC=off \
CGO_ENABLED=1 \
go build -buildvcs=false \
-ldflags "-X main.version=$GIT_COMMIT -X main.version=$(shell git rev-parse --short HEAD) -X github.com/weaveworks/scope/probe/host.agentCommitID=$(shell git rev-parse --short HEAD) -X github.com/weaveworks/scope/probe/host.agentBuildTime=$(shell date +"%s%d%m%y") -s -w -extldflags=-static"\
-ldflags "-X main.version=${VERSION} -X github.com/weaveworks/scope/probe/host.agentCommitID=${VERSION} -X github.com/weaveworks/scope/probe/host.agentBuildTime=$(shell date +"%s%d%m%y") -s -w -extldflags=-static"\
-tags 'netgo osusergo unsafe' \
-o docker/deepfence_exe \
./prog)
Expand Down
2 changes: 1 addition & 1 deletion deepfence_agent/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ building_image(){
fi

echo "Building Agent Executable"
docker run --rm --workdir /go/src/github.com/deepfence/deepfence_agent -v $(pwd)/../golang_deepfence_sdk:/go/src/github.com/deepfence/golang_deepfence_sdk -v $(pwd)/../deepfence_utils:/go/src/github.com/deepfence/deepfence_utils -v $(pwd):/go/src/github.com/deepfence/deepfence_agent:rw --net=host -e GIT_COMMIT="$GIT_COMMIT" $IMAGE_REPOSITORY/deepfence_builder_ce:$DF_IMG_TAG bash -x /home/deepfence/agent-build.sh
docker run --rm --workdir /go/src/github.com/deepfence/deepfence_agent -v $(pwd)/../golang_deepfence_sdk:/go/src/github.com/deepfence/golang_deepfence_sdk -v $(pwd)/../deepfence_utils:/go/src/github.com/deepfence/deepfence_utils -v $(pwd):/go/src/github.com/deepfence/deepfence_agent:rw --net=host -e VERSION=${VERSION} $IMAGE_REPOSITORY/deepfence_builder_ce:$DF_IMG_TAG bash -c "make agent"
build_result=$?
if [ $build_result -ne 0 ]
then
Expand Down
2 changes: 1 addition & 1 deletion deepfence_agent/plugins/YaraHunter
2 changes: 1 addition & 1 deletion deepfence_agent/tools/apache/scope/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ require (
golang.org/x/sys v0.12.0
golang.org/x/time v0.1.0
google.golang.org/grpc v1.56.1
google.golang.org/protobuf v1.30.0
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
Expand Down Expand Up @@ -128,7 +129,6 @@ require (
golang.org/x/tools v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
3 changes: 1 addition & 2 deletions deepfence_agent/tools/apache/scope/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,7 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
Expand Down
5 changes: 2 additions & 3 deletions deepfence_agent/tools/apache/scope/probe/host/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

// Agent version to display in metadata
var (
AgentVersionNo = "v2.0.1"
agentCommitID = "Unknown"
agentBuildTime = "0"
DockerSocketPath = os.Getenv("DOCKER_SOCKET_PATH")
Expand Down Expand Up @@ -236,7 +235,7 @@ func NewReporter(hostName, probeID, version string) (*Reporter, string, string)
k8sClusterName: os.Getenv(report.KubernetesClusterName),
OSVersion: runtime.GOOS,
KernelVersion: kernel,
AgentVersion: AgentVersionNo + "-" + agentCommitID + "-" + agentBuildTime,
AgentVersion: agentCommitID + "-" + agentBuildTime,
IsConsoleVm: isConsoleVm,
hostDetailsMinute: HostDetailsEveryMinute{},
}
Expand Down Expand Up @@ -379,7 +378,7 @@ func (r *Reporter) Report() (report.Report, error) {
InterfaceNames: interfaceNames,
InterfaceIps: interfaceIPs,
InterfaceIpMap: interfaceIPMap,
Version: r.AgentVersion,
Version: r.version,
IsConsoleVm: r.IsConsoleVm,
AgentRunning: true,
LocalCIDRs: localCIDRs,
Expand Down

0 comments on commit ba294bd

Please sign in to comment.