@@ -45,7 +45,8 @@ import (
45
45
sensorsv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
46
46
wf "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow"
47
47
wfv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
48
- appProxyModel "github.com/codefresh-io/go-sdk/pkg/codefresh/model/app-proxy"
48
+ platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
49
+ apmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model/app-proxy"
49
50
billyUtils "github.com/go-git/go-billy/v5/util"
50
51
"github.com/juju/ansiterm"
51
52
"github.com/spf13/cobra"
67
68
IngressHost string
68
69
IngressClass string
69
70
IngressController routingutil.RoutingController
71
+ AccessMode platmodel.AccessMode
70
72
GatewayName string
71
73
GatewayNamespace string
72
- Flow string
73
74
GitProvider cfgit.Provider
74
75
useGatewayAPI bool
75
76
}
@@ -105,6 +106,7 @@ type (
105
106
ingressHost string
106
107
ingressClass string
107
108
ingressController routingutil.RoutingController
109
+ accessMode platmodel.AccessMode
108
110
gatewayName string
109
111
gatewayNamespace string
110
112
useGatewayAPI bool
@@ -147,7 +149,6 @@ func NewGitSourceCreateCommand() *cobra.Command {
147
149
createRepo bool
148
150
include string
149
151
exclude string
150
- flow string
151
152
)
152
153
153
154
cmd := & cobra.Command {
@@ -217,7 +218,6 @@ func NewGitSourceCreateCommand() *cobra.Command {
217
218
CreateDemoResources : false ,
218
219
Include : include ,
219
220
Exclude : exclude ,
220
- Flow : flow ,
221
221
})
222
222
},
223
223
}
@@ -232,8 +232,6 @@ func NewGitSourceCreateCommand() *cobra.Command {
232
232
Optional : true ,
233
233
})
234
234
235
- flow = store .Get ().GsCreateFlow
236
-
237
235
return cmd
238
236
}
239
237
@@ -243,10 +241,6 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
243
241
return err
244
242
}
245
243
246
- if opts .Flow == store .Get ().InstallationFlow {
247
- return legacyGitSourceCreate (ctx , opts )
248
- }
249
-
250
244
if version .LessThan (appProxyGitSourceSupport ) {
251
245
log .G (ctx ).Warnf ("runtime \" %s\" is using a deprecated git-source api. Versions %s and up use the app-proxy for this command. You are using version: %s" , opts .RuntimeName , appProxyGitSourceSupport , version .String ())
252
246
return legacyGitSourceCreate (ctx , opts )
@@ -260,7 +254,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
260
254
appSpecifier := opts .GsCloneOpts .Repo
261
255
isInternal := util .StringIndexOf (store .Get ().CFInternalGitSources , opts .GsName ) > - 1
262
256
263
- err = appProxy .AppProxyGitSources ().Create (ctx , & appProxyModel .CreateGitSourceInput {
257
+ err = appProxy .AppProxyGitSources ().Create (ctx , & apmodel .CreateGitSourceInput {
264
258
AppName : opts .GsName ,
265
259
AppSpecifier : appSpecifier ,
266
260
DestServer : store .Get ().InCluster ,
@@ -280,23 +274,25 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
280
274
return nil
281
275
}
282
276
283
- func createPlaceholderIfNeeded (ctx context.Context , opts * GitSourceCreateOptions , gsRepo git.Repository , gsFs fs.FS ) error {
277
+ func ensureGitSourceDirectory (ctx context.Context , opts * GitSourceCreateOptions , gsRepo git.Repository , gsFs fs.FS ) error {
284
278
fi , err := gsFs .ReadDir ("." )
285
279
if err != nil {
286
280
return fmt .Errorf ("failed to read files in git-source repo. Err: %w" , err )
287
281
}
288
282
289
- if len (fi ) == 0 {
290
- if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
291
- return fmt .Errorf ("failed to write the git-source placeholder file. Err: %w" , err )
292
- }
283
+ if len (fi ) > 0 {
284
+ return nil
285
+ }
286
+
287
+ if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
288
+ return fmt .Errorf ("failed to write the git-source placeholder file. Err: %w" , err )
289
+ }
293
290
294
- commitMsg := fmt .Sprintf ("Created a placeholder file in %s Directory" , opts .GsCloneOpts .Path ())
291
+ commitMsg := fmt .Sprintf ("Created a placeholder file in %s Directory" , opts .GsCloneOpts .Path ())
295
292
296
- log .G (ctx ).Info ("Pushing placeholder file to the default-git-source repo" )
297
- if err := apu .PushWithMessage (ctx , gsRepo , commitMsg ); err != nil {
298
- return fmt .Errorf ("failed to push placeholder file to git-source repo: %w" , err )
299
- }
293
+ log .G (ctx ).Info ("Pushing placeholder file to the default-git-source repo" )
294
+ if err := apu .PushWithMessage (ctx , gsRepo , commitMsg ); err != nil {
295
+ return fmt .Errorf ("failed to push placeholder file to git-source repo: %w" , err )
300
296
}
301
297
302
298
return nil
@@ -569,7 +565,7 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
569
565
return err
570
566
}
571
567
572
- err = appProxy .AppProxyGitSources ().Edit (ctx , & appProxyModel .EditGitSourceInput {
568
+ err = appProxy .AppProxyGitSources ().Edit (ctx , & apmodel .EditGitSourceInput {
573
569
AppName : opts .GsName ,
574
570
AppSpecifier : opts .GsCloneOpts .Repo ,
575
571
Include : opts .Include ,
@@ -591,6 +587,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
591
587
if err != nil {
592
588
return fmt .Errorf ("failed to read files in git-source repo. Err: %w" , err )
593
589
}
590
+
594
591
if len (fi ) == 0 {
595
592
wfTemplateFilePath := store .Get ().DemoWorkflowTemplateFileName
596
593
wfTemplate := createDemoWorkflowTemplate ()
@@ -607,21 +604,24 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
607
604
return fmt .Errorf ("failed to create calendar example pipeline. Error: %w" , err )
608
605
}
609
606
610
- err = createDemoGitPipeline (& gitSourceGitDemoPipelineOptions {
611
- runtimeName : opts .RuntimeName ,
612
- gsCloneOpts : opts .GsCloneOpts ,
613
- gitProvider : opts .GitProvider ,
614
- gsFs : gsFs ,
615
- hostName : opts .HostName ,
616
- ingressHost : opts .IngressHost ,
617
- ingressClass : opts .IngressClass ,
618
- ingressController : opts .IngressController ,
619
- gatewayName : opts .GatewayName ,
620
- gatewayNamespace : opts .GatewayNamespace ,
621
- useGatewayAPI : opts .useGatewayAPI ,
622
- })
623
- if err != nil {
624
- return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
607
+ if opts .AccessMode == platmodel .AccessModeIngress {
608
+ err = createDemoGitPipeline (& gitSourceGitDemoPipelineOptions {
609
+ runtimeName : opts .RuntimeName ,
610
+ gsCloneOpts : opts .GsCloneOpts ,
611
+ gitProvider : opts .GitProvider ,
612
+ gsFs : gsFs ,
613
+ hostName : opts .HostName ,
614
+ ingressHost : opts .IngressHost ,
615
+ ingressClass : opts .IngressClass ,
616
+ ingressController : opts .IngressController ,
617
+ accessMode : opts .AccessMode ,
618
+ gatewayName : opts .GatewayName ,
619
+ gatewayNamespace : opts .GatewayNamespace ,
620
+ useGatewayAPI : opts .useGatewayAPI ,
621
+ })
622
+ if err != nil {
623
+ return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
624
+ }
625
625
}
626
626
627
627
commitMsg := fmt .Sprintf ("Created demo pipelines in %s Directory" , opts .GsCloneOpts .Path ())
@@ -752,7 +752,7 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
752
752
}
753
753
754
754
func createDemoGitPipeline (opts * gitSourceGitDemoPipelineOptions ) error {
755
- if ! store . Get (). SkipIngress {
755
+ if opts . accessMode == platmodel . AccessModeIngress {
756
756
// Create an ingress that will manage external access to the git eventsource service
757
757
routeOpts := routingutil.CreateRouteOpts {
758
758
RuntimeName : opts .runtimeName ,
@@ -1532,20 +1532,22 @@ func legacyGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) er
1532
1532
return fmt .Errorf ("failed to create git-source demo resources: %w" , err )
1533
1533
}
1534
1534
} else {
1535
- if err := createPlaceholderIfNeeded (ctx , opts , gsRepo , gsFs ); err != nil {
1536
- return fmt .Errorf ("failed to create a git-source placeholder : %w" , err )
1535
+ if err := ensureGitSourceDirectory (ctx , opts , gsRepo , gsFs ); err != nil {
1536
+ return fmt .Errorf ("failed to ensure git-source directory : %w" , err )
1537
1537
}
1538
1538
}
1539
1539
1540
1540
appDef := & runtime.AppDef {
1541
- Name : opts .GsName ,
1542
- Type : application .AppTypeDirectory ,
1543
- URL : opts .GsCloneOpts .Repo ,
1541
+ Name : opts .GsName ,
1542
+ Type : application .AppTypeDirectory ,
1543
+ URL : opts .GsCloneOpts .Repo ,
1544
+ Include : opts .Include ,
1545
+ Exclude : opts .Exclude ,
1544
1546
}
1545
1547
1546
1548
appDef .IsInternal = util .StringIndexOf (store .Get ().CFInternalGitSources , appDef .Name ) > - 1
1547
1549
1548
- if err := appDef .CreateApp (ctx , nil , opts .InsCloneOpts , opts .RuntimeName , store .Get ().CFGitSourceType , opts . Include , opts . Exclude ); err != nil {
1550
+ if err := appDef .CreateApp (ctx , nil , opts .InsCloneOpts , opts .RuntimeName , store .Get ().CFGitSourceType ); err != nil {
1549
1551
return fmt .Errorf ("failed to create git-source application. Err: %w" , err )
1550
1552
}
1551
1553
0 commit comments