Skip to content

Commit

Permalink
Merge branch 'main' into fix/subtract-previous-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SOF3 committed May 5, 2023
2 parents c803016 + 41da7b9 commit 2de20b6
Show file tree
Hide file tree
Showing 68 changed files with 3,599 additions and 918 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ updates:
directory: /
schedule:
interval: weekly
ignore:
# Minor version upgrades are adopted in longer cycles for stability.
- dependency-name: "k8s.io/*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]
- dependency-name: "sigs.k8s.io/*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ linters-settings:
- pkg: github.com/kubewharf/kubeadmiral/pkg/apis/schedulerwebhook/(?P<s1>v\d+)((?P<s2>\w)\w+(?P<s3>\d+))?
# schedwebhookv1a1
alias: schedwebhook${s1}${s2}${s3}
- pkg: github.com/kubewharf/kubeadmiral/pkg/apis/(?P<group>[\w\d]+)/(?P<s1>v\d+)((?P<s2>\w)\w+(?P<s3>\d+))?
- pkg: github.com/kubewharf/kubeadmiral/pkg/apis/core/(?P<s1>v\d+)((?P<s2>\w)\w+(?P<s3>\d+))?
# fedcorev1a1
alias: fed${group}${s1}${s2}${s3}
alias: fedcore${s1}${s2}${s3}
- pkg: github.com/kubewharf/kubeadmiral/pkg/apis/types/(?P<s1>v\d+)((?P<s2>\w)\w+(?P<s3>\d+))?
# fedtypesv1a1
alias: fedtypes${s1}${s2}${s3}

- pkg: k8s.io/client-go/kubernetes/typed/(?P<group>[\w\d]+)/(?P<s1>v\d+)((?P<s2>\w)\w+(?P<s3>\d+))?
alias: ${group}${s1}${s2}${s3}client
Expand Down
60 changes: 44 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
.PHONY: all generate manager test lint kind e2e
SHELL := /bin/bash

all: manager
BUILD_FLAGS :=
BINARY := manager

# Generate code
.PHONY: all
all: build

# Production build
.PHONY: build
build:
mkdir -p output
go build $(BUILD_FLAGS) -o output/$(BINARY) cmd/controller-manager/main.go

# Debug build
.PHONY: debug
debug: BUILD_FLAGS+=-race
debug: BINARY:=$(BINARY)_debug
debug: build

# Clean built binaries
.PHONY: clean
clean:
rm -r output

# Generate code and artifacts
.PHONY: generate
generate: pkg/client
pkg/client: $(shell find pkg/apis)
bash ./hack/generate-groups.sh
# update the directory mtime to avoid unnecessary re-runs
touch pkg/client

# Build manager binary
manager:
mkdir -p output
go build -o output/manager cmd/controller-manager/main.go

# Run tests
test:
go test -race -coverprofile coverage.out ./pkg/...
LINT_FLAGS := --timeout=5m --max-issues-per-linter=0 --max-same-issues=0 --uniq-by-line=false

# Run golangci-lint
.PHONY: lint
lint:
golangci-lint run
golangci-lint run $(LINT_FLAGS)

# Creates federation using kind
kind: generate
bash ./hack/dev-up.sh
# Run golangci-lint on files changed from the default branch
.PHONY: lint-new
lint-new: LINT_FLAGS += --new-from-rev=main --whole-files
lint-new: lint

# Run tests
.PHONY: test
test:
go test -race -coverprofile coverage0.out ./pkg/...
# exclude generated files from coverage calculation
sed '/generated/d' coverage0.out > coverage.out
rm coverage0.out

# Run e2e tests
.PHONY: e2e
e2e:
ginkgo run -tags=e2e $(EXTRA_GINKGO_FLAGS) test/e2e -- --kubeconfig=$(KUBECONFIG) $(EXTRA_E2E_FLAGS)
ginkgo run -race -tags=e2e $(EXTRA_GINKGO_FLAGS) test/e2e -- --kubeconfig=$(KUBECONFIG) $(EXTRA_E2E_FLAGS)
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -eux

