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

Use CLI-specific API endpoints so that fossa test works with push-only API keys #253

Merged
merged 4 commits into from
Sep 13, 2018

Conversation

lackstein
Copy link
Member

q := url.Values{}
q.Add("locator", locator.String())

// GetLatestBuild loads the most recent build for a revision.
Copy link
Member

Choose a reason for hiding this comment

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

What happens when no build exists? It would be great to add that in the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the build doesn't exist then the API returns a 404, so this should return an error.

Copy link
Member

Choose a reason for hiding this comment

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

Let's document this in the function comment.

if err != nil {
log.Fatalf("Could not marshal unresolved issues: %s", err)
}
fmt.Println(string(marshalled))
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep this until we figure out a good way to pretty-print issues. I bet there are existing users that are doing something like:

fossa test | tail -n +1 | jq < something >

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed it because we're already printing the issues here, although I suppose not as JSON.

log.Debugf("Got issues: %#v", issues)

I'll work on a better solution for pretty-printing issues, but for the moment the data isn't returned by the API.

@@ -17,15 +17,17 @@ type Issue struct {
Type string
}

type Issues struct {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this better than []Issue? Where possible, I would like to prefer simpler data structures.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm debating whether we should return any issue data at all aside from the count if a push-only API key is used.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Let's document this in the comment for Issues. Otherwise, this is very unintuitive.

case "FAILED":
return latestBuild, fmt.Errorf("failed to analyze build #%d: %s (visit FOSSA or contact support@fossa.io)", latestBuild.ID, latestBuild.Error)
return build, fmt.Errorf("failed to analyze build #%d: %s (visit FOSSA or contact support@fossa.io)", build.ID, build.Error)
default:
Copy link
Member

Choose a reason for hiding this comment

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

I would like to change this so that we continue polling on a specific build status (e.g. "IN PROGRESS"?) instead of polling by default. This way we can return an error by default (i.e. on unrecognised statuses) so we can detect bugs earlier.

Copy link
Member Author

Choose a reason for hiding this comment

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

The set of possible statuses is "CREATED" | "ASSIGNED" | "RUNNING" | "SUCCEEDED" | "FAILED", and we'd want to keep polling on anything other than succeeded or failed.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but one day that might change. When it does, I want an error to occur instead of infinite polling.

case "FAILED":
return latestBuild, fmt.Errorf("failed to analyze build #%d: %s (visit FOSSA or contact support@fossa.io)", latestBuild.ID, latestBuild.Error)
return build, fmt.Errorf("failed to analyze build #%d: %s (visit FOSSA or contact support@fossa.io)", build.ID, build.Error)
default:
Copy link
Member

Choose a reason for hiding this comment

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

Yes, but one day that might change. When it does, I want an error to occur instead of infinite polling.

q := url.Values{}
q.Add("locator", locator.String())

// GetLatestBuild loads the most recent build for a revision.
Copy link
Member

Choose a reason for hiding this comment

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

Let's document this in the function comment.

@@ -17,15 +17,17 @@ type Issue struct {
Type string
}

type Issues struct {
Copy link
Member

Choose a reason for hiding this comment

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

Got it. Let's document this in the comment for Issues. Otherwise, this is very unintuitive.

@elldritch
Copy link
Member

LGTM. Will wait until the API changes are in before merging.

@elldritch elldritch merged commit 58e029f into master Sep 13, 2018
@elldritch elldritch deleted the feat/cliAPI branch September 13, 2018 21:26
meghfossa pushed a commit that referenced this pull request Nov 12, 2021
* Suuport --branch for container scans

* Make sure branch flows through to API

* Reformat merged files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants