-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Asklv <boironic@gmail.com>
- Loading branch information
Showing
12 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
pkg/apiserver/registry/controlplane/nodelatencystat/rest.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2024 Antrea 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 nodelatencystat | ||
|
||
// import ( | ||
// "context" | ||
|
||
// "antrea.io/antrea/pkg/apis/controlplane" | ||
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
// v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
// "k8s.io/apimachinery/pkg/runtime" | ||
// "k8s.io/apiserver/pkg/registry/rest" | ||
// ) | ||
|
||
// // nodeLatencyCollector is the interface required by the handler. | ||
// type nodeLatencyCollector interface { | ||
// Collect(summary *controlplane.NodeIPLatencyStat) | ||
// Get(name string) *controlplane.NodeIPLatencyStat | ||
// List() []*controlplane.NodeIPLatencyStat | ||
// } | ||
|
||
// type REST struct { | ||
// nodeLatencyCollector nodeLatencyCollector | ||
// } | ||
|
||
// var ( | ||
// _ rest.Scoper = &REST{} | ||
// _ rest.Getter = &REST{} | ||
// _ rest.SingularNameProvider = &REST{} | ||
// _ rest.Creater = &REST{} | ||
// ) | ||
|
||
// // NewREST returns a REST object that will work against API services. | ||
// func NewREST(c nodeLatencyCollector) *REST { | ||
// return &REST{c} | ||
// } | ||
|
||
// func (r *REST) New() runtime.Object { | ||
// return &controlplane.NodeIPLatencyStat{} | ||
// } | ||
|
||
// func (r *REST) Destroy() { | ||
// } | ||
|
||
// func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *v1.CreateOptions) (runtime.Object, error) { | ||
// // Try to store the NodeIPLatencyStat in the store. | ||
// summary := obj.(*controlplane.NodeIPLatencyStat) | ||
// r.nodeLatencyCollector.Collect(summary) | ||
// // a valid runtime.Object must be returned, otherwise the client would throw error. | ||
// return &controlplane.NodeIPLatencyStat{}, nil | ||
// } | ||
|
||
// func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { | ||
// // Try to retrieve the NodeIPLatencyStat from the store. | ||
// entry := r.nodeLatencyCollector.Get(name) | ||
// return entry, nil | ||
// } | ||
|
||
// func (r *REST) NamespaceScoped() bool { | ||
// return false | ||
// } | ||
|
||
// func (r *REST) GetSingularName() string { | ||
// return "nodeiplatencystat" | ||
// } |
59 changes: 59 additions & 0 deletions
59
pkg/apiserver/registry/controlplane/nodelatencystat/rest_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2024 Antrea 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 nodelatencystat | ||
|
||
// import ( | ||
// "context" | ||
// "testing" | ||
|
||
// "github.com/stretchr/testify/assert" | ||
// v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// "antrea.io/antrea/pkg/apis/controlplane" | ||
// ) | ||
|
||
// func TestREST(t *testing.T) { | ||
// r := NewREST(nil) | ||
// assert.Equal(t, &controlplane.NodeIPLatencyStat{}, r.New()) | ||
// assert.False(t, r.NamespaceScoped()) | ||
// } | ||
|
||
// type fakeCollector struct { | ||
// gotSummary *controlplane.NodeIPLatencyStat | ||
// } | ||
|
||
// func (f *fakeCollector) Collect(summary *controlplane.NodeIPLatencyStat) { | ||
// f.gotSummary = summary | ||
// } | ||
|
||
// func (f *fakeCollector) Get(name string) (*controlplane.NodeIPLatencyStat, error) { | ||
// return nil, nil | ||
// } | ||
|
||
// func TestRESTCreate(t *testing.T) { | ||
// collector := &fakeCollector{} | ||
// r := NewREST(collector) | ||
|
||
// summary := &controlplane.NodeIPLatencyStat{ | ||
// ObjectMeta: v1.ObjectMeta{ | ||
// Name: "foo", | ||
// }, | ||
// } | ||
// actualObj, err := r.Create(context.TODO(), summary, nil, &v1.CreateOptions{}) | ||
// assert.NoError(t, err) | ||
// // Empty struct is returned on success. | ||
// assert.Equal(t, &controlplane.NodeIPLatencyStat{}, actualObj) | ||
// assert.Equal(t, summary, collector.gotSummary) | ||
// } |