Merge lp:~jcsackett/juju-gui/charm-unification-cleanup into lp:juju-gui/experimental

Proposed by j.c.sackett
Status: Merged
Merged at revision: 951
Proposed branch: lp:~jcsackett/juju-gui/charm-unification-cleanup
Merge into: lp:juju-gui/experimental
Diff against target: 96 lines (+13/-30)
1 file modified
app/models/charm.js (+13/-30)
To merge this branch: bzr merge lp:~jcsackett/juju-gui/charm-unification-cleanup
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+180008@code.launchpad.net

Description of the change

Minor clean ups from model unification.

* XXX notes have been consolidated to indicate what should actually be done once
possible.
* The checks in BrowserCharm.parse have been updated based on investigation into
the PyJuju and GoJuju environments. As the data passed is consistently in one
form or another, we now just check if "config" exists and parse
the data as needed in that case.

https://codereview.appspot.com/12897043/

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :
Download full text (5.8 KiB)

Reviewers: mp+180008_code.launchpad.net,

Message:
Please take a look.

Description:
Minor clean ups from model unification.

This began as an effort to do some cleanup from the charm unification
work.
However, the real cleanup consists of removing models.Charm, which we
have
elected to not do at this time, and removing the Charm View code (and
related
attributes on BrowserCharm). The latter cannot be done until the Service
Inspector is no longer feature flagged.

* XXX notes have been consolidated to indicate what should actually be
done once
possible.
* The checks in BrowserCharm.parse have been updated based on
investigation into
the PyJuju and GoJuju environments:
* * Go Juju and Py Juju both pass "subordinate", "config", and
"requires/provides".
* * Fake backend doesn't actually pass this information in at all, as
charms only
reach parse on deploy from the charm browser.
* * Charm browser passes in the browsercharm attributes, e.g.
"is_subordinate".
* * As the data is consistent, we now just check if "config" exists and
parse
the data as needed in that case.

https://code.launchpad.net/~jcsackett/juju-gui/charm-unification-cleanup/+merge/180008

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/12897043/

Affected files:
   A [revision details]
   M app/models/charm.js

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: app/models/charm.js
=== modified file 'app/models/charm.js'
--- app/models/charm.js 2013-08-12 17:39:36 +0000
+++ app/models/charm.js 2013-08-13 21:34:51 +0000
@@ -111,6 +111,9 @@
     *
     * @class Charm
     */
