Skip to content
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
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ updates:
interval: "daily"
open-pull-requests-limit: 10
reviewers:
- "onmetal/onmetal-api-maintainers"
- "ironcore-dev/core"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
reviewers:
- "onmetal/onmetal-api-maintainers"
- "ironcore-dev/core"
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
version: v1.55.2
11 changes: 8 additions & 3 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ on:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]
types: [ opened, reopened, synchronize ]

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
with:
disable-releaser: github.ref != 'refs/heads/main'
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 8 additions & 2 deletions .github/workflows/size-label.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: Size Label

on:
pull_request_target:
types: [opened, reopened, synchronize]
pull_request:
types:
- opened
- edited
- synchronize

jobs:
size-label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: size-label
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# onmetal-api maintainers
* @onmetal/onmetal-api-maintainers
# ironcore-dev core maintainers
* @ironcore-dev/core
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Please refer to the [Gardener on Metal code of conduct](https://onmetal.github.io/documentation/contribute/overview/#code-of-conduct).
Please refer to the [IronCore code of conduct](https://ironcore-dev.github.io/documentation/contribute/overview/#code-of-conduct).
55 changes: 40 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.0
ENVTEST_K8S_VERSION = 1.28.0

# 'sample' folder, where you mentioned the `go mod download` should take place
SAMPLE_DIR = sample
Expand Down Expand Up @@ -28,33 +28,35 @@ help: ## Display this help.
##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
fmt: goimports ## Run goimports against code.
$(GOIMPORTS) -w .

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: lint
lint: golangci-lint ## Run golangci-lint on the code.
$(GOLANGCI_LINT) run ./...

.PHONY: test
test: fmt vet envtest checklicense ## Run tests.
test: fmt vet envtest check-license ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

.PHONY: openapi-test
openapi-test: fmt vet envtest checklicense ## Run tests.
openapi-test: fmt vet envtest check-license ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" ./hack/openapi-test.sh

.PHONY: addlicense
addlicense: ## Add license headers to all go files.
find . -name '*.go' -exec go run github.com/google/addlicense -c 'OnMetal authors' {} +

.PHONY: checklicense
checklicense: ## Check that every file has a license header present.
find . -name '*.go' -exec go run github.com/google/addlicense -check -c 'OnMetal authors' {} +
.PHONY: add-license
add-license: addlicense ## Add license headers to all go files.
find . -name '*.go' -exec $(ADDLICENSE) -f hack/license-header.txt {} +

lint: ## Run golangci-lint against code.
golangci-lint run ./...
.PHONY: check-license
check-license: addlicense ## Check that every file has a license header present.
find . -name '*.go' -exec $(ADDLICENSE) -check -c 'IronCore authors' {} +

check: checklicense lint test
.PHONY: check
check: check-license fmt lint test ## Check the codebase. Useful before committing / pushing.

##@ Build

Expand All @@ -75,8 +77,31 @@ $(LOCALBIN):

## Tool Binaries
ENVTEST ?= $(LOCALBIN)/setup-envtest
ADDLICENSE ?= $(LOCALBIN)/addlicense
GOIMPORTS ?= $(LOCALBIN)/goimports
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint

## Tool Versions
ADDLICENSE_VERSION ?= v1.1.1
GOIMPORTS_VERSION ?= v0.14.0
GOLANGCI_LINT_VERSION ?= v1.55.2

.PHONY: addlicense
addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
$(ADDLICENSE): $(LOCALBIN)
test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION)

.PHONY: goimports
goimports: $(GOIMPORTS) ## Download goimports locally if necessary.
$(GOIMPORTS): $(LOCALBIN)
test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: goimports
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# openapi-extractor

[![Test](https://github.com/onmetal/openapi-extractor/actions/workflows/test.yml/badge.svg)](https://github.com/onmetal/openapi-extractor/actions/workflows/test.yml)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
[![GitHub License](https://img.shields.io/static/v1?label=License&message=Apache-2.0&color=blue&style=flat-square)](LICENSE)
[![Test](https://github.com/ironcore-dev/openapi-extractor/actions/workflows/test.yml/badge.svg)](https://github.com/ironcore-dev/openapi-extractor/actions/workflows/test.yml)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)
[![GitHub License](https://img.shields.io/static/v1?label=License&message=Apache-2.0&color=blue)](LICENSE)

The `openapi-extractor` extracts the OpenAPI v2 and v3 specifications of a given Kubernetes API server.

Expand All @@ -13,7 +13,7 @@ The `openapi-extractor` extracts the OpenAPI v2 and v3 specifications of a given
To install the `openapi-extractor` binary into your Go bin path run

```bash
go install github.com/onmetal/openapi-extractor/cmd/openapi-extractor@main
go install github.com/ironcore-dev/openapi-extractor/cmd/openapi-extractor@main
```

## Usage
Expand All @@ -30,10 +30,10 @@ openapi-extractor --apiserver-command=<PATH-TO-APISERVER-BIN> \
### Go module based extraction

The [`sample`](/sample) folder contains an example on how to extract the Open API spec from an api server package. In
our example we are using the [`onmetal-api`](https://github.com/onmetal/onmetal-api) aggregated api server.
our example we are using the [`ironcore`](https://github.com/ironcore-dev/ironcore) aggregated api server.

```shell
openapi-extractor --apiserver-package=github.com/onmetal/onmetal-api/cmd/onmetal-apiserver \
openapi-extractor --apiserver-package=github.com/ironcore-dev/ironcore/cmd/ironcore-apiserver \
--apiserver-build-opts=mod \
--apiservices=<PATH-TO-APISERVICES-DIR>
```
Expand Down
11 changes: 5 additions & 6 deletions cmd/openapi-extractor/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OnMetal authors
// Copyright 2022 IronCore authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,22 +27,21 @@ import (
"time"

"github.com/go-logr/logr"
"github.com/onmetal/controller-utils/buildutils"
"github.com/onmetal/openapi-extractor/envtestutils"
"github.com/onmetal/openapi-extractor/envtestutils/apiserver"
"github.com/ironcore-dev/controller-utils/buildutils"
"github.com/ironcore-dev/openapi-extractor/envtestutils"
"github.com/ironcore-dev/openapi-extractor/envtestutils/apiserver"
flag "github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

_ "k8s.io/client-go/plugin/pkg/client/auth"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions envtestutils/apiserver/apiserver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OnMetal authors
// Copyright 2022 IronCore authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,8 +30,8 @@ import (
"syscall"
"time"

"github.com/onmetal/controller-utils/buildutils"
"github.com/onmetal/openapi-extractor/internal/testing/controlplane"
"github.com/ironcore-dev/controller-utils/buildutils"
"github.com/ironcore-dev/openapi-extractor/internal/testing/controlplane"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest"
Expand Down
2 changes: 1 addition & 1 deletion envtestutils/apiservice.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OnMetal authors
// Copyright 2022 IronCore authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions envtestutils/envtestutils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 OnMetal authors
// Copyright 2021 IronCore authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,9 +24,9 @@ import (
"strings"
"time"

"github.com/onmetal/controller-utils/conditionutils"
"github.com/onmetal/openapi-extractor/internal/testing/addr"
"github.com/onmetal/openapi-extractor/internal/testing/certs"
"github.com/ironcore-dev/controller-utils/conditionutils"
"github.com/ironcore-dev/openapi-extractor/internal/testing/addr"
"github.com/ironcore-dev/openapi-extractor/internal/testing/certs"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -298,7 +298,7 @@ func (o *APIServiceInstallOptions) Stop() error {
return nil
}

const fieldOwner = client.FieldOwner("envtest.onmetal-api.onmetal.de")
const fieldOwner = client.FieldOwner("envtest.ironcore.dev")

func (o *APIServiceInstallOptions) ApplyAPIServices(cfg *rest.Config) error {
ctx := context.TODO()
Expand Down
2 changes: 1 addition & 1 deletion envtestutils/helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OnMetal authors
// Copyright 2022 IronCore authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
11 changes: 4 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module github.com/onmetal/openapi-extractor
module github.com/ironcore-dev/openapi-extractor

go 1.20
go 1.21

require (
github.com/go-logr/logr v1.3.0
github.com/google/addlicense v1.1.1
github.com/onmetal/controller-utils v0.8.3
github.com/ironcore-dev/controller-utils v0.9.0
github.com/onsi/ginkgo/v2 v2.13.1
github.com/onsi/gomega v1.30.0
github.com/spf13/pflag v1.0.5
Expand All @@ -21,7 +20,6 @@ require (

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.0.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
Expand Down Expand Up @@ -58,7 +56,6 @@ require (
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
Expand All @@ -69,7 +66,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/apiextensions-apiserver v0.28.4 // indirect
k8s.io/component-base v0.28.4 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
Expand Down
Loading