go: re-do the entire thing
This is a mega-change, but attempting to split this up further is
probably not worth the effort.
Summary:
1. Bump up bazel, rules_go, and others.
2. Switch to new go target naming (bye bye go_default_library)
3. Move go deps to go.mod/go.sum, use make gazelle generate from that
4. Bump up Python deps a bit
And also whatever was required to actually get things to work - loads of
small useless changes.
Tested to work on NixOS and Ubuntu 20.04:
$ bazel build //...
$ bazel test //...
Change-Id: I8364bdaa1406b9ae4d0385a6b607f3e7989f98a9
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1583
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/cluster/tools/kartongips/utils/client.go b/cluster/tools/kartongips/utils/client.go
index 07cf254..df9bdb8 100644
--- a/cluster/tools/kartongips/utils/client.go
+++ b/cluster/tools/kartongips/utils/client.go
@@ -27,7 +27,7 @@
"sync"
"syscall"
- openapi_v2 "github.com/googleapis/gnostic/openapiv2"
+ openapi_v2 "github.com/google/gnostic/openapiv2"
log "github.com/sirupsen/logrus"
errorsutil "k8s.io/apimachinery/pkg/api/errors"
@@ -38,6 +38,8 @@
"k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
+ openapi_v3 "k8s.io/client-go/openapi"
+ cachedopenapi_v3 "k8s.io/client-go/openapi/cached"
restclient "k8s.io/client-go/rest"
)
@@ -57,7 +59,9 @@
lock sync.RWMutex
groupToServerResources map[string]*cacheEntry
groupList *metav1.APIGroupList
+ openAPISchema *openapi_v2.Document
cacheValid bool
+ openapiV3Client openapi_v3.Client
}
// Error Constants
@@ -124,12 +128,6 @@
return cachedVal.resourceList, cachedVal.err
}
-// ServerResources returns the supported resources for all groups and versions.
-// Deprecated: use ServerGroupsAndResources instead.
-func (d *memcachedDiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error) {
- return discovery.ServerResources(d)
-}
-
// ServerGroupsAndResources returns the groups and supported resources for all groups and versions.
func (d *memcachedDiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
return discovery.ServerGroupsAndResources(d)
@@ -163,7 +161,18 @@
}
func (d *memcachedDiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
- return d.delegate.OpenAPISchema()
+ d.lock.Lock()
+ defer d.lock.Unlock()
+
+ if d.openAPISchema == nil {
+ schema, err := d.delegate.OpenAPISchema()
+ if err != nil {
+ return nil, err
+ }
+ d.openAPISchema = schema
+ }
+
+ return d.openAPISchema, nil
}
func (d *memcachedDiscoveryClient) Fresh() bool {
@@ -183,6 +192,28 @@
d.cacheValid = false
d.groupToServerResources = nil
d.groupList = nil
+ d.openAPISchema = nil
+}
+
+// OpenAPIV3 retrieves and parses the OpenAPIV3 specs exposed by the server
+func (d *memcachedDiscoveryClient) OpenAPIV3() openapi_v3.Client {
+ d.lock.Lock()
+ defer d.lock.Unlock()
+
+ if d.openapiV3Client == nil {
+ // Delegate is discovery client created with special HTTP client which
+ // respects E-Tag cache responses to serve cache from disk.
+ d.openapiV3Client = cachedopenapi_v3.NewClient(d.delegate.OpenAPIV3())
+ }
+
+ return d.openapiV3Client
+}
+
+// taken from: https://github.com/kubernetes/client-go/commit/3ac73ea2c834b1268732024766f1e55a5d0327d2#diff-46edd694bf30a54d9f6e202e010134bedfce438de77f57830155b0762eda7bf6R280-R285
+// WithLegacy returns current cached discovery client;
+// current client does not support legacy-only discovery.
+func (d *memcachedDiscoveryClient) WithLegacy() discovery.DiscoveryInterface {
+ return d
}
// refreshLocked refreshes the state of cache. The caller must hold d.lock for