mirror of
https://github.com/portainer/portainer.git
synced 2026-06-23 04:20:11 +00:00
ae1b6b8a71
Co-authored-by: Claude <noreply@anthropic.com>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package workflows
|
|
|
|
import (
|
|
"context"
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
gittypes "github.com/portainer/portainer/api/git/types"
|
|
wf "github.com/portainer/portainer/api/gitops/workflows"
|
|
)
|
|
|
|
func computeGitPhases(ctx context.Context, gitSvc portainer.GitService, cfg *gittypes.RepoConfig) (source, artifact wf.WorkflowPhaseStatus) {
|
|
if gitSvc == nil || cfg == nil {
|
|
return wf.WorkflowPhaseStatus{Status: wf.StatusUnknown}, wf.WorkflowPhaseStatus{Status: wf.StatusUnknown}
|
|
}
|
|
|
|
username, password := gitCredentials(cfg)
|
|
return wf.ComputeGitPhases(ctx, cfg.ReferenceName, cfg.ConfigFilePath,
|
|
func(ctx context.Context) ([]string, error) {
|
|
return gitSvc.ListRefs(ctx, cfg.URL, username, password, false, cfg.TLSSkipVerify)
|
|
},
|
|
func(ctx context.Context, exts []string) ([]string, error) {
|
|
return gitSvc.ListFiles(ctx, cfg.URL, cfg.ReferenceName, username, password, false, false, exts, cfg.TLSSkipVerify)
|
|
},
|
|
)
|
|
}
|
|
|
|
func gitCredentials(cfg *gittypes.RepoConfig) (username, password string) {
|
|
if cfg.Authentication != nil {
|
|
return cfg.Authentication.Username, cfg.Authentication.Password
|
|
}
|
|
return "", ""
|
|
}
|