File tree 2 files changed +29
-13
lines changed
packages/google-cloud-compute
2 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -582,23 +582,18 @@ class Zone extends common.ServiceObject {
582
582
createVM ( name , config , callback ) {
583
583
const self = this ;
584
584
const query = { } ;
585
- const body = Object . assign (
586
- {
587
- name : name ,
588
- machineType : 'n1-standard-1' ,
589
- networkInterfaces : [
590
- {
591
- network : 'global/networks/default' ,
592
- } ,
593
- ] ,
594
- } ,
595
- config
596
- ) ;
585
+ const body = Object . assign ( { name} , config ) ;
597
586
if ( body . template ) {
598
587
query . sourceInstanceTemplate = body . template ;
599
588
delete body . template ;
600
589
}
601
- if ( body . machineType . indexOf ( '/' ) === - 1 ) {
590
+ if ( ! is . defined ( query . sourceInstanceTemplate ) ) {
591
+ body . machineType = body . machineType || 'n1-standard-1' ;
592
+ body . networkInterfaces = body . networkInterfaces || [
593
+ { network : 'global/networks/default' } ,
594
+ ] ;
595
+ }
596
+ if ( body . machineType && body . machineType . indexOf ( '/' ) === - 1 ) {
602
597
// The specified machineType is only a partial name, e.g. 'n1-standard-1'.
603
598
body . machineType = format ( 'zones/{zoneName}/machineTypes/{machineType}' , {
604
599
zoneName : this . name ,
Original file line number Diff line number Diff line change @@ -791,6 +791,27 @@ describe('Zone', () => {
791
791
792
792
zone . createVM ( NAME , CONFIG , assert . ifError ) ;
793
793
} ) ;
794
+
795
+ it ( 'should not set default value for machineType' , done => {
796
+ zone . request = function ( reqOpts ) {
797
+ assert . strictEqual ( typeof reqOpts . json . machineType , 'undefined' ) ;
798
+ done ( ) ;
799
+ } ;
800
+
801
+ zone . createVM ( NAME , CONFIG , assert . ifError ) ;
802
+ } ) ;
803
+
804
+ it ( 'should not set default value for network' , done => {
805
+ zone . request = function ( reqOpts ) {
806
+ assert . strictEqual (
807
+ typeof reqOpts . json . networkInterfaces ,
808
+ 'undefined'
809
+ ) ;
810
+ done ( ) ;
811
+ } ;
812
+
813
+ zone . createVM ( NAME , CONFIG , assert . ifError ) ;
814
+ } ) ;
794
815
} ) ;
795
816
796
817
describe ( 'config.machineType' , ( ) => {
You can’t perform that action at this time.
0 commit comments