@@ -23,7 +23,7 @@ import {
2323 ServiceJobDeployment ,
2424 ServiceJobSpecifications ,
2525} from '@typedefs/deeploys' ;
26- import { GenericSecondaryPlugin , SecondaryPluginType } from '@typedefs/steps/deploymentStepTypes' ;
26+ import { GenericSecondaryPlugin , NativeSecondaryPlugin , SecondaryPluginType } from '@typedefs/steps/deploymentStepTypes' ;
2727import { addDays , addHours , differenceInDays , differenceInHours } from 'date-fns' ;
2828import _ from 'lodash' ;
2929import { FieldValues , UseFieldArrayAppend , UseFieldArrayRemove } from 'react-hook-form' ;
@@ -217,6 +217,12 @@ export const formatGenericJobVariables = (plugin: GenericSecondaryPlugin) => {
217217 } ;
218218} ;
219219
220+ export const formatNativeJobPluginSignature = ( plugin : NativeSecondaryPlugin ) => {
221+ return plugin . pluginSignature === PLUGIN_SIGNATURE_TYPES [ PLUGIN_SIGNATURE_TYPES . length - 1 ]
222+ ? plugin . customPluginSignature
223+ : plugin . pluginSignature ;
224+ } ;
225+
220226export const formatGenericPluginConfigAndSignature = (
221227 resources : {
222228 cpu : number ;
@@ -318,13 +324,6 @@ export const formatNativeJobPayload = (
318324) => {
319325 const jobTags = formatJobTags ( specifications ) ;
320326
321- const customParams : Record < string , string > = { } ;
322- deployment . customParams . forEach ( ( param ) => {
323- if ( param . key ) {
324- customParams [ param . key ] = param . value ;
325- }
326- } ) ;
327-
328327 const pipelineParams : Record < string , string > = { } ;
329328 deployment . pipelineParams . forEach ( ( param ) => {
330329 if ( param . key ) {
@@ -342,31 +341,28 @@ export const formatNativeJobPayload = (
342341
343342 // Primary plugin configuration
344343 const primaryPluginConfig : any = {
345- plugin_signature :
346- deployment . pluginSignature === PLUGIN_SIGNATURE_TYPES [ PLUGIN_SIGNATURE_TYPES . length - 1 ]
347- ? deployment . customPluginSignature
348- : deployment . pluginSignature ,
344+ plugin_signature : formatNativeJobPluginSignature ( deployment ) ,
349345 PORT : deployment . port ,
350346 CLOUDFLARE_TOKEN : deployment . tunnelingToken || null ,
351347 TUNNEL_ENGINE_ENABLED : deployment . enableTunneling === 'True' ,
352348 NGROK_USE_API : true ,
353- ENV : { } ,
354- DYNAMIC_ENV : { } ,
355349 } ;
356350
357- if ( ! _ . isEmpty ( customParams ) ) {
358- Object . assign ( primaryPluginConfig , customParams ) ;
351+ if ( ! _ . isEmpty ( deployment . customParams ) ) {
352+ deployment . customParams . forEach ( ( param ) => {
353+ if ( param . key ) {
354+ primaryPluginConfig [ param . key ] = param . value ;
355+ }
356+ } ) ;
359357 }
360358
361359 // Build plugins array starting with the primary plugin
362360 const plugins = [ primaryPluginConfig ] ;
363361
364362 // Add secondary plugins if they exist
365363 if ( deployment . secondaryPlugins . length ) {
366- // TODO: Implement native secondary plugin configuration
367- const secondaryPluginConfigs = deployment . secondaryPlugins
368- . filter ( ( plugin ) => plugin . secondaryPluginType === SecondaryPluginType . Generic )
369- . map ( ( plugin ) => {
364+ const secondaryPluginConfigs = deployment . secondaryPlugins . map ( ( plugin ) => {
365+ if ( plugin . secondaryPluginType === SecondaryPluginType . Generic ) {
370366 const { pluginConfig, pluginSignature } = formatGenericPluginConfigAndSignature (
371367 nodeResources ,
372368 plugin as GenericSecondaryPlugin ,
@@ -376,7 +372,30 @@ export const formatNativeJobPayload = (
376372 plugin_signature : pluginSignature ,
377373 ...pluginConfig ,
378374 } ;
379- } ) ;
375+ }
376+
377+ if ( plugin . secondaryPluginType === SecondaryPluginType . Native ) {
378+ const nativePlugin = plugin as NativeSecondaryPlugin ;
379+
380+ const nativePluginConfig : any = {
381+ plugin_signature : formatNativeJobPluginSignature ( nativePlugin ) ,
382+ PORT : nativePlugin . port ,
383+ CLOUDFLARE_TOKEN : nativePlugin . tunnelingToken || null ,
384+ TUNNEL_ENGINE_ENABLED : nativePlugin . enableTunneling === 'True' ,
385+ NGROK_USE_API : true ,
386+ } ;
387+
388+ if ( ! _ . isEmpty ( nativePlugin . customParams ) ) {
389+ nativePlugin . customParams . forEach ( ( param ) => {
390+ if ( param . key ) {
391+ nativePluginConfig [ param . key ] = param . value ;
392+ }
393+ } ) ;
394+ }
395+
396+ return nativePluginConfig ;
397+ }
398+ } ) ;
380399
381400 plugins . push ( ...secondaryPluginConfigs ) ;
382401 }
0 commit comments