Skip to content

Commit

Permalink
Fix presubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
CatherineF-dev committed Jul 9, 2023
1 parent 959ab87 commit c2f9fee
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +k8s:defaulter-gen=TypeMeta
// +groupName=customresource.ksm.io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
Expand All @@ -7,6 +23,7 @@ import (
)

const (
// GroupName is the group name for CustomResourceMonitor
// TODO(): change ksm.io to another name
GroupName = "customresource.ksm.io"
)
Expand All @@ -20,9 +37,10 @@ func Resource(resource string) schema.GroupResource {
}

var (
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
SchemeBuilder runtime.SchemeBuilder
// localSchemeBuilder = &SchemeBuilder

// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/kube-state-metrics/v2/pkg/customresourcestate"
)

const (
// CustomResourceMonitorKind is Kind of CustomResourceMonitor
CustomResourceMonitorKind = "CustomResourceMonitor"
// CustomResourceMonitorName is plural Name of CustomResourceMonitor
CustomResourceMonitorName = "customresourcemonitors"
)

Expand All @@ -21,7 +40,7 @@ type CustomResourceMonitor struct {
customresourcestate.Metrics `json:",inline"`
}

// PodMonitorList is a list of PodMonitors.
// CustomResourceMonitorList is a list of CustomResourceMonitors.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type CustomResourceMonitorList struct {
metav1.TypeMeta `json:",inline"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/customresourcestate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func FromConfig(decoder ConfigDecoder, discovererInstance GVKToGVKP) (func() ([]
return fn, nil
}

// FromConfig decodes a configuration source into a slice of customresource.RegistryFactory that are ready to use.
// FromConfig2 decodes a configuration source into a slice of customresource.RegistryFactory that are ready to use.
func FromConfig2(decoder ConfigDecoder) ([]customresource.RegistryFactory, error) {
var crconfig Metrics
var factories []customresource.RegistryFactory
Expand Down
2 changes: 0 additions & 2 deletions pkg/customresourcestate/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/metricshandler/metrics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ import (
"k8s.io/kube-state-metrics/v2/pkg/options"
)

// Reconfigure provides two functions
type Reconfigure interface {
// ResolveCustomResourceConfig update custom resource stores
ResolveCustomResourceConfig(opts *options.Options) (customresourcestate.ConfigDecoder, error)
// FromConfig construct customresource.RegistryFactory from ConfigDecoder
FromConfig(decoder customresourcestate.ConfigDecoder) ([]customresource.RegistryFactory, error)
}

Expand All @@ -74,6 +77,7 @@ type MetricsHandler struct {

// New creates and returns a new MetricsHandler with the given options.
func New(opts *options.Options, kubeClient kubernetes.Interface, crMonitorClient crmonitorclientset.Interface, storeBuilder ksmtypes.BuilderInterface, enableGZIPEncoding bool, reconfigure Reconfigure) *MetricsHandler {

return &MetricsHandler{
opts: opts,
kubeClient: kubeClient,
Expand Down Expand Up @@ -105,6 +109,7 @@ func (m *MetricsHandler) ConfigureSharding(ctx context.Context, shard int32, tot
m.curTotalShards = totalShards
}

// ReconfigureCustomResourceMetrics reconfigures customresource stores.
func (m *MetricsHandler) ReconfigureCustomResourceMetrics(ctx context.Context, opts *options.Options) error {
m.mtx.Lock()
defer m.mtx.Unlock()
Expand Down
2 changes: 2 additions & 0 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (
"flag"
"fmt"
"os"

// "path/filepath"
"strings"

"github.com/prometheus/common/version"
"github.com/spf13/cobra"

/* "gopkg.in/yaml.v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd" */
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"k8s.io/klog/v2"

"k8s.io/kube-state-metrics/v2/internal"
"k8s.io/kube-state-metrics/v2/pkg/customresourcestate"
"k8s.io/kube-state-metrics/v2/pkg/options"
)

Expand Down

This file was deleted.

0 comments on commit c2f9fee

Please sign in to comment.