-
Notifications
You must be signed in to change notification settings - Fork 262
initial commit #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
initial commit #3022
Conversation
vConfig, err := project.ReadConfigFile(configFilePath, project.YAML) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can validate config file contents before proceeding.
if err != nil { | ||
return err | ||
} | ||
err = build.AddArtifacts(moduleName, "generic", artifacts...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Improvements:
- We can add error context if adding artifacts fails.
- We can add logging for successful artifact addition.
} | ||
|
||
func getBuildPropsForArtifact(buildName, buildNumber, project string) (string, error) { | ||
err := buildUtils.SaveBuildGeneralDetails(buildName, buildNumber, project) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider logging if saving general details fails.
} | ||
searchReader, err = servicesManager.SearchFiles(searchParams) | ||
if err != nil { | ||
log.Error("Failed to get uploaded npm package: ", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is specific to npm, but the function is generic.
We can update it to generic message: "Failed to get uploaded package: ..."
if err != nil { | ||
log.Warn("Unable to set build properties: ", err, "\nThis may cause build to not properly link with artifact, please add build name and build number properties on the tarball artifact manually") | ||
} | ||
buildInfoArtifacts, err := utils.ConvertArtifactsSearchDetailsToBuildInfoArtifacts(searchReader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if needed we can check for errors after converting artifacts before proceeding
func GetBuildInfoForUploadedArtifacts(uploadedFile string, buildConfiguration *buildUtils.BuildConfiguration) error { | ||
repoConfig, err := extractRepositoryConfig() | ||
if err != nil { | ||
return err | ||
} | ||
serverDetails, err := repoConfig.ServerDetails() | ||
if err != nil { | ||
return err | ||
} | ||
err = saveBuildInfo(serverDetails, repoConfig.TargetRepo(), uploadedFile, buildConfiguration) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logs and the error messages can be updated,
func GetBuildInfoForUploadedArtifacts(uploadedFile string, buildConfiguration *buildUtils.BuildConfiguration) error {
log.Info("Extracting repository configuration for build info...")
repoConfig, err := extractRepositoryConfig()
if err != nil {
log.Error("Failed to extract repository configuration: ", err)
return fmt.Errorf("extractRepositoryConfig failed: %w", err)
}
log.Info("Retrieving server details...")
serverDetails, err := repoConfig.ServerDetails()
if err != nil {
log.Error("Failed to retrieve server details: ", err)
return fmt.Errorf("ServerDetails extraction failed: %w", err)
}
log.Infof("Saving build info for uploaded file: %s", uploadedFile)
err = saveBuildInfo(serverDetails, repoConfig.TargetRepo(), uploadedFile, buildConfiguration)
if err != nil {
log.Error("Failed to save build info: ", err)
return fmt.Errorf("saveBuildInfo failed: %w", err)
}
log.Info("Successfully saved build info for uploaded artifact.")
return nil
}
err = cliutils.CreateConfigCmd(ctx, project.FromString(confType)) | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = cliutils.CreateConfigCmd(ctx, project.FromString(confType)) | |
if err != nil { | |
return err | |
} | |
if !configExists(confType) { | |
err = cliutils.CreateConfigCmd(ctx, project.FromString(confType)) | |
if err != nil { | |
return fmt.Errorf("failed to create config: %w", err) | |
} | |
} |
dev
branch.go vet ./...
.go fmt ./...
.