crc-org / vfkit

Apache License 2.0
125 stars 24 forks source link

Add Restful service #29

Closed baude closed 1 year ago

baude commented 1 year ago

add restful service to VFKit which defaults to tcp://localhost:8081. The URL can be changed using the newly introduced --restful-uri option. The schemes may be tcp or unix (unix domain socket). The service for the unix domain implementation is incomplete and should be considered a TODO still. users can also opt out of the service with a --restful-uri none.

the restful service now replies to three endpoints:

/vm/state GET which returns the state of the vm /vm/state POST which allows for a state change /vm/inspect GET which returns basic information about the virtual machine

error handling for the endpoints needs to be completed still. these endpoints should return http response codes (like 200) based on the error handling. this can be completed in a subsequent PR.

/version GET should also probably be added. I was unsure if we should return the version of vfkit (my first inclination) or some sort of API version. maybe we should return both?

added tests for new content where applicable

cfergeau commented 1 year ago

/version GET should also probably be added. I was unsure if we should return the version of vfkit (my first inclination) or some sort of API version. maybe we should return both?

yeah vfkit version is good to have (possibly with git hash if that's easy to get). API version, if that's about the REST API, I'd keep this for later. I'm sure we'll want to bump the API some day, but will we do this through a /version entry point, through a /v2 in the URL, .. I have no idea.

baude commented 1 year ago

should be updated now

cfergeau commented 1 year ago

/lgtm /approve

baude commented 1 year ago

I have updated the PR per your wishes

cfergeau commented 1 year ago

/lgtm /approve

openshift-ci[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: baude, cfergeau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/crc-org/vfkit/blob/main/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment