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

✨ Enable webhook authorization options #3198

Merged
merged 6 commits into from
Dec 18, 2024
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
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ GOLANGCI_LINT_VER := v1.62.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

HTTEST_VER := v0.3.2
HTTEST_BIN := httest
HTTEST := $(TOOLS_GOBIN_DIR)/$(HTTEST_BIN)-$(HTTEST_VER)

GOTESTSUM_VER := v1.8.1
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(abspath $(TOOLS_DIR))/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)
Expand Down Expand Up @@ -136,6 +140,9 @@ install: require-jq require-go require-git verify-go-versions ## Install the pro
$(GOLANGCI_LINT):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)

$(HTTEST):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) go.xrstf.de/httest $(HTTEST_BIN) $(HTTEST_VER)

$(LOGCHECK):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/logtools/logcheck $(LOGCHECK_BIN) $(LOGCHECK_VER)

Expand Down Expand Up @@ -183,7 +190,7 @@ vendor: ## Vendor the dependencies
go mod vendor
.PHONY: vendor

tools: $(GOLANGCI_LINT) $(CONTROLLER_GEN) $(KCP_APIGEN_GEN) $(YAML_PATCH) $(GOTESTSUM) $(OPENSHIFT_GOIMPORTS) $(CODE_GENERATOR) ## Install tools
tools: $(GOLANGCI_LINT) $(HTTEST) $(CONTROLLER_GEN) $(KCP_APIGEN_GEN) $(YAML_PATCH) $(GOTESTSUM) $(OPENSHIFT_GOIMPORTS) $(CODE_GENERATOR) ## Install tools
.PHONY: tools

$(CONTROLLER_GEN):
Expand Down Expand Up @@ -269,6 +276,7 @@ endif
ifdef USE_GOTESTSUM
test-e2e: $(GOTESTSUM)
endif
test-e2e: $(HTTEST)
test-e2e: TEST_ARGS ?=
test-e2e: WHAT ?= ./test/e2e...
test-e2e: build-all ## Run e2e tests
Expand All @@ -280,6 +288,7 @@ test-e2e: build-all ## Run e2e tests
ifdef USE_GOTESTSUM
test-e2e-shared-minimal: $(GOTESTSUM)
endif
test-e2e-shared-minimal: $(HTTEST)
test-e2e-shared-minimal: TEST_ARGS ?=
test-e2e-shared-minimal: WHAT ?= ./test/e2e...
test-e2e-shared-minimal: WORK_DIR ?= .
Expand All @@ -305,6 +314,7 @@ test-e2e-shared-minimal: build-all
ifdef USE_GOTESTSUM
test-e2e-sharded-minimal: $(GOTESTSUM)
endif
test-e2e-sharded-minimal: $(HTTEST)
test-e2e-sharded-minimal: TEST_ARGS ?=
test-e2e-sharded-minimal: WHAT ?= ./test/e2e...
test-e2e-sharded-minimal: WORK_DIR ?= .
Expand Down
22 changes: 11 additions & 11 deletions cmd/kcp/kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func main() {
}
}

serverOptions := options.NewOptions(rootDir)
serverOptions.Server.GenericControlPlane.Logs.Verbosity = logsapiv1.VerbosityLevel(2)
kcpOptions := options.NewOptions(rootDir)
mjudeikis marked this conversation as resolved.
Show resolved Hide resolved
kcpOptions.Server.GenericControlPlane.Logs.Verbosity = logsapiv1.VerbosityLevel(2)

startCmd := &cobra.Command{
Use: "start",
Expand All @@ -101,34 +101,34 @@ func main() {
},
RunE: func(cmd *cobra.Command, args []string) error {
// run as early as possible to avoid races later when some components (e.g. grpc) start early using klog
if err := logsapiv1.ValidateAndApply(serverOptions.Server.GenericControlPlane.Logs, kcpfeatures.DefaultFeatureGate); err != nil {
if err := logsapiv1.ValidateAndApply(kcpOptions.Server.GenericControlPlane.Logs, kcpfeatures.DefaultFeatureGate); err != nil {
return err
}

completed, err := serverOptions.Complete()
completedKcpOptions, err := kcpOptions.Complete()
if err != nil {
return err
}

if errs := completed.Validate(); len(errs) > 0 {
if errs := completedKcpOptions.Validate(); len(errs) > 0 {
return errors.NewAggregate(errs)
}

logger := klog.FromContext(cmd.Context())
logger.Info("running with selected batteries", "batteries", strings.Join(completed.Server.Extra.BatteriesIncluded, ","))
logger.Info("running with selected batteries", "batteries", strings.Join(completedKcpOptions.Server.Extra.BatteriesIncluded, ","))

config, err := server.NewConfig(completed.Server)
ctx := genericapiserver.SetupSignalContext()

serverConfig, err := server.NewConfig(ctx, completedKcpOptions.Server)
if err != nil {
return err
}

completedConfig, err := config.Complete()
completedConfig, err := serverConfig.Complete()
if err != nil {
return err
}

ctx := genericapiserver.SetupSignalContext()

// the etcd server must be up before NewServer because storage decorators access it right away
if completedConfig.EmbeddedEtcd.Config != nil {
if err := embeddedetcd.NewServer(completedConfig.EmbeddedEtcd).Run(ctx); err != nil {
Expand All @@ -146,7 +146,7 @@ func main() {

// add start named flag sets to start flags
fss := cliflag.NamedFlagSets{}
serverOptions.AddFlags(&fss)
kcpOptions.AddFlags(&fss)
globalflag.AddGlobalFlags(fss.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags())
startFlags := startCmd.Flags()
for _, f := range fss.FlagSets {
Expand Down
Loading
Loading