pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Add a way to configure plan-preview handling

Open Warashi opened this issue 8 months ago • 4 comments

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

Warashi avatar Jun 04 '25 08:06 Warashi

I can help!

kadai0308 avatar Jun 11 '25 06:06 kadai0308

Thanks, assigned to @kadai0308 👍

khanhtc1202 avatar Jun 11 '25 06:06 khanhtc1202

@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 avatar Jun 11 '25 14:06 kadai0308

@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

Warashi avatar Jun 11 '25 23:06 Warashi