@@ -193,13 +193,17 @@ func ComponentVersionQuestionFunc(f func(p Plugin, question *ComponentVersionQue
193
193
}
194
194
}
195
195
196
- func ComponentReferenceQuestionFunc (f func (p Plugin , question * ComponentReferenceQuestionArguments ) (bool , error )) QuestionResultFunc {
196
+ type ComponentReferenceQuestionFunc = func (p Plugin , question * ComponentReferenceQuestionArguments ) (bool , error )
197
+
198
+ func ForComponentReferenceQuestion (f func (p Plugin , question * ComponentReferenceQuestionArguments ) (bool , error )) QuestionResultFunc {
197
199
return func (p Plugin , question QuestionArguments ) (bool , error ) {
198
200
return f (p , question .(* ComponentReferenceQuestionArguments ))
199
201
}
200
202
}
201
203
202
- func ArtifactQuestionFunc (f func (p Plugin , question * ArtifactQuestionArguments ) (bool , error )) QuestionResultFunc {
204
+ type ArtifactQuestionFunc = func (p Plugin , question * ArtifactQuestionArguments ) (bool , error )
205
+
206
+ func ForArtifactQuestion (f ArtifactQuestionFunc ) QuestionResultFunc {
203
207
return func (p Plugin , question QuestionArguments ) (bool , error ) {
204
208
return f (p , question .(* ArtifactQuestionArguments ))
205
209
}
@@ -212,7 +216,7 @@ type defaultDecisionHandler struct {
212
216
213
217
// NewDecisionHandler provides a default decision handler based on its standard
214
218
// fields and a handler function.
215
- func NewDecisionHandler (q , desc string , h func ( p Plugin , question QuestionArguments ) ( bool , error ) , labels ... string ) DecisionHandler {
219
+ func NewDecisionHandler (q , desc string , h QuestionResultFunc , labels ... string ) DecisionHandler {
216
220
return & defaultDecisionHandler {
217
221
DecisionHandlerBase : NewDecisionHandlerBase (q , desc , labels ... ),
218
222
handler : h ,
@@ -223,6 +227,37 @@ func (d *defaultDecisionHandler) DecideOn(p Plugin, question QuestionArguments)
223
227
return d .handler (p , question )
224
228
}
225
229
230
+ ////////////////////////////////////////////////////////////////////////////////
231
+ // specialized handler creation
232
+
233
+ func NewTransferResourceDecision (desc string , h ArtifactQuestionFunc , labels ... string ) DecisionHandler {
234
+ return NewDecisionHandler (Q_TRANSFER_RESOURCE , desc , ForArtifactQuestion (h ))
235
+ }
236
+
237
+ func NewTransferSourceDecision (desc string , h ArtifactQuestionFunc , labels ... string ) DecisionHandler {
238
+ return NewDecisionHandler (Q_TRANSFER_SOURCE , desc , ForArtifactQuestion (h ))
239
+ }
240
+
241
+ func NewEnforceTransportDesision (desc string , h ComponentReferenceQuestionFunc , labels ... string ) DecisionHandler {
242
+ return NewDecisionHandler (Q_ENFORCE_TRANSPORT , desc , ForComponentReferenceQuestion (h ))
243
+ }
244
+
245
+ func NewTransferversionDecision (desc string , h ComponentReferenceQuestionFunc , labels ... string ) DecisionHandler {
246
+ return NewDecisionHandler (Q_TRANSFER_VERSION , desc , ForComponentReferenceQuestion (h ))
247
+ }
248
+
249
+ func NewOverwriteVersionDecision (desc string , h ComponentReferenceQuestionFunc , labels ... string ) DecisionHandler {
250
+ return NewDecisionHandler (Q_OVERWRITE_VERSION , desc , ForComponentReferenceQuestion (h ))
251
+ }
252
+
253
+ func NewUpdateVersionDecision (desc string , h ComponentReferenceQuestionFunc , labels ... string ) DecisionHandler {
254
+ return NewDecisionHandler (Q_UPDATE_VERSION , desc , ForComponentReferenceQuestion (h ))
255
+ }
256
+
257
+ func NewOUpdateVersionDecision (desc string , h ComponentReferenceQuestionFunc , labels ... string ) DecisionHandler {
258
+ return NewDecisionHandler (Q_UPDATE_VERSION , desc , ForComponentReferenceQuestion (h ))
259
+ }
260
+
226
261
////////////////////////////////////////////////////////////////////////////////
227
262
228
263
// Config is a generic structured config stored in a string map.
0 commit comments