Skip to content
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

Implement Project upload with V4 and selectable items. #48

Merged
merged 5 commits into from
Mar 13, 2024

Conversation

garnold54
Copy link
Collaborator

The project upload was previously using the V3 API. This pull request will use the V4 API on builds that support it. This also allows for selectable items to be excluded if desired.

@garnold54 garnold54 requested a review from jkerssens March 12, 2024 16:50
Copy link
Contributor

@jkerssens jkerssens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just noted a few smalll things that I came across

cmd/projects_upload.go Outdated Show resolved Hide resolved
time.Sleep(1 * time.Second)
tries++
} else {
return errors.New("import task did not complete successfully. Status is \"" + importStatus.Status + "\". Please check the FME Flow web interface for the status of the import task")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.New("import task did not complete successfully. Status is \"" + importStatus.Status + "\". Please check the FME Flow web interface for the status of the import task")
return errors.New("Import task did not complete successfully. Status is \"" + importStatus.Status + "\". Please check the FME Flow web interface for the status of the import task")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go is actually picky about this and shouldn't start with a capital letter: https://go.dev/wiki/CodeReviewComments#error-strings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake!

cmd/projects_upload.go Outdated Show resolved Hide resolved
cmd/projects_upload.go Outdated Show resolved Hide resolved
if importStatus.Status == "imported" {
finished = true
} else if importStatus.Status != "importing" {
return errors.New("import task did not complete successfully. Please check the FME Flow web interface for the status of the import task")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.New("import task did not complete successfully. Please check the FME Flow web interface for the status of the import task")
return errors.New("Import task did not complete successfully. Please check the FME Flow web interface for the status of the import task")

cmd/projects_upload.go Show resolved Hide resolved
cmd/projects_upload.go Outdated Show resolved Hide resolved
// validate that the selected items are the correct format
match, _ := regexp.MatchString(`^([^:,]+:[^:,]+,)*([^:,]+:[^:,]+)$`, f.selectedItems)
if !match {
return errors.New("invalid selected items. Must be a comma separated list of item ids and types. e.g. item1:itemtype1,item2:itemtype2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.New("invalid selected items. Must be a comma separated list of item ids and types. e.g. item1:itemtype1,item2:itemtype2")
return errors.New("Invalid selected items. Must be a comma separated list of item ids and types. e.g. item1:itemtype1,item2:itemtype2")

}
}
if !found {
return errors.New("selected item " + id + " (" + itemType + ") is not in the list of selectable items")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.New("selected item " + id + " (" + itemType + ") is not in the list of selectable items")
return errors.New("Selected item " + id + " (" + itemType + ") is not in the list of selectable items")

@garnold54
Copy link
Collaborator Author

Thanks! I have made the changes suggested, with the exception of the error message capitalization: https://go.dev/wiki/CodeReviewComments#error-strings

@garnold54 garnold54 merged commit f88e5cc into main Mar 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants