Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmd init #25

Merged
merged 2 commits into from
Aug 19, 2022
Merged
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
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

# General Project parameters
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

# Image related parameters, used when building image
IMAGE_REPOSITORY ?= nvidia.com
IMAGE_NAME ?= multi-networkpolicy-tc
Expand All @@ -11,12 +20,6 @@ else
GOBIN=$(shell go env GOBIN)
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

TARGET_OS ?= $(shell go env GOOS)
TARGET_ARCH ?= $(shell go env GOARCH)

Expand All @@ -27,7 +30,6 @@ GO_BIN_SUFFIX ?= $(TARGET_OS)-$(TARGET_ARCH)

all: build


##@ General

# The help target prints out all targets with their descriptions organized
Expand All @@ -54,7 +56,6 @@ unit-test: ## Run unit tests.

test: lint unit-test ## Run all tests (lint, unit-test).


##@ Build
.PHONY: build
build: ## Build multi-networkpolicy-tc binary.
Expand Down Expand Up @@ -97,8 +98,13 @@ MOCKERY = $(shell pwd)/bin/mockery
mockery: ## Download mockery if necessary.
$(call go-install-tool,$(MOCKERY),github.com/vektra/mockery/[email protected])

.PHONY: clean
clean:
@rm -rf build
@rm -rf bin


# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
Expand Down
9 changes: 5 additions & 4 deletions cmd/multi-networkpolicy-tc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ func main() {
initLogs(ctx)
defer klog.Flush()
opts := server.NewOptions()
srv, err := server.NewServer(opts)
if err != nil {
klog.Exit(err)
}

cmd := &cobra.Command{
Use: "multi-networkpolicy-tc",
Long: `TBD`,
Run: func(cmd *cobra.Command, args []string) {
srv, err := server.NewServer(opts)
if err != nil {
klog.Exit(err)
}

srv.Run(ctx)
},
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func (s *Server) Run(ctx context.Context) {
go s.SyncLoop(ctx)

s.birthCry()

// wait on Context
<-ctx.Done()
}

// setInitialized sets s.initialized to 1 if value is true. the set operation is atomic
Expand Down