@@ -803,155 +803,15 @@ func createDemoWorkflowTemplate(ctx context.Context, gsCloneOpts *git.CloneOptio
803
803
}
804
804
805
805
func createGitSource (ctx context.Context , insCloneOpts * git.CloneOptions , gsCloneOpts * git.CloneOptions , gsName , runtimeName , cfBaseURL string ) error {
806
- var err error
807
-
808
- insRepo , insFs , err := insCloneOpts .GetRepo (ctx )
809
- if err != nil {
810
- return err
811
- }
812
-
813
- resPath := insFs .Join (apstore .Default .AppsDir , gsName , runtimeName , "resources" )
814
- eventSourceName := gsName + "-event-source"
815
- gsSyncName := gsName + "-synchronize"
816
- selectors := []eventsutil.CreateSelectorOptions {
817
- {
818
- Key : "app.kubernetes.io/instance" ,
819
- Operation : "==" ,
820
- Value : gsSyncName ,
821
- },
822
- }
823
- eventSource := eventsutil .CreateEventSource (& eventsutil.CreateEventSourceOptions {
824
- Name : eventSourceName ,
825
- Namespace : runtimeName ,
826
- ServiceAccountName : store .Get ().CodefreshSA ,
827
- EventBusName : store .Get ().EventBusName ,
828
- Resource : map [string ]eventsutil.CreateResourceEventSourceOptions {
829
- // "clusterWorkflowTemplate": {
830
- // Group: "argoproj.io",
831
- // Version: "v1alpha1",
832
- // Resource: "clusterworkflowtemplates",
833
- // Namespace: runtimeName,
834
- // Selectors: selectors,
835
- // },
836
- "cronWorkflow" : {
837
- Group : "argoproj.io" ,
838
- Version : "v1alpha1" ,
839
- Resource : "cronworkflows" ,
840
- Namespace : runtimeName ,
841
- Selectors : selectors ,
842
- },
843
- "workflowTemplate" : {
844
- Group : "argoproj.io" ,
845
- Version : "v1alpha1" ,
846
- Resource : "workflowtemplates" ,
847
- Namespace : runtimeName ,
848
- Selectors : selectors ,
849
- },
850
- "workflow" : {
851
- Group : "argoproj.io" ,
852
- Version : "v1alpha1" ,
853
- Resource : "workflows" ,
854
- Namespace : runtimeName ,
855
- Selectors : selectors ,
856
- },
857
- "appProject" : {
858
- Group : "argoproj.io" ,
859
- Version : "v1alpha1" ,
860
- Resource : "appprojects" ,
861
- Namespace : runtimeName ,
862
- Selectors : selectors ,
863
- },
864
- "application" : {
865
- Group : "argoproj.io" ,
866
- Version : "v1alpha1" ,
867
- Resource : "applications" ,
868
- Namespace : runtimeName ,
869
- Selectors : selectors ,
870
- },
871
- "eventBus" : {
872
- Group : "argoproj.io" ,
873
- Version : "v1alpha1" ,
874
- Resource : "eventbus" ,
875
- Namespace : runtimeName ,
876
- Selectors : selectors ,
877
- },
878
- "eventSource" : {
879
- Group : "argoproj.io" ,
880
- Version : "v1alpha1" ,
881
- Resource : "eventsources" ,
882
- Namespace : runtimeName ,
883
- Selectors : selectors ,
884
- },
885
- "sensor" : {
886
- Group : "argoproj.io" ,
887
- Version : "v1alpha1" ,
888
- Resource : "sensors" ,
889
- Namespace : runtimeName ,
890
- Selectors : selectors ,
891
- },
892
- "rollout" : {
893
- Group : "argoproj.io" ,
894
- Version : "v1alpha1" ,
895
- Resource : "rollouts" ,
896
- Namespace : runtimeName ,
897
- Selectors : selectors ,
898
- },
899
- },
900
- })
901
- if err := insFs .WriteYamls (insFs .Join (resPath , "event-source.yaml" ), eventSource ); err != nil {
902
- return err
903
- }
904
-
905
- sensor := eventsutil .CreateSensor (& eventsutil.CreateSensorOptions {
906
- Name : gsName + "-sensor" ,
907
- Namespace : runtimeName ,
908
- EventSourceName : eventSourceName ,
909
- EventBusName : store .Get ().EventBusName ,
910
- TriggerURL : cfBaseURL + store .Get ().EventReportingEndpoint ,
911
- Triggers : []string {
912
- // "clusterWorkflowTemplate",
913
- "workflowTemplate" ,
914
- "workflow" ,
915
- "appProject" ,
916
- "application" ,
917
- "eventBus" ,
918
- "eventSource" ,
919
- "sensor" ,
920
- "rollout" ,
921
- },
922
- })
923
- if err = insFs .WriteYamls (insFs .Join (resPath , "sensor.yaml" ), sensor ); err != nil {
924
- return err
925
- }
926
-
927
806
gsPath := gsCloneOpts .FS .Join (apstore .Default .AppsDir , gsName , runtimeName )
928
807
fullGsPath := gsCloneOpts .FS .Join (gsCloneOpts .FS .Root (), gsPath )[1 :]
929
- syncApp := cdutil .CreateApp (& cdutil.CreateAppOptions {
930
- Name : gsSyncName ,
931
- Namespace : runtimeName ,
932
- Project : runtimeName ,
933
- SyncWave : 10 ,
934
- RepoURL : gsCloneOpts .URL (),
935
- Revision : gsCloneOpts .Revision (),
936
- SrcPath : fullGsPath ,
937
- })
938
- if err = insFs .WriteYamls (insFs .Join (resPath , gsName + "-synchronize.yaml" ), syncApp ); err != nil {
939
- return err
940
- }
941
-
942
- _ , err = insRepo .Persist (ctx , & git.PushOptions {
943
- CommitMsg : fmt .Sprintf ("Created %s Resources" , gsName ),
944
- })
945
- if err != nil {
946
- return err
947
- }
948
808
949
809
appDef := & runtime.AppDef {
950
810
Name : gsName ,
951
811
Type : application .AppTypeDirectory ,
952
- URL : insCloneOpts .URL () + insFs . Join ( insFs . Root (), resPath ) ,
812
+ URL : gsCloneOpts .URL () + fullGsPath ,
953
813
}
954
- if err = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName , store .Get ().CFGitSourceType , nil ); err != nil {
814
+ if err : = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName , store .Get ().CFGitSourceType , nil ); err != nil {
955
815
return fmt .Errorf ("failed to create git-source: %w" , err )
956
816
}
957
817
0 commit comments