mirror of
https://github.com/harness/drone.git
synced 2025-05-04 02:32:10 +08:00
feat: [CDE-722]: Truncate gitspace config identifier to accommodate the unique identifier and -disk suffixes (#3667)
* feat: [CDE-722]: Truncate gitspace config name to accommodate the unique identifier and -disk suffixes
This commit is contained in:
parent
961687e883
commit
31519b68d3
@ -104,11 +104,10 @@ func (c *Controller) Create(
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
suffixUID, err := gonanoid.Generate(gitspace.AllowedUIDAlphabet, 6)
|
||||
identifier, err := buildIdentifier(in.Identifier)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not generate UID for gitspace config : %q %w", in.Identifier, err)
|
||||
return nil, fmt.Errorf("could not generate identrifier for gitspace config : %q %w", in.Identifier, err)
|
||||
}
|
||||
identifier := strings.ToLower(in.Identifier + "-" + suffixUID)
|
||||
now := time.Now().UnixMilli()
|
||||
var gitspaceConfig *types.GitspaceConfig
|
||||
// assume resource to be in same space if it's not explicitly specified.
|
||||
@ -281,3 +280,14 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildIdentifier(identifier string) (string, error) {
|
||||
suffixUID, err := gonanoid.Generate(gitspace.AllowedUIDAlphabet, 6)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not generate UID for gitspace config : %q %w", identifier, err)
|
||||
}
|
||||
if len(identifier) > 50 {
|
||||
identifier = identifier[:50]
|
||||
}
|
||||
return strings.ToLower(identifier + "-" + suffixUID), nil
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ const (
|
||||
UpstreamConfigSourceDockerhub UpstreamConfigSource = "Dockerhub"
|
||||
UpstreamConfigSourceMavenCentral UpstreamConfigSource = "MavenCentral"
|
||||
UpstreamConfigSourcePyPi UpstreamConfigSource = "PyPi"
|
||||
UpstreamConfigSourceNpmjs UpstreamConfigSource = "NpmJs"
|
||||
UpstreamConfigSourceNpmjs UpstreamConfigSource = "NpmJs"
|
||||
)
|
||||
|
||||
// Defines values for WebhookExecResult.
|
||||
|
Loading…
Reference in New Issue
Block a user