mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
Merge pull request #10604 from nikhiljindal/v1
Updating scripts to use v1 instead of v1beta3
This commit is contained in:
@@ -54,11 +54,7 @@ import (
|
||||
var nodeResourceName string
|
||||
|
||||
func init() {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
nodeResourceName = "minions"
|
||||
} else {
|
||||
nodeResourceName = "nodes"
|
||||
}
|
||||
nodeResourceName = "nodes"
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -90,7 +86,7 @@ func timeoutPath(resource, namespace, name string) string {
|
||||
var aPod string = `
|
||||
{
|
||||
"kind": "Pod",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"creationTimestamp": null%s
|
||||
@@ -108,7 +104,7 @@ var aPod string = `
|
||||
var aRC string = `
|
||||
{
|
||||
"kind": "ReplicationController",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -141,7 +137,7 @@ var aRC string = `
|
||||
var aService string = `
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -158,14 +154,14 @@ var aService string = `
|
||||
"selector": {
|
||||
"name": "a"
|
||||
},
|
||||
"portalIP": "10.0.0.100"
|
||||
"clusterIP": "10.0.0.100"
|
||||
}
|
||||
}
|
||||
`
|
||||
var aNode string = `
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -177,7 +173,7 @@ var aNode string = `
|
||||
var aEvent string = `
|
||||
{
|
||||
"kind": "Event",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -185,7 +181,7 @@ var aEvent string = `
|
||||
"kind": "Node",
|
||||
"namespace": "default",
|
||||
"name": "a",
|
||||
"apiVersion": "v1beta3"
|
||||
"apiVersion": "v1"
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -193,7 +189,7 @@ var aEvent string = `
|
||||
var aBinding string = `
|
||||
{
|
||||
"kind": "Binding",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -206,7 +202,7 @@ var aBinding string = `
|
||||
var aEndpoints string = `
|
||||
{
|
||||
"kind": "Endpoints",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -214,7 +210,7 @@ var aEndpoints string = `
|
||||
{
|
||||
"addresses": [
|
||||
{
|
||||
"IP": "10.10.1.1"
|
||||
"ip": "10.10.1.1"
|
||||
}
|
||||
],
|
||||
"ports": [
|
||||
@@ -231,7 +227,7 @@ var aEndpoints string = `
|
||||
var deleteNow string = `
|
||||
{
|
||||
"kind": "DeleteOptions",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"gracePeriodSeconds": null%s
|
||||
}
|
||||
`
|
||||
@@ -462,17 +458,6 @@ func parseResourceVersion(response []byte) (string, float64, error) {
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("unexpected error unmarshaling resultBody: %v", err)
|
||||
}
|
||||
apiVersion, ok := resultBodyMap["apiVersion"].(string)
|
||||
if !ok {
|
||||
return "", 0, fmt.Errorf("unexpected error, apiVersion not found in JSON response: %v", string(response))
|
||||
}
|
||||
if api.PreV1Beta3(apiVersion) {
|
||||
return parsePreV1Beta3ResourceVersion(resultBodyMap, response)
|
||||
}
|
||||
return parseV1Beta3ResourceVersion(resultBodyMap, response)
|
||||
}
|
||||
|
||||
func parseV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response []byte) (string, float64, error) {
|
||||
metadata, ok := resultBodyMap["metadata"].(map[string]interface{})
|
||||
if !ok {
|
||||
return "", 0, fmt.Errorf("unexpected error, metadata not found in JSON response: %v", string(response))
|
||||
@@ -492,19 +477,6 @@ func parseV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response
|
||||
return id, resourceVersion, nil
|
||||
}
|
||||
|
||||
func parsePreV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response []byte) (string, float64, error) {
|
||||
id, ok := resultBodyMap["id"].(string)
|
||||
if !ok {
|
||||
return "", 0, fmt.Errorf("unexpected error, id not found in JSON response: %v", string(response))
|
||||
}
|
||||
|
||||
resourceVersion, ok := resultBodyMap["resourceVersion"].(float64)
|
||||
if !ok {
|
||||
return "", 0, fmt.Errorf("unexpected error, resourceVersion not found in JSON response: %v", string(response))
|
||||
}
|
||||
return id, resourceVersion, nil
|
||||
}
|
||||
|
||||
func getPreviousResourceVersionKey(url, id string) string {
|
||||
baseUrl := strings.Split(url, "?")[0]
|
||||
key := baseUrl
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"kind": "ReplicationController",
|
||||
"apiVersion": "v1beta3",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "test-controller",
|
||||
"namespace": "test",
|
||||
|
@@ -97,7 +97,7 @@ func NewMasterComponents(c *Config) *MasterComponents {
|
||||
if c.DeleteEtcdKeys {
|
||||
DeleteAllEtcdKeys()
|
||||
}
|
||||
restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: "v1beta3", QPS: c.QPS, Burst: c.Burst})
|
||||
restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: testapi.Version(), QPS: c.QPS, Burst: c.Burst})
|
||||
rcStopCh := make(chan struct{})
|
||||
controllerManager := controller.NewReplicationManager(restClient, c.Burst)
|
||||
|
||||
|
Reference in New Issue
Block a user