Add a way to configure plan-preview handling
What would you like to be added:
The way to configure plan-preview handling behavior.
Why is this needed:
We have some options in the planpreview package, but they are not used or are only used in the tests.
https://github.com/pipe-cd/pipecd/blob/d667a1c43fa245519079d106a717fe1e0125021a/pkg/app/piped/planpreview/handler.go#L52-L74
I can help!
Thanks, assigned to @kadai0308 👍
@Warashi Hi, not sure do I understand correct or not? Do you mean to remove all these function https://github.com/pipe-cd/pipecd/blob/d667a1c43fa245519079d106a717fe1e0125021a/pkg/app/piped/planpreview/handler.go#L52-L74
and pass parameter directly in NewHandler?
something like:
func NewHandler(
gc gitClient,
ac apiClient,
cl commandLister,
al applicationLister,
cg lastTriggeredCommitGetter,
sd secretDecrypter,
appManifestsCache cache.Cache,
cfg *config.PipedSpec,
workerNum int,
commandQueueBufferSize int,
commandCheckInterval time.Duration,
commandHandleTimeout time.Duration,
opts ...Option,
) *Handler {
if workerNum < 1 {
workerNum = defaultWorkerNum
}
if commandQueueBufferSize < 1 {
commandQueueBufferSize = defaultCommandQueueBufferSize
}
if commandCheckInterval <= 0 {
commandCheckInterval = defaultCommandCheckInterval
}
if commandHandleTimeout <= 0 {
commandHandleTimeout = defaultCommandHandleTimeout
}
opt := &options{
workerNum: workerNum,
commandQueueBufferSize: commandQueueBufferSize,
commandCheckInterval: commandCheckInterval,
commandHandleTimeout: commandHandleTimeout,
logger: zap.NewNop(),
}
for _, o := range opts {
o(opt)
}
...
@kadai0308 No, I meant adding a way to configure these values via piped's config.
I think that we have to add types/fields to the below struct and pass the values to NewHandler with optional functions. https://github.com/pipe-cd/pipecd/blob/275a1e13ed6efef6b2853616f728df467670c252/pkg/config/piped.go#L38-L83