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

Implement /ext in Steve for Imperative API #287

Merged
merged 58 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8d3ebf9
Checkpoint
tomleb Sep 25, 2024
470a33d
Starting work on authentication
tomleb Sep 26, 2024
98b51e7
Enforce authentication
tomleb Sep 26, 2024
13e5710
Add authentication
tomleb Sep 27, 2024
3fcdd43
Checkpoint authz and /ext
tomleb Sep 27, 2024
2c3d8da
Use own Context type
tomleb Sep 27, 2024
8aad8de
Convert metainternalversion.ListOptions to metav1.ListOptions
tomleb Sep 30, 2024
d7993ea
Reorganize tests
tomleb Sep 30, 2024
6ab6a3a
Add authorization tests
tomleb Sep 30, 2024
0102237
Update go.mod
tomleb Oct 2, 2024
517f58a
Update openapi for TestType
tomleb Oct 2, 2024
10ec99a
Update to k8s.io v1.31
tomleb Oct 2, 2024
99af3ff
Add GroupVersionResource to Context
tomleb Oct 2, 2024
518ff6d
Figured out *Validation things and support create on update
tomleb Oct 2, 2024
70e1230
Add more authorization tests
tomleb Oct 2, 2024
dc7394b
Fix cleanup test code
tomleb Oct 2, 2024
e4eef2a
Add mutex for handler
tomleb Oct 2, 2024
b814df4
Move away from DerefT and DerefTList
tomleb Oct 2, 2024
5719b68
Remove global scheme
tomleb Oct 3, 2024
615bbc0
Move tests fixtures to fixtures_test.go
tomleb Oct 3, 2024
6def090
Move type assertions to tests, clarify namespaced store comment
tomleb Oct 3, 2024
2145f1c
Handle nil ExtensionAPIServer
tomleb Oct 3, 2024
0ed77a7
Document the store
tomleb Oct 3, 2024
97c8eda
Remove hasUser method used only in tests
tomleb Oct 3, 2024
0bce8fc
Add Deny reason for AccessStore authorizer
tomleb Oct 3, 2024
f525d17
Use single authenticator with chain via UnionAuthenticator
tomleb Oct 4, 2024
c9ab659
Rename Authorization to Authorizer
tomleb Oct 4, 2024
6dcdd75
Clarify Destroy's function
tomleb Oct 4, 2024
2afd400
Remove wrangler local replace directive
tomleb Oct 4, 2024
2e75296
Rename BuiltinAuthenticator to DefaultAuthenticator
tomleb Oct 7, 2024
bea909f
Ensure TList is a list
tomleb Oct 8, 2024
b3f295a
Use Listener instead of BindPort
tomleb Oct 8, 2024
06edba5
Add comment on empty string reason
tomleb Oct 9, 2024
1fb4d0b
Add comment on empty DiscoveryAddresses
tomleb Oct 9, 2024
dbf5cdc
Add comment on ExtensionAPIServer
tomleb Oct 9, 2024
22d138e
Add more comments
tomleb Oct 9, 2024
67f7826
Add test for multiple stores
tomleb Oct 9, 2024
af88132
Remove unused Client field
tomleb Oct 9, 2024
fadbff8
Add validation for opts.Listener
tomleb Oct 9, 2024
7d1e38d
go mod update
tomleb Oct 9, 2024
4ce369e
Split PR into two parts
tomleb Oct 9, 2024
485746b
Use interface for ExtensionAPIServer
tomleb Oct 9, 2024
2cb27b6
Add nolint:misspell for golangci-lint
tomleb Oct 9, 2024
0779e52
Install envtest in CI
tomleb Oct 9, 2024
2980c8e
Add tests for Stores
tomleb Oct 9, 2024
ec3b8c9
Add how to read tests in README
tomleb Oct 10, 2024
d7509cf
Add comments on ExtensionAPIServer
tomleb Oct 10, 2024
acf722e
Remove unsafe casts
tomleb Oct 10, 2024
819972c
Return true on Update that created the object
tomleb Oct 10, 2024
ecebb4f
Fix watch bugs and add watch tests
tomleb Oct 11, 2024
b93cbce
Add test without any store
tomleb Oct 11, 2024
400534a
Set EffectiveVersion due to v1.31 bump
tomleb Oct 11, 2024
202e066
Update comments
tomleb Oct 11, 2024
b967f3a
Fix flaky test
tomleb Oct 11, 2024
d9baa92
Only use the Suite when necessary
tomleb Oct 11, 2024
09433a5
Fix rebase shenanigans
tomleb Oct 11, 2024
5c6fc92
Fix comment
tomleb Oct 11, 2024
4f720d1
Fix more comments
tomleb Oct 11, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
with:
version: v1.59.0
- name: Install env-test
tomleb marked this conversation as resolved.
Show resolved Hide resolved
run: go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
- name: Build
run: make build-bin
- name: Test
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,21 @@ Integration tests for the steve API are located among the [rancher integration
tests](ihttps://github.com/rancher/rancher/tree/release/v2.8/tests/v2/integration/steveapi).
See the documentation included there for running the tests and using them to
generate API documentation.

## Running Tests

Some of steve's tests make use of [envtest](https://book.kubebuilder.io/reference/envtest) to run. Envtest allows tests to run against a "fake" kubernetes server with little/no overhead.

To install the required `setup-envtest` binary, use the following command:

```bash
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
```

Before running the tests, you must run the following command to setup the fake server:

```bash
# note that this will use a new/latest version of k8s. Our CI will run against the version of k8s that corresponds to steve's
# current client-go version, as seen in scripts/test.sh
export KUBEBUILDER_ASSETS=$(setup-envtest use -p path)
```
23 changes: 23 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,27 @@ require (
k8s.io/klog v1.0.0
k8s.io/kube-aggregator v0.31.1
k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3
sigs.k8s.io/controller-runtime v0.19.0
)

require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -61,13 +69,17 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -83,9 +95,15 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
go.etcd.io/etcd/client/v3 v3.5.14 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
Expand All @@ -94,7 +112,10 @@ require (
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.23.0 // indirect
Expand All @@ -107,9 +128,11 @@ require (
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kms v0.31.1 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.49.3 // indirect
Expand Down
Loading
Loading