feat(sources): allow user to edit source [BE-12956] (#2748)
This commit is contained in:
@@ -251,3 +251,27 @@ func gitAuthMatches(a, b *gittypes.GitAuthentication) bool {
|
||||
|
||||
return a.Username == b.Username && a.Password == b.Password && a.GitCredentialID == b.GitCredentialID
|
||||
}
|
||||
|
||||
// ValidateUniqueSourceURL validates there are no other sources with the same URL
|
||||
func ValidateUniqueSourceURL(tx gitSourceStore, url string, sourceID portainer.SourceID) (bool, error) {
|
||||
normalizedURL, err := gittypes.NormalizeURL(gittypes.SanitizeURL(url))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
existing, err := tx.Source().ReadAll(func(s portainer.Source) bool {
|
||||
if s.ID == sourceID || s.Type != portainer.SourceTypeGit || s.GitConfig == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
normalized, err := gittypes.NormalizeURL(gittypes.SanitizeURL(s.GitConfig.URL))
|
||||
|
||||
return err == nil && normalized == normalizedURL
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(existing) == 0, nil
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ type WorkflowStatusObject struct {
|
||||
}
|
||||
|
||||
type Workflow struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type Type `json:"type"`
|
||||
Platform DeploymentPlatform `json:"platform"`
|
||||
Status WorkflowStatusObject `json:"status"`
|
||||
ID int `json:"id" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Type Type `json:"type" validate:"required"`
|
||||
Platform DeploymentPlatform `json:"platform" validate:"required"`
|
||||
Status WorkflowStatusObject `json:"status" validate:"required"`
|
||||
GitConfig *gittypes.RepoConfig `json:"gitConfig,omitempty"`
|
||||
AutoUpdate *portainer.AutoUpdateSettings `json:"autoUpdate,omitempty"`
|
||||
Target Target `json:"target"`
|
||||
Target Target `json:"target" validate:"required"`
|
||||
CreationDate int64 `json:"creationDate"`
|
||||
LastSyncDate int64 `json:"lastSyncDate"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user