infra/google/kubernetes/index.js
function useVpcNetwork(mCb) {
			//assign network name to deployment entry
			oneDeployment.options.network = name;
			
			function patchFirewall() {
				let firewallRules = getFirewallRules(oneDeployment.options.network);
				
				let request = getConnector(options.infra.api);
				request.filter = `network eq .*${oneDeployment.options.network}`;
				request.project = options.infra.api.project;
				
				//list firewalls
				//Ref: https://cloud.google.com/compute/docs/reference/rest/v1/firewalls/list
				v1Compute().firewalls.list(request, function (error, firewalls) {
					if (error) return mCb(error);
					
					if (!firewalls.items) firewalls.items = [];
					
					async.eachSeries(firewallRules, (oneRule, vCb) => {
						let foundFirewall = firewalls.items.find((oneEntry) => {
							return oneEntry.name === oneRule.name
						});
						
						if (foundFirewall) {
							options.soajs.log.debug("Firewall rule:", oneRule.name, "already exists, skipping");
							return vCb();
						} else {
							options.soajs.log.debug("Creating firewall rule:", oneRule.name);
							request.resource = oneRule;
							return v1Compute().firewalls.insert(request, vCb);
						}
					}, mCb);
				});
			}
			
			patchFirewall();
		}
function useVpcNetwork(mCb) {
			//assign network name to deployment entry
			oneDeployment.options.network = name;
			
			function patchFirewall() {
				let firewallRules = getFirewallRules(oneDeployment.options.network);
				
				let request = getConnector(options.infra.api);
				request.filter = `network eq .*${oneDeployment.options.network}`;
				request.project = options.infra.api.project;
				
				//list firewalls
				//Ref: https://cloud.google.com/compute/docs/reference/rest/v1/firewalls/list
				v1Compute().firewalls.list(request, function (error, firewalls) {
					if (error) return mCb(error);
					
					if (!firewalls.items) firewalls.items = [];
					
					async.eachSeries(firewallRules, (oneRule, vCb) => {
						let foundFirewall = firewalls.items.find((oneEntry) => {
							return oneEntry.name === oneRule.name
						});
						
						if (foundFirewall) {
							options.soajs.log.debug("Firewall rule:", oneRule.name, "already exists, skipping");
							return vCb();
						} else {
							options.soajs.log.debug("Creating firewall rule:", oneRule.name);
							request.resource = oneRule;
							return v1Compute().firewalls.insert(request, vCb);
						}
					}, mCb);
				});
			}
			
			patchFirewall();
		}
function useVpcNetwork ( mCb ) { //assign network name to deployment entry oneDeployment . options . network = name ; function patchFirewall ( ) { let firewallRules = getFirewallRules ( oneDeployment . options . network ) ; let request = getConnector ( options . infra . api ) ; request . filter = ` ${ oneDeployment . options . network } ` ; request . project = options . infra . api . project ; //list firewalls //Ref: https://cloud.google.com/compute/docs/reference/rest/v1/firewalls/list v1Compute ( ) . firewalls . list ( request , function ( error , firewalls ) { if ( error ) return mCb ( error ) ; if ( ! firewalls . items ) firewalls . items = [ ] ; async . eachSeries ( firewallRules , ( oneRule , vCb ) => { let foundFirewall = firewalls . items . find ( ( oneEntry ) => { return oneEntry . name === oneRule . name } ) ; if ( foundFirewall ) { options . soajs . log . debug ( "Firewall rule:" , oneRule . name , "already exists, skipping" ) ; return vCb ( ) ; } else { options . soajs . log . debug ( "Creating firewall rule:" , oneRule . name ) ; request . resource = oneRule ; return v1Compute ( ) . firewalls . insert ( request , vCb ) ; } } , mCb ) ; } ) ; } patchFirewall ( ) ; }
method used to use an existing google vpc network
@returns {*}
method used to use an existing google vpc network