+ // XXX jcsackett Aug 12 2013 Charm model is only being kept while we
observe
+ // the effects of the changeover to Browsercharm. This can be deleted
once we
+ // ascertain there is no fallout.
    var Charm = Y.Base.create('charm', Y.Model, [], {

      /**
@@ -148,8 +151,6 @@
       * @param {Object} cfg The configuration object.
       */
      initializer: function(cfg) {
- // XXX jcsackett July 19 2013 This is temporary while resolving
Charm and
- // BrowserCharm; Charm wants a fully qualified url as it's ID.
        if (cfg && cfg.url) {
          this.set('id', cfg.url);
        }
@@ -164,10 +165,6 @@
        Y.Object.each(
            parts,
            function(value, key) { self.set(key, value); });
- // XXX jcsackett July 16 2013 There are a raft of bits and bobs of
- // differences between the two charm models that need to be resolved
for
- // the new API to work with the old model. These will no longer be
needed
- // when we switch over to BrowserCharm everywhere.
        if (cfg) {
          if (cfg.config) {
            this.set('options', cfg.config.options);
@@ -210,12 +207,7 @@
        var data = Charm.superclass.parse.apply(this, arguments),
            self = this;

- // TODO (gary): verify whether is_subordinate is ever...

Read more...

951. By j.c.sackett

Merged trunk.

Revision history for this message
j.c.sackett (jcsackett) wrote :
Revision history for this message
Madison Scott-Clary (makyo) wrote :
Revision history for this message
Richard Harding (rharding) wrote :

LGTM though I don't get parse called on the super class? Can you
verify/double check that?

https://codereview.appspot.com/12897043/diff/4001/app/models/charm.js
File app/models/charm.js (right):

https://codereview.appspot.com/12897043/diff/4001/app/models/charm.js#newcode518
app/models/charm.js:518: var data =
models.BrowserCharm.superclass.parse.apply(this, arguments),
why is this calling it's own method?

https://codereview.appspot.com/12897043/

Revision history for this message
j.c.sackett (jcsackett) wrote :

https://codereview.appspot.com/12897043/diff/4001/app/models/charm.js#newcode518
> app/models/charm.js:518: var data =
> models.BrowserCharm.superclass.parse.apply(this, arguments),
> why is this calling it's own method?

It's calling the Models.parse method, I assume. This is a port from what
Charm did.

https://codereview.appspot.com/12897043/

952. By j.c.sackett

Merged trunk.

953. By j.c.sackett

Merged trunk.

Revision history for this message
j.c.sackett (jcsackett) wrote :

*** Submitted:

Minor clean ups from model unification.

* XXX notes have been consolidated to indicate what should actually be
done once
possible.
* The checks in BrowserCharm.parse have been updated based on
investigation into
the PyJuju and GoJuju environments. As the data passed is consistently
in one
form or another, we now just check if "config" exists and parse
the data as needed in that case.

R=matthew.scott, rharding
CC=
https://codereview.appspot.com/12897043

https://codereview.appspot.com/12897043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/models/charm.js'
2--- app/models/charm.js 2013-08-13 19:01:52 +0000
3+++ app/models/charm.js 2013-08-14 21:41:44 +0000
4@@ -112,6 +112,9 @@
5 *
6 * @class Charm
7 */
8+ // XXX jcsackett Aug 12 2013 Charm model is only being kept while we observe
9+ // the effects of the changeover to Browsercharm. This can be deleted once we
10+ // ascertain there is no fallout.
11 var Charm = Y.Base.create('charm', Y.Model, [], {
12
13 /**
14@@ -149,8 +152,6 @@
15 * @param {Object} cfg The configuration object.
16 */
17 initializer: function(cfg) {
18- // XXX jcsackett July 19 2013 This is temporary while resolving Charm and
19- // BrowserCharm; Charm wants a fully qualified url as it's ID.
20 if (cfg && cfg.url) {
21 this.set('id', cfg.url);
22 }
23@@ -165,10 +166,6 @@
24 Y.Object.each(
25 parts,
26 function(value, key) { self.set(key, value); });
27- // XXX jcsackett July 16 2013 There are a raft of bits and bobs of
28- // differences between the two charm models that need to be resolved for
29- // the new API to work with the old model. These will no longer be needed
30- // when we switch over to BrowserCharm everywhere.
31 if (cfg) {
32 if (cfg.config) {
33 this.set('options', cfg.config.options);
34@@ -211,12 +208,7 @@
35 var data = Charm.superclass.parse.apply(this, arguments),
36 self = this;
37
38- // TODO (gary): verify whether is_subordinate is ever passed by pyjuju
39- // or juju core. If not, remove the "|| data.is_subordinate" and change
40- // in the fakebackend and/or sandbox to send the expected thing there.
41 data.is_subordinate = data.subordinate || data.is_subordinate;
42- // Because the old and new charm models have different places for
43- // the options data, this handles the normalization.
44 if (data.config && data.config.options && !data.options) {
45 data.options = data.config.options;
46 delete data.config;
47@@ -264,10 +256,6 @@
48 }
49 },
50 bzr_branch: {},
51- //XXX jcsackett July 31 2013 This attribute is only needed until we turn
52- // on the service inspector. It's just used by the charm view you get when
53- // inspecting a service, and should be ripped out (along with tests) when
54- // we remove that view.
55 charm_path: {
56 /**
57 * Generate the charm store path from the attributes of the charm.
58@@ -528,28 +516,23 @@
59 },
60
61 parse: function(response) {
62- var data = Charm.superclass.parse.apply(this, arguments),
63+ var data = models.BrowserCharm.superclass.parse.apply(this, arguments),
64 self = this;
65
66- // TODO (gary): verify whether is_subordinate is ever passed by pyjuju
67- // or juju core. If not, remove the "|| data.is_subordinate" and change
68- // in the fakebackend and/or sandbox to send the expected thing there.
69- data.is_subordinate = data.subordinate || data.is_subordinate;
70- // Because the old and new charm models have different places for
71- // the options data, this handles the normalization.
72-
73- // TODO (jcsackett): Verify whether parse *ever* gets data.config or
74- // data.relations, if not we can remove the checks and default to altering
75- // the data.
76- if (data.config && data.config.options && !data.options) {
77+ //Data can come from two places; a BrowserCharm being deployed into the
78+ //environment, or a charm already in the environment. They have slightly
79+ //different attributes.
80+ if (data.config) {
81+ // If data has a 'config' attribute, we're dealing with data from the
82+ // environment.
83 data.options = data.config.options;
84- delete data.config;
85- }
86- if (!data.relations && (data.requires || data.provides)) {
87 data.relations = {
88 requires: data.requires,
89 provides: data.provides
90 };
91+ data.is_subordinate = data.subordinate;
92+ delete data.config;
93+ delete data.subordinate;
94 delete data.requires;
95 delete data.provides;
96 }

Subscribers

People subscribed via source and target branches