diff --git a/Makefile b/Makefile index 86241f52c..9e4975e6c 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,7 @@ lint: $(GOLANGCI_LINT) ## Lint the code build_code: validate_go lint @go mod vendor go build -ldflags "-X 'main.BuildVersion=$(BUILD_VERSION)' -X 'main.BuildDate=$(BUILD_DATE)'" "${CMD_DIR}${FLP_BIN_FILE}" + go build -ldflags "-X 'main.BuildVersion=$(BUILD_VERSION)' -X 'main.BuildDate=$(BUILD_DATE)'" "${CMD_DIR}${CG_BIN_FILE}" .PHONY: build build: build_code docs ## Build flowlogs-pipeline executable and update the docs diff --git a/cmd/confgenerator/main.go b/cmd/confgenerator/main.go index 51e53873d..d32e00535 100644 --- a/cmd/confgenerator/main.go +++ b/cmd/confgenerator/main.go @@ -33,6 +33,8 @@ import ( ) var ( + BuildVersion string + BuildDate string cfgFile string logLevel string envPrefix = "FLP_CONFGEN" @@ -143,8 +145,9 @@ func main() { } func run() { - // Starting log message - log.Infof("starting %s", filepath.Base(os.Args[0])) + // Initial log message + fmt.Printf("Starting %s:\n=====\nBuild Version: %s\nBuild Date: %s\n\n", + filepath.Base(os.Args[0]), BuildVersion, BuildDate) // Dump the configuration dumpConfig() // creating a new configuration generator diff --git a/cmd/confgenerator/main_test.go b/cmd/confgenerator/main_test.go new file mode 100644 index 000000000..7f58d2eea --- /dev/null +++ b/cmd/confgenerator/main_test.go @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 IBM, Inc. + * + * 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. + * + */ + +package main + +import ( + "os" + "os/exec" + "testing" +) + +func TestTheMain(t *testing.T) { + if os.Getenv("BE_CRASHER") == "1" { + main() + return + } + cmd := exec.Command(os.Args[0], "-test.run=TestTheMain") + cmd.Env = append(os.Environ(), "BE_CRASHER=1") + err := cmd.Run() + if e, ok := err.(*exec.ExitError); ok && !e.Success() { + return + } + t.Fatalf("process ran with err %v, want exit status 1", err) +} diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index b0ebbf8ac..4e5ac1198 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -18,11 +18,14 @@ RUN make build_code # final stage FROM ubuntu -RUN apt-get update -y -RUN apt-get install -y netbase -RUN apt-get install -y curl -RUN apt-get install -y net-tools +RUN apt-get update && apt-get install -y \ + netbase \ + curl \ + net-tools \ + && rm -rf /var/lib/apt/lists/* + COPY --from=builder /app/flowlogs-pipeline /app/ +COPY --from=builder /app/confgenerator /app/ # expose ports EXPOSE 2055 diff --git a/docs/confGenerator.md b/docs/confGenerator.md index 9ad49da64..e9e17c9d7 100644 --- a/docs/confGenerator.md +++ b/docs/confGenerator.md @@ -30,6 +30,9 @@ Flags: ``` +> Note: confgenerator is available also from `netobserv/flowlogs-pipeline` quay image. To use execute: +> `docker run --entrypoint /app/confgenerator quay.io/netobserv/flowlogs-pipeline:latest --help` + > Note: The default location for network definitions in flowlogs-pipeline is `/network_definitions` folder The files and folder structure required as input for `confGenerator` are: