Merge lp:~bcsaller/juju-gui/export-improvements into lp:juju-gui/experimental

Proposed by Benjamin Saller
Status: Merged
Merged at revision: 829
Proposed branch: lp:~bcsaller/juju-gui/export-improvements
Merge into: lp:juju-gui/experimental
Diff against target: 127 lines (+67/-9)
2 files modified
app/models/models.js (+33/-5)
test/test_model.js (+34/-4)
To merge this branch: bzr merge lp:~bcsaller/juju-gui/export-improvements
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+174485@code.launchpad.net

Description of the change

Many deployer export format fixes

Export Annotations
Skip export of default service options.
Services is a dict, not an array
Use qualified charm names

https://codereview.appspot.com/11227043/

To post a comment you must log in.
Revision history for this message
Benjamin Saller (bcsaller) wrote :
Download full text (5.7 KiB)

Reviewers: mp+174485_code.launchpad.net,

Message:
Please take a look.

Description:
Many deployer export format fixes

Export Annotations
Skip export of default service options.
Services is a dict, not an array
Use qualified charm names

https://code.launchpad.net/~bcsaller/juju-gui/export-improvements/+merge/174485

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M app/models/models.js
   M test/test_model.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: test/test_model.js
=== modified file 'test/test_model.js'
--- test/test_model.js 2013-07-11 23:21:42 +0000
+++ test/test_model.js 2013-07-12 19:16:17 +0000
@@ -808,7 +808,10 @@
      var mysql = db.services.add({id: 'mysql', charm: 'precise/mysql-1'});
      var wordpress = db.services.add({
        id: 'wordpress',
- charm: 'precise/wordpress-1'});
+ charm: 'precise/wordpress-1',
+ config: {debug: 'no', username: 'admin'},
+ annotations: {'gui-x': 100, 'gui-y': 200, 'ignored': true}
+ });
      var rel0 = db.relations.add({
        id: 'relation-0',
        endpoints: [
@@ -820,13 +823,40 @@
      db.environment.set('defaultSeries', 'precise');

      // Add the charms so we can resolve them in the export.
- db.charms.add([{id: 'precise/mysql-1'}, {id: 'precise/wordpress-1'}]);
+ db.charms.add([{id: 'precise/mysql-1'},
+ {id: 'precise/wordpress-1',
+ config: {
+ options: {
+ debug: {
+ 'default': 'no'
+ },
+ username: {
+ 'default': 'root'
+ }
+ }
+ }
+ }
+ ]);
      var result = db.exportDeployer().envExport;
      var relation = result.relations[0];

      assert.equal(result.series, 'precise');
- assert.equal(result.services[0].charm, 'mysql');
- assert.equal(result.services[1].charm, 'wordpress');
+ assert.equal(result.services.mysql.charm, 'precise/mysql-1');
+ assert.equal(result.services.wordpress.charm, 'precise/wordpress-1');
+
+ // A default config value is skipped
+ assert.equal(result.services.wordpress.options.debug, undefined);
+ // A value changed from the default is exported
+ assert.equal(result.services.wordpress.options.username, 'admin');
+ // Ensure that mysql has no options object in the export as no
+ // non-default options are defined
+ assert.equal(result.services.mysql.options, undefined);
+
+ // Export position annotations.
+ assert.equal(result.services.wordpress.annotations['gui-x'], 100);
+ assert.equal(result.services.wordpress.annotations['gui-y'], 200);
+ // Note that ignored wasn't exported.
+ assert.equal(result.services.wordpress.annotations.ignored, undefined);

      assert.equal(relation[0], 'mysql:db');
      assert.equal(relation[1], 'w...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :

LGTM with a suggestion to go XXX vs "doesn't make sense" note.

https://codereview.appspot.com/11227043/diff/1/app/models/models.js
File app/models/models.js (right):

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode919
app/models/models.js:919: // than relative which would make more sense
in an export.
should this be an XXX vs a note then if it doesn't make much sense as
is?

https://codereview.appspot.com/11227043/

Revision history for this message
Gary Poster (gary) wrote :

LGTM with trivials, thank you!

https://codereview.appspot.com/11227043/diff/1/app/models/models.js
File app/models/models.js (right):

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode889
app/models/models.js:889: // Process the serivce_options removing any
values
trivial: service_options

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode900
app/models/models.js:900: // Using package name here so the default
series
This comment is no longer correct. Delete?

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode919
app/models/models.js:919: // than relative which would make more sense
in an export.
Good point. File a bug? Low priority until someone asks for it.

https://codereview.appspot.com/11227043/

Revision history for this message
Benjamin Saller (bcsaller) wrote :

Thanks for the reviews

https://codereview.appspot.com/11227043/diff/1/app/models/models.js
File app/models/models.js (right):

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode889
app/models/models.js:889: // Process the serivce_options removing any
values
On 2013/07/12 21:32:11, gary.poster wrote:
> trivial: service_options

Done.

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode900
app/models/models.js:900: // Using package name here so the default
series
On 2013/07/12 21:32:11, gary.poster wrote:
> This comment is no longer correct. Delete?

Ha, the "this is likely..." part was still valid, removed though as its
happened.

https://codereview.appspot.com/11227043/diff/1/app/models/models.js#newcode919
app/models/models.js:919: // than relative which would make more sense
in an export.
On 2013/07/12 21:15:00, rharding wrote:
> should this be an XXX vs a note then if it doesn't make much sense as
is?

XXX'd :)

https://codereview.appspot.com/11227043/

Revision history for this message
Benjamin Saller (bcsaller) wrote :

*** Submitted:

Many deployer export format fixes

Export Annotations
Skip export of default service options.
Services is a dict, not an array
Use qualified charm names

R=rharding, gary.poster, benjamin.saller
CC=
https://codereview.appspot.com/11227043

https://codereview.appspot.com/11227043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/models/models.js'
--- app/models/models.js 2013-07-08 21:52:00 +0000
+++ app/models/models.js 2013-07-12 19:20:34 +0000
@@ -871,7 +871,7 @@
871 result = {871 result = {
872 envExport: {872 envExport: {
873 series: this.environment.get('defaultSeries'),873 series: this.environment.get('defaultSeries'),
874 services: [],874 services: {},
875 relations: []875 relations: []
876 }876 }
877 };877 };
@@ -879,22 +879,50 @@
879 serviceList.each(function(service) {879 serviceList.each(function(service) {
880 var units = service.units;880 var units = service.units;
881 var charm = self.charms.getById(service.get('charm'));881 var charm = self.charms.getById(service.get('charm'));
882 if (service.get('pending') === true) {return;}882 var serviceOptions = {};
883 var charmOptions = charm.get('config.options');
884
885 if (service.get('pending') === true) {
886 return;
887 }
888
889 // Process the serivce_options removing any values
890 // that are the default value for the charm.
891 Y.each(service.get('config'), function(value, key) {
892 var optionData = charmOptions && charmOptions[key];
893 if (!optionData || (optionData && optionData['default'] &&
894 (value !== optionData['default']))) {
895 serviceOptions[key] = value;
896 }
897 });
898
883 var serviceData = {899 var serviceData = {
884 // Using package name here so the default series900 // Using package name here so the default series
885 // is picked up. This will likely have to be the full901 // is picked up. This will likely have to be the full
886 // path in the future.902 // path in the future.
887 charm: charm.get('package_name'),903 charm: charm.get('id'),
888 options: service.get('config'),
889 // Test models or ghosts might not have a units LazyModelList.904 // Test models or ghosts might not have a units LazyModelList.
890 num_units: units && units.size() || 1905 num_units: units && units.size() || 1
891 };906 };
907 if (serviceOptions && Y.Object.size(serviceOptions) >= 1) {
908 serviceData.options = serviceOptions;
909 }
892 // Add constraints910 // Add constraints
893 var constraints = service.get('constraintsStr');911 var constraints = service.get('constraintsStr');
894 if (constraints) {912 if (constraints) {
895 serviceData.constraints = constraints;913 serviceData.constraints = constraints;
896 }914 }
897 result.envExport.services.push(serviceData);915
916 var annotations = service.get('annotations');
917 if (annotations && annotations['gui-x']) {
918 // Only expose position. Currently these are position absolute rather
919 // than relative which would make more sense in an export.
920 serviceData.annotations = {
921 'gui-x': annotations['gui-x'],
922 'gui-y': annotations['gui-y']
923 };
924 }
925 result.envExport.services[service.get('id')] = serviceData;
898 });926 });
899927
900 relationList.each(function(relation) {928 relationList.each(function(relation) {
901929
=== modified file 'test/test_model.js'
--- test/test_model.js 2013-07-11 23:21:42 +0000
+++ test/test_model.js 2013-07-12 19:20:34 +0000
@@ -808,7 +808,10 @@
808 var mysql = db.services.add({id: 'mysql', charm: 'precise/mysql-1'});808 var mysql = db.services.add({id: 'mysql', charm: 'precise/mysql-1'});
809 var wordpress = db.services.add({809 var wordpress = db.services.add({
810 id: 'wordpress',810 id: 'wordpress',
811 charm: 'precise/wordpress-1'});811 charm: 'precise/wordpress-1',
812 config: {debug: 'no', username: 'admin'},
813 annotations: {'gui-x': 100, 'gui-y': 200, 'ignored': true}
814 });
812 var rel0 = db.relations.add({815 var rel0 = db.relations.add({
813 id: 'relation-0',816 id: 'relation-0',
814 endpoints: [817 endpoints: [
@@ -820,13 +823,40 @@
820 db.environment.set('defaultSeries', 'precise');823 db.environment.set('defaultSeries', 'precise');
821824
822 // Add the charms so we can resolve them in the export.825 // Add the charms so we can resolve them in the export.
823 db.charms.add([{id: 'precise/mysql-1'}, {id: 'precise/wordpress-1'}]);826 db.charms.add([{id: 'precise/mysql-1'},
827 {id: 'precise/wordpress-1',
828 config: {
829 options: {
830 debug: {
831 'default': 'no'
832 },
833 username: {
834 'default': 'root'
835 }
836 }
837 }
838 }
839 ]);
824 var result = db.exportDeployer().envExport;840 var result = db.exportDeployer().envExport;
825 var relation = result.relations[0];841 var relation = result.relations[0];
826842
827 assert.equal(result.series, 'precise');843 assert.equal(result.series, 'precise');
828 assert.equal(result.services[0].charm, 'mysql');844 assert.equal(result.services.mysql.charm, 'precise/mysql-1');
829 assert.equal(result.services[1].charm, 'wordpress');845 assert.equal(result.services.wordpress.charm, 'precise/wordpress-1');
846
847 // A default config value is skipped
848 assert.equal(result.services.wordpress.options.debug, undefined);
849 // A value changed from the default is exported
850 assert.equal(result.services.wordpress.options.username, 'admin');
851 // Ensure that mysql has no options object in the export as no
852 // non-default options are defined
853 assert.equal(result.services.mysql.options, undefined);
854
855 // Export position annotations.
856 assert.equal(result.services.wordpress.annotations['gui-x'], 100);
857 assert.equal(result.services.wordpress.annotations['gui-y'], 200);
858 // Note that ignored wasn't exported.
859 assert.equal(result.services.wordpress.annotations.ignored, undefined);
830860
831 assert.equal(relation[0], 'mysql:db');861 assert.equal(relation[0], 'mysql:db');
832 assert.equal(relation[1], 'wordpress:app');862 assert.equal(relation[1], 'wordpress:app');

Subscribers

People subscribed via source and target branches