chore: update copyright headers (#6496)
Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
url "net/url"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// refer to https://github.com/kubernetes/kubernetes/issues/94688
|
||||
// conversions must be registered.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodLogOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodLogOptions(a.(*url.Values), b.(*v1.PodLogOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v1_PodLogOptions(in *url.Values, out *v1.PodLogOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["container"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Container, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Container = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["follow"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Follow, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Follow = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["previous"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Previous, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Previous = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["sinceSeconds"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.SinceSeconds, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.SinceSeconds = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["sinceTime"]; ok && len(values) > 0 {
|
||||
if err := metav1.Convert_Slice_string_To_Pointer_v1_Time(&values, &out.SinceTime, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.SinceTime = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["timestamps"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Timestamps, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Timestamps = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["tailLines"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.TailLines, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.TailLines = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["limitBytes"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.LimitBytes, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LimitBytes = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["insecureSkipTLSVerifyBackend"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.InsecureSkipTLSVerifyBackend, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.InsecureSkipTLSVerifyBackend = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v1_PodLogOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v1_PodLogOptions(in *url.Values, out *v1.PodLogOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v1_PodLogOptions(in, out, s)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
// TODO: refactor
|
||||
package esutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// KubeSphere uses the layout `yyyy.MM.dd`.
|
||||
const layoutISO = "2006.01.02"
|
||||
|
||||
// Always do calculation based on UTC.
|
||||
func ResolveIndexNames(prefix string, start, end time.Time) string {
|
||||
if end.IsZero() {
|
||||
end = time.Now()
|
||||
}
|
||||
|
||||
// In case of no start time or a broad query range over 30 days, search all indices.
|
||||
if start.IsZero() || end.Sub(start).Hours() > 24*30 {
|
||||
return fmt.Sprintf("%s*", prefix)
|
||||
}
|
||||
|
||||
var indices []string
|
||||
days := int(end.Sub(start).Hours() / 24)
|
||||
if start.Add(time.Duration(days)*24*time.Hour).UTC().Day() != end.UTC().Day() {
|
||||
days++
|
||||
}
|
||||
for i := 0; i <= days; i++ {
|
||||
suffix := end.Add(time.Duration(-i) * 24 * time.Hour).UTC().Format(layoutISO)
|
||||
indices = append(indices, fmt.Sprintf("%s-%s", prefix, suffix))
|
||||
}
|
||||
|
||||
// If start is after end, ResolveIndexNames returns "".
|
||||
// However, query parameter validation will prevent it from happening at the very beginning (Bad Request).
|
||||
return strings.Join(indices, ",")
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package esutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestResolveIndexNames(t *testing.T) {
|
||||
var tests = []struct {
|
||||
prefix string
|
||||
start time.Time
|
||||
end time.Time
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.February, 1, 0, 0, 0, 0, time.UTC),
|
||||
end: time.Date(2020, time.February, 1, 0, 0, 0, 0, time.UTC),
|
||||
expected: "ks-logstash-log-2020.02.01",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.February, 1, 0, 0, 0, 0, time.UTC),
|
||||
end: time.Date(2020, time.February, 3, 0, 0, 0, 0, time.UTC),
|
||||
expected: "ks-logstash-log-2020.02.03,ks-logstash-log-2020.02.02,ks-logstash-log-2020.02.01",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
end: time.Date(2020, time.February, 3, 0, 0, 0, 0, time.UTC),
|
||||
expected: "ks-logstash-log*",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2000, time.February, 1, 0, 0, 0, 0, time.UTC),
|
||||
end: time.Date(2020, time.February, 3, 0, 0, 0, 0, time.UTC),
|
||||
expected: "ks-logstash-log*",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.February, 3, 0, 0, 0, 0, time.UTC),
|
||||
end: time.Date(2020, time.February, 1, 0, 0, 0, 0, time.UTC),
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.August, 6, 22, 0, 0, 0, time.UTC),
|
||||
end: time.Date(2020, time.August, 7, 04, 0, 0, 0, time.UTC),
|
||||
expected: "ks-logstash-log-2020.08.07,ks-logstash-log-2020.08.06",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.August, 6, 22, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
end: time.Date(2020, time.August, 7, 04, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
expected: "ks-logstash-log-2020.08.06",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.August, 7, 02, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
end: time.Date(2020, time.August, 7, 04, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
expected: "ks-logstash-log-2020.08.06",
|
||||
},
|
||||
{
|
||||
prefix: "ks-logstash-log",
|
||||
start: time.Date(2020, time.August, 7, 12, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
end: time.Date(2020, time.August, 7, 14, 0, 0, 0, time.FixedZone("UTC+8", 8*3600)),
|
||||
expected: "ks-logstash-log-2020.08.07",
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
result := ResolveIndexNames(test.prefix, test.start, test.end)
|
||||
if diff := cmp.Diff(result, test.expected); diff != "" {
|
||||
t.Fatalf("%T differ (-got, +want): %s", test.expected, diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the KubeSphere Authors.
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user