make manager
make build
1 change: 1 addition & 0 deletions cmd/controller-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func startGlobalScheduler(
federatedGVR := schemautil.APIResourceToGVR(&federatedAPIResource)

scheduler, err := scheduler.NewScheduler(
klog.FromContext(ctx),
typeConfig,
controllerCtx.KubeClientset,
controllerCtx.FedClientset,
Expand Down
1 change: 1 addition & 0 deletions cmd/controller-manager/app/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func createControllerContext(opts *options.Options) (*controllercontext.Context,
func getComponentConfig(opts *options.Options) (*controllercontext.ComponentConfig, error) {
componentConfig := &controllercontext.ComponentConfig{
FederatedTypeConfigCreateCRDsForFTCs: opts.CreateCRDsForFTCs,
ClusterJoinTimeout: opts.ClusterJoinTimeout,
}

if opts.NSAutoPropExcludeRegexp != "" {
Expand Down
33 changes: 18 additions & 15 deletions config/crds/core.kubeadmiral.io_clusteroverridepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ spec:
omitted, defaults to "replace".
type: string
path:
description: Path specified the location within the
resource document where the operation is performed.
Each key in the path should be prefixed with "/",
for example, "/metadata/labels".
description: Path is a JSON pointer (RFC 6901) specifying
the location within the resource document where
the operation is performed. Each key in the path
should be prefixed with "/", while "~" and "/" should
be escaped as "~0" and "~1" respectively. For example,
to add a label "kubeadmiral.io/label", the path
should be "/metadata/labels/kubeadmiral.io~1label".
type: string
value:
description: Value is the value(s) required by the
Expand All @@ -77,9 +80,9 @@ spec:
of all of them.
properties:
clusterAffinity:
description: ClusterAffinity selects clusters by matching
their labels and fields against expressions. If multiple
terms are specified, their results are ORed.
description: ClusterAffinity selects FederatedClusters by
matching their labels and fields against expressions.
If multiple terms are specified, their results are ORed.
items:
properties:
matchExpressions:
Expand Down Expand Up @@ -148,18 +151,18 @@ spec:
type: array
type: object
type: array
clusterNames:
description: ClusterNames selects clusters by their names.
Empty ClusterNames selects all clusters.
items:
type: string
type: array
clusterSelector:
additionalProperties:
type: string
description: ClusterSelector selects clusters by their labels.
Empty labels selects all clusters.
description: ClusterSelector selects FederatedClusters by
their labels. Empty labels selects all FederatedClusters.
type: object
clusters:
description: Clusters selects FederatedClusters by their
names. Empty Clusters selects all FederatedClusters.
items:
type: string
type: array
type: object
type: object
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ spec:
items:
description: Placement describes a cluster that a federated object can be propagated to and its propagation preferences.
properties:
clusterName:
description: ClusterName is the name of the cluster to propgate to.
cluster:
description: Cluster is the name of the FederatedCluster to propagate to.
type: string
preferences:
description: Preferences contains the cluster's propagation preferences.
Expand All @@ -155,7 +155,7 @@ spec:
type: integer
type: object
required:
- clusterName
- cluster
type: object
type: array
replicaRescheduling:
Expand Down
33 changes: 18 additions & 15 deletions config/crds/core.kubeadmiral.io_overridepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ spec:
omitted, defaults to "replace".
type: string
path:
description: Path specified the location within the
resource document where the operation is performed.
Each key in the path should be prefixed with "/",
for example, "/metadata/labels".
description: Path is a JSON pointer (RFC 6901) specifying
the location within the resource document where
the operation is performed. Each key in the path
should be prefixed with "/", while "~" and "/" should
be escaped as "~0" and "~1" respectively. For example,
to add a label "kubeadmiral.io/label", the path
should be "/metadata/labels/kubeadmiral.io~1label".
type: string
value:
description: Value is the value(s) required by the
Expand All @@ -77,9 +80,9 @@ spec:
of all of them.
properties:
clusterAffinity:
description: ClusterAffinity selects clusters by matching
their labels and fields against expressions. If multiple
terms are specified, their results are ORed.
description: ClusterAffinity selects FederatedClusters by
matching their labels and fields against expressions.
If multiple terms are specified, their results are ORed.
items:
properties:
matchExpressions:
Expand Down Expand Up @@ -148,18 +151,18 @@ spec:
type: array
type: object
type: array
clusterNames:
description: ClusterNames selects clusters by their names.
Empty ClusterNames selects all clusters.
items:
type: string
type: array
clusterSelector:
additionalProperties:
type: string
description: ClusterSelector selects clusters by their labels.
Empty labels selects all clusters.
description: ClusterSelector selects FederatedClusters by
their labels. Empty labels selects all FederatedClusters.
type: object
clusters:
description: Clusters selects FederatedClusters by their
names. Empty Clusters selects all FederatedClusters.
items:
type: string
type: array
type: object
type: object
type: array
Expand Down
6 changes: 3 additions & 3 deletions config/crds/core.kubeadmiral.io_propagationpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ spec:
items:
description: Placement describes a cluster that a federated object can be propagated to and its propagation preferences.
properties:
clusterName:
description: ClusterName is the name of the cluster to propgate to.
cluster:
description: Cluster is the name of the FederatedCluster to propagate to.
type: string
preferences:
description: Preferences contains the cluster's propagation preferences.
Expand All @@ -155,7 +155,7 @@ spec:
type: integer
type: object
required:
- clusterName
- cluster
type: object
type: array
replicaRescheduling:
Expand Down
Loading

0 comments on commit 2de20b6

Please sign in to comment.