Skip to content

Commit 54cc564

Browse files
author
OpenShift Bot
committed
Merge pull request #2371 from smarterclayton/disable_v1beta1
Merged by openshift-bot
2 parents b32294b + 7138704 commit 54cc564

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3590
-69
lines changed

assets/app/scripts/controllers/overview.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ angular.module('openshiftConsole')
235235
if (configJson) {
236236
try {
237237
var depConfig = $.parseJSON(configJson);
238-
deployment.details = depConfig.details;
238+
if (depConfig.apiVersion === "v1beta1") {
239+
// TODO: will be slightly inaccurate for now
240+
deployment.status = {details: depConfig.details};
241+
} else {
242+
deployment.status = depConfig.status;
243+
}
239244
}
240245
catch (e) {
241246
Logger.error("Failed to parse encoded deployment config", e);

assets/app/scripts/filters/resources.js

+22
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,28 @@ angular.module('openshiftConsole')
253253
(resource && resource.metadata && resource.metadata.namespace);
254254
};
255255
})
256+
.filter('imageObjectRef', function(){
257+
return function(objectRef){
258+
// TODO: needs to handle the current namespace
259+
var ns = objectRef.namespace || "";
260+
if (ns.length > 0) {
261+
ns = ns + "/";
262+
}
263+
var kind = objectRef.kind;
264+
if (kind === "ImageStreamTag" || kind === "ImageStreamImage") {
265+
return ns+objectRef.name;
266+
}
267+
if (kind === "DockerImage") {
268+
// TODO: replace with real DockerImageReference parse function
269+
var name = objectRef.name;
270+
name = name.substring(name.lastIndexOf("/")+1);
271+
return name;
272+
}
273+
// TODO: we may want to indicate the actual type
274+
var ref = ns + objectRef.name;
275+
return ref;
276+
};
277+
})
256278
.filter('imageRepoReference', function(){
257279
return function(objectRef, kind, tag){
258280
var ns = objectRef.namespace || "";

assets/app/views/_overview-deployment.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ <h3 class="h4">
4242

4343
<div class="component meta-data">
4444
created <relative-timestamp timestamp="rc.metadata.creationTimestamp"></relative-timestamp
45-
><span ng-if="rc.details.causes.length"
45+
><span ng-if="rc.status.details.causes.length"
4646
><span>, triggered by
47-
<span class="deployment-trigger" ng-repeat="cause in rc.details.causes">
47+
<span class="deployment-trigger" ng-repeat="cause in rc.status.details.causes">
4848
<span ng-switch="cause.type">
49-
<span ng-switch-when="ImageChange">a new image for {{cause.imageTrigger.repositoryName | imageStreamName}}:{{cause.imageTrigger.tag}}</span>
49+
<span ng-switch-when="ImageChange">a new image for {{cause.imageTrigger.from | imageObjectRef}}</span>
5050
<span ng-switch-when="ConfigChange">a config change</span>
5151
</span>
5252
</span>

assets/test/e2e/test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('', function() {
2323

2424
var login = function(loginPageAlreadyLoaded) {
2525
// The login page doesn't use angular, so we have to use the underlying WebDriver instance
26-
var driver = browser.driver;
26+
var driver = browser.driver;
2727
if (!loginPageAlreadyLoaded) {
2828
browser.get('/');
2929
driver.wait(function() {
@@ -76,7 +76,7 @@ describe('', function() {
7676

7777
it('should be able to list the test project', function() {
7878
browser.get('/');
79-
79+
8080
expect(element(by.cssContainingText("h2.project","test")).isPresent()).toBe(true);
8181
});
8282

@@ -92,10 +92,10 @@ describe('', function() {
9292

9393
expect(element(by.cssContainingText(".pod-template-build","Build: ruby-sample-build")).isPresent()).toBe(true);
9494

95-
expect(element(by.cssContainingText(".deployment-trigger","new image for test/origin-ruby-sample:latest")).isPresent()).toBe(true);
96-
95+
expect(element(by.cssContainingText(".deployment-trigger","new image for origin-ruby-sample:latest")).isPresent()).toBe(true);
96+
9797
expect(element.all(by.css(".pod-running")).count()).toEqual(3);
9898
});
99-
});
99+
});
100100

101101
});

cmd/origin-version-change/main.go

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// origin-version-change is a simple utility for converting a
2+
// storage object into a different api version.
3+
package main
4+
5+
import (
6+
"bytes"
7+
"encoding/json"
8+
"io"
9+
"io/ioutil"
10+
"log"
11+
"os"
12+
"runtime"
13+
14+
"github.com/ghodss/yaml"
15+
flag "github.com/spf13/pflag"
16+
17+
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
18+
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
19+
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
20+
21+
"github.com/openshift/origin/pkg/api/latest"
22+
)
23+
24+
var (
25+
inputSource = flag.StringP("input", "i", "-", "Input source; '-' means stdin")
26+
outputDest = flag.StringP("output", "o", "-", "Output destination; '-' means stdout")
27+
rewrite = flag.StringP("rewrite", "r", "", "If nonempty, use this as both input and output.")
28+
outputVersion = flag.StringP("out-version", "v", latest.Version, "Version to convert input to")
29+
)
30+
31+
// isYAML determines whether data is JSON or YAML formatted by seeing
32+
// if it will parse as json.
33+
func isYAML(data []byte) bool {
34+
var unused interface{}
35+
if err := json.Unmarshal(data, &unused); err != nil {
36+
return true
37+
}
38+
return false
39+
}
40+
41+
func main() {
42+
runtime.GOMAXPROCS(runtime.NumCPU())
43+
flag.CommandLine.SetNormalizeFunc(util.WordSepNormalizeFunc)
44+
flag.Parse()
45+
46+
if *rewrite != "" {
47+
*inputSource = *rewrite
48+
*outputDest = *rewrite
49+
}
50+
51+
var in io.Reader
52+
if *inputSource == "-" {
53+
in = os.Stdin
54+
} else {
55+
f, err := os.Open(*inputSource)
56+
if err != nil {
57+
log.Fatalf("Couldn't open %q: %q", *inputSource, err)
58+
}
59+
defer f.Close()
60+
in = f
61+
}
62+
63+
data, err := ioutil.ReadAll(in)
64+
if err != nil {
65+
log.Fatalf("Couldn't read from input: %q", err)
66+
}
67+
isYAML := isYAML(data)
68+
69+
if isYAML {
70+
data, err = yaml.YAMLToJSON(data)
71+
if err != nil {
72+
log.Fatalf("Failed to convert YAML to JSON: %q", err)
73+
}
74+
}
75+
obj, err := api.Scheme.Decode(data)
76+
if err != nil {
77+
log.Fatalf("Couldn't decode input: %q", err)
78+
}
79+
80+
outData, err := api.Scheme.EncodeToVersion(obj, *outputVersion)
81+
if err != nil {
82+
log.Fatalf("Failed to encode to version %q: %q", *outputVersion, err)
83+
}
84+
85+
if isYAML {
86+
outData, err = yaml.JSONToYAML(outData)
87+
if err != nil {
88+
log.Fatalf("Failed to convert to YAML: %q", err)
89+
}
90+
} else if true {
91+
// TODO: figure out if input JSON was pretty.
92+
var buf bytes.Buffer
93+
err = json.Indent(&buf, outData, "", " ")
94+
if err != nil {
95+
log.Fatalf("Failed to indent JSON: %q", err)
96+
}
97+
outData = buf.Bytes()
98+
}
99+
100+
var out io.Writer
101+
if *outputDest == "-" {
102+
out = os.Stdout
103+
} else {
104+
f, err := os.Create(*outputDest)
105+
if err != nil {
106+
log.Fatalf("Couldn't open %q: %q", *outputDest, err)
107+
}
108+
defer f.Close()
109+
out = f
110+
}
111+
112+
if _, err = out.Write(outData); err != nil {
113+
log.Fatalf("Failed to write: %q", err)
114+
}
115+
}

pkg/api/latest/latest.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
_ "github.com/openshift/origin/pkg/api"
1616
"github.com/openshift/origin/pkg/api/meta"
17+
"github.com/openshift/origin/pkg/api/v1"
1718
"github.com/openshift/origin/pkg/api/v1beta1"
1819
"github.com/openshift/origin/pkg/api/v1beta3"
1920
)
@@ -29,13 +30,13 @@ const OldestVersion = "v1beta1"
2930
// may be assumed to be least feature rich to most feature rich, and clients may
3031
// choose to prefer the latter items in the list over the former items when presented
3132
// with a set of versions to choose.
32-
var Versions = []string{"v1beta1", "v1beta3"}
33+
var Versions = []string{"v1beta1", "v1beta3", "v1"}
3334

3435
// Codec is the default codec for serializing output that should use
3536
// the latest supported version. Use this Codec when writing to
3637
// disk, a data store that is not dynamically versioned, or in tests.
3738
// This codec can decode any object that OpenShift is aware of.
38-
var Codec = v1beta1.Codec
39+
var Codec = v1beta3.Codec
3940

4041
// accessor is the shared static metadata accessor for the API.
4142
var accessor = kmeta.NewAccessor()
@@ -71,6 +72,12 @@ func InterfacesFor(version string) (*kmeta.VersionInterfaces, error) {
7172
ObjectConvertor: api.Scheme,
7273
MetadataAccessor: accessor,
7374
}, nil
75+
case "v1":
76+
return &kmeta.VersionInterfaces{
77+
Codec: v1.Codec,
78+
ObjectConvertor: api.Scheme,
79+
MetadataAccessor: accessor,
80+
}, nil
7481
default:
7582
return nil, fmt.Errorf("unsupported storage version: %s (valid: %s)", version, strings.Join(Versions, ", "))
7683
}
@@ -108,7 +115,7 @@ func init() {
108115
)
109116

110117
// list of versions we support on the server, in preferred order
111-
versions := []string{"v1beta3", "v1beta1"}
118+
versions := []string{"v1beta3", "v1beta1", "v1"}
112119

113120
// versions that used mixed case URL formats
114121
versionMixedCase := map[string]bool{
@@ -119,6 +126,7 @@ func init() {
119126
versionToNamespaceScope := map[string]kmeta.RESTScope{
120127
"v1beta1": kmeta.RESTScopeNamespaceLegacy,
121128
"v1beta3": kmeta.RESTScopeNamespace,
129+
"v1": kmeta.RESTScopeNamespace,
122130
}
123131

124132
// the list of kinds that are scoped at the root of the api hierarchy

pkg/api/serialization_test.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
osapi "github.com/openshift/origin/pkg/api"
1919
_ "github.com/openshift/origin/pkg/api/latest"
20+
"github.com/openshift/origin/pkg/api/v1"
2021
"github.com/openshift/origin/pkg/api/v1beta1"
2122
"github.com/openshift/origin/pkg/api/v1beta3"
2223
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
@@ -53,13 +54,13 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
5354
},
5455
func(j *image.ImageRepositoryMapping, c fuzz.Continue) {
5556
c.FuzzNoCustom(j)
56-
if forVersion == "v1beta3" {
57+
if forVersion != "v1beta1" {
5758
j.DockerImageRepository = ""
5859
}
5960
},
6061
func(j *image.ImageStreamMapping, c fuzz.Continue) {
6162
c.FuzzNoCustom(j)
62-
if forVersion == "v1beta3" {
63+
if forVersion != "v1beta1" {
6364
j.DockerImageRepository = ""
6465
}
6566
},
@@ -108,7 +109,7 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
108109
c.FuzzNoCustom(j)
109110
specs := []string{"", "a/b", "a/b/c", "a:5000/b/c", "a/b:latest", "a/b@test"}
110111
j.DockerImageReference = specs[c.Intn(len(specs))]
111-
if forVersion == "v1beta3" {
112+
if forVersion != "v1beta1" {
112113
j.Tag, j.DockerImageReference = "", ""
113114
if j.To != nil && (len(j.To.Kind) == 0 || j.To.Kind == "ImageStream") {
114115
j.To.Kind = "ImageStream"
@@ -255,7 +256,10 @@ var skipStandardVersions = map[string][]string{
255256
"DockerImage": {"pre012", "1.0"},
256257
}
257258
var skipV1beta1 = map[string]struct{}{}
258-
var skipV1beta2 = map[string]struct{}{
259+
var skipV1beta3 = map[string]struct{}{
260+
"ImageRepository": {},
261+
}
262+
var skipV1 = map[string]struct{}{
259263
"ImageRepository": {},
260264
}
261265

@@ -277,6 +281,7 @@ func TestSpecificKind(t *testing.T) {
277281
roundTrip(t, osapi.Codec, item)
278282
roundTrip(t, v1beta1.Codec, item)
279283
roundTrip(t, v1beta3.Codec, item)
284+
roundTrip(t, v1.Codec, item)
280285
}
281286

282287
func TestTypes(t *testing.T) {
@@ -310,10 +315,14 @@ func TestTypes(t *testing.T) {
310315
fuzzInternalObject(t, "v1beta1", item, seed)
311316
roundTrip(t, v1beta1.Codec, item)
312317
}
313-
if _, ok := skipV1beta2[kind]; !ok {
318+
if _, ok := skipV1beta3[kind]; !ok {
314319
fuzzInternalObject(t, "v1beta3", item, seed)
315320
roundTrip(t, v1beta3.Codec, item)
316321
}
322+
if _, ok := skipV1[kind]; !ok {
323+
fuzzInternalObject(t, "v1", item, seed)
324+
roundTrip(t, v1.Codec, item)
325+
}
317326
}
318327
}
319328
}

pkg/api/v1/doc.go

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package v1 is the v1 version of the API.
2+
package v1

pkg/api/v1/register.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package v1
2+
3+
import (
4+
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
5+
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
6+
7+
_ "github.com/openshift/origin/pkg/authorization/api/v1"
8+
_ "github.com/openshift/origin/pkg/build/api/v1"
9+
_ "github.com/openshift/origin/pkg/deploy/api/v1"
10+
_ "github.com/openshift/origin/pkg/image/api/v1"
11+
_ "github.com/openshift/origin/pkg/oauth/api/v1"
12+
_ "github.com/openshift/origin/pkg/project/api/v1"
13+
_ "github.com/openshift/origin/pkg/route/api/v1"
14+
_ "github.com/openshift/origin/pkg/sdn/api/v1"
15+
_ "github.com/openshift/origin/pkg/template/api/v1"
16+
_ "github.com/openshift/origin/pkg/user/api/v1"
17+
)
18+
19+
// Codec encodes internal objects to the v1 scheme
20+
var Codec = runtime.CodecFor(api.Scheme, "v1")
21+
22+
func init() {
23+
}

0 commit comments

Comments
 (0)