JSCS Cleanup - use DI in launch instance model

Per the JP style guide, implements getter syntax rather than declaring a
variable for the module, and implements DI for the service as well.
This also fixes the indent related issues caused by the new eslint
rules.
Change-Id: I8d9404d56c0c38debe97a99d8282d1d5b559302d
Co-Authored-By: Valerie Roske<varoske@thoughtworks.com>
Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
Rajat Vig 2015-08-27 14:31:36 -07:00 committed by Rajat Vig
parent 2096671dbe
commit f863e51dea
8 changed files with 567 additions and 520 deletions

View File

@ -36,15 +36,12 @@
ctrl.title = gettext('Import Key Pair Help');
var genKeyPairsMap = { genKeyPairCmd: 'ssh-keygen' };
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathsMap = { privateKeyPath: 'cloud.key', publicKeyPath: 'cloud.key.pub' };
var keyPathText = gettext('This command generates a pair of keys: a private key (%(privateKeyPath)s) and a public key (%(publicKeyPath)s).');
var windowsCmdMap = { authorizeKeysFile: '.ssh/authorized_keys' };
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathText = gettext('This command generates a pair of keys: a private key (%(privateKeyPath)s) and a public key (%(publicKeyPath)s).');
var windowsCmd = gettext('From a Windows system, you can use PuTTYGen to create private/public keys. Use the PuTTY Key Generator to create and save the keys, then copy the public key in the red highlighted box to your <samp>%(authorizeKeysFile)s</samp> file.');
/*eslint-enable max-len */

View File

@ -33,18 +33,17 @@
ctrl.title = gettext('Key Pair Help');
var genKeyPairsMap = {genKeyPairCmd: 'ssh-keygen'};
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathsMap = {
privateKeyPath: 'cloud.key',
publicKeyPath: 'cloud.key.pub'
};
var windowsCmdMap = {authorizeKeysFile: '.ssh/authorized_keys'};
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathText = gettext('This command generates a pair of keys: a private key (%(privateKeyPath)s) and a public key (%(publicKeyPath)s).');
var windowsCmdMap = {authorizeKeysFile: '.ssh/authorized_keys'};
var windowsCmd = gettext('From a Windows system, you can use PuTTYGen to create private/public keys. Use the PuTTY Key Generator to create and save the keys, then copy the public key in the red highlighted box to your <samp>%(authorizeKeysFile)s</samp> file.');
/*eslint-enable max-len */

View File

@ -413,14 +413,14 @@
it('should set final spec in format required for Block Device Mapping v2', function() {
var finalSpec = model.createInstance();
var expectedBlockDevice = [{
device_name: 'volTestName',
source_type: 'image',
destination_type: 'volume',
delete_on_termination: 1,
uuid: 'cirros',
boot_index: '0',
volume_size: 10
}];
device_name: 'volTestName',
source_type: 'image',
destination_type: 'volume',
delete_on_termination: 1,
uuid: 'cirros',
boot_index: '0',
volume_size: 10
}];
expect(finalSpec.block_device_mapping_v2).toEqual(expectedBlockDevice);
});

View File

@ -34,7 +34,9 @@
}));
beforeEach(inject(function ($injector) {
launchInstanceWorkflow = $injector.get('horizon.dashboard.project.workflow.launch-instance.workflow');
launchInstanceWorkflow = $injector.get(
'horizon.dashboard.project.workflow.launch-instance.workflow'
);
}));
it('should be defined', function () {

View File

@ -26,10 +26,17 @@
var scope, ctrl;
beforeEach(inject(function($controller) {
scope = {model: {
newInstanceSpec: {networks: ['net-a']},
networks: ['net-a', 'net-b']}};
ctrl = $controller('LaunchInstanceNetworkController', {$scope:scope});
scope = {
model: {
newInstanceSpec: {
networks: ['net-a']
},
networks: ['net-a', 'net-b']
}
};
ctrl = $controller('LaunchInstanceNetworkController', {
$scope: scope
});
}));
it('has correct network statuses', function() {

View File

@ -52,10 +52,33 @@
diskFormatFilter,
gbFilter,
quotaChartDefaults,
basePath) {
basePath
) {
var ctrl = this;
ctrl.label = {
title: gettext('Instance Details'),
/*eslint-disable max-len */
subtitle: gettext('Please provide the initial host name for the instance, the availability zone where it will be deployed, and the instance count. Increase the Count to create multiple instances with the same settings.'),
/*eslint-enable max-len */
instanceName: gettext('Instance Name'),
availabilityZone: gettext('Availability Zone'),
instance_count: gettext('Count'),
instanceSourceTitle: gettext('Instance Source'),
/*eslint-disable max-len */
instanceSourceSubTitle: gettext('Instance source is the template used to create an instance. You can use a snapshot of an existing instance, an image, or a volume (if enabled). You can also choose to use persistent storage by creating a new volume.'),
/*eslint-enable max-len */
bootSource: gettext('Select Boot Source'),
volumeSize: gettext('Size (GB)'),
volumeCreate: gettext('Create New Volume'),
volumeDeviceName: gettext('Device Name'),
deleteVolumeOnTerminate: gettext('Delete Volume on Terminate'),
id: gettext('ID'),
min_ram: gettext('Min Ram'),
min_disk: gettext('Min Disk')
};
// Error text for invalid fields
/*eslint-disable max-len */
ctrl.bootSourceTypeError = gettext('Volumes can only be attached to 1 active instance at a time. Please either set your instance count to 1 or select a different source type.');

View File

@ -25,7 +25,9 @@
var scope, ctrl, $browser, deferred;
beforeEach(module(function($provide) {
$provide.value('horizon.dashboard.project.workflow.launch-instance.boot-source-types', noop);
$provide.value(
'horizon.dashboard.project.workflow.launch-instance.boot-source-types', noop
);
$provide.value('bytesFilter', noop);
$provide.value('horizon.framework.widgets.charts.donutChartSettings', noop);
$provide.value('dateFilter', noop);
@ -62,7 +64,6 @@
scope.$apply();
}));
it('should be defined', function() {
expect(ctrl).toBeDefined();
});