@@ -10,6 +10,12 @@ import com.dtolabs.rundeck.core.resources.format.ResourceFormatParser
1010import com.dtolabs.rundeck.core.resources.format.ResourceFormatParserException
1111import com.dtolabs.rundeck.core.resources.format.UnsupportedFormatException
1212import com.dtolabs.utils.Streams
13+ import com.dtolabs.rundeck.core.execution.ExecutionContext ;
14+ import com.dtolabs.rundeck.core.execution.ExecutionContextImpl ;
15+ import com.rundeck.plugin.util.GitPluginUtil
16+ import org.rundeck.app.spi.Services ;
17+ import com.dtolabs.rundeck.core.storage.keys.KeyStorageTree ;
18+ import com.dtolabs.rundeck.core.execution.ExecutionListener
1319
1420
1521/**
@@ -31,6 +37,42 @@ class GitResourceModel implements ResourceModelSource , WriteableModelSource{
3137 this . writable= true ;
3238 }
3339
40+ GitResourceModel (Services services , Properties configuration , Framework framework ) {
41+
42+ this . configuration = configuration
43+ this . framework = framework
44+
45+ this . extension= configuration. getProperty(GitResourceModelFactory . GIT_FORMAT_FILE )
46+ this . writable= Boolean . valueOf(configuration. getProperty(GitResourceModelFactory . WRITABLE ))
47+ this . fileName= configuration. getProperty(GitResourceModelFactory . GIT_FILE )
48+ this . localPath= configuration. getProperty(GitResourceModelFactory . GIT_BASE_DIRECTORY )
49+
50+ if (gitManager== null ){
51+ gitManager = new GitManager (configuration)
52+ }
53+
54+ ExecutionContext context = null ;
55+
56+ if (services!= null ){
57+ context = new ExecutionContextImpl.Builder ()
58+ .framework(framework)
59+ .storageTree(services. getService(KeyStorageTree . class))
60+ .build();
61+ }else {
62+ context = new ExecutionContextImpl.Builder ()
63+ .framework(framework)
64+ .build();
65+ }
66+
67+ if (configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE )){
68+ def password = GitPluginUtil . getFromKeyStorage(configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE ), context)
69+ gitManager. setGitPassword(password)
70+ }
71+
72+ if (configuration. getProperty(GitResourceModelFactory . GIT_KEY_STORAGE )) {
73+ gitManager. setSshPrivateKeyPath(configuration. getProperty(GitResourceModelFactory . GIT_KEY_STORAGE ))
74+ }
75+ }
3476
3577 GitResourceModel (Properties configuration , Framework framework ) {
3678 this . configuration = configuration
@@ -45,10 +87,21 @@ class GitResourceModel implements ResourceModelSource , WriteableModelSource{
4587 gitManager = new GitManager (configuration)
4688 }
4789
48- if (configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE )) {
49- gitManager. setGitPassword(configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE ))
90+ ExecutionContext context = new ExecutionContextImpl.Builder ()
91+ .framework(this . framework)
92+ .storageTree(services. getService(KeyStorageTree . class))
93+ .build();
94+
95+
96+ if (configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE )){
97+ def password = GitPluginUtil . getFromKeyStorage(configuration. getProperty(GitResourceModelFactory . GIT_PASSWORD_STORAGE ), context)
98+ gitManager. setGitPassword(password)
5099 }
51100
101+ // if(configuration.getProperty(GitResourceModelFactory.GIT_PASSWORD_STORAGE)) {
102+ // gitManager.setGitPassword(configuration.getProperty(GitResourceModelFactory.GIT_PASSWORD_STORAGE))
103+ // }
104+
52105 if (configuration. getProperty(GitResourceModelFactory . GIT_KEY_STORAGE )) {
53106 gitManager. setSshPrivateKeyPath(configuration. getProperty(GitResourceModelFactory . GIT_KEY_STORAGE ))
54107 }
0 commit comments