-
Notifications
You must be signed in to change notification settings - Fork 44
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
Go tutorial and reference #723
base: main
Are you sure you want to change the base?
Conversation
fa851bb
to
47903ac
Compare
47903ac
to
e74cf0c
Compare
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.
Looked at the tutorial, I think it is a good start
docs/tutorial/go.rst
Outdated
:dedent: 2 | ||
|
||
|
||
Add another binary to the Go application |
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.
A lot of the other tutorials demonstrate how to update the application? I think this is fine to include perhaps as another step since we don't have the chisel anyway?
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.
replied in the next comment.
docs/tutorial/go.rst
Outdated
Add the following snippet to the file ``rockcraft.yaml``, so the new binary is | ||
set as the main application to run: |
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.
Hmm, I don't follow why we would suggest the user does this?
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.
I did this because I think it is one of the pain points of the extension. Many Go projects have the binaries under cmd/, sometimes being one the server and the other ones could be for example command line tools.
I put this example to show how to use another binary, and at the same time how to "update" the application, put another version of the rock... Would you suggest another different example to update the app?
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.
Perhaps that can be a separate how to. I would suggest just showing perhaps adding another endpoint like the time endpoint on other tutorials
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.
I think the tutorial doesn’t flow, it doesn’t make sense at least to me that I would want to add another binary at this point, I probably would just want to add some features
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.
sure, let me try that way (adding another endpoint) and I will leave that part for a how-to (I think it is important).
I will copy the flask endpoint in Go
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.
Done!
docs/tutorial/go.rst
Outdated
for you. | ||
|
||
By default, the ``go-framework`` will use the ``bare`` base. You can improve | ||
the developer experience changing the base to ``[email protected]``, but the |
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.
Could we caveat what we mean by this? E.g., for debugging it might be better to use but for production we recommend bare?
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.
I have rephrased it a bit. I think it is a bit clearer now.
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.
perhaps rename this to main-time.go so that the editors recognise it as a go file?
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.
I did not use the .go
extension because otherwise it will be compiled (and will fail).
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.
Ah ok makes sense
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.
As a relatively new user, I tried to follow the tutorial but failed (there isn't a go-framework profile). But I still read through the tutorial thoroughly. There are some nitpicking comments, but mostly are my thoughts on naming consistency and content organisation. See comments inline.
Setup | ||
===== | ||
|
||
.. include:: /reuse/tutorial/setup.rst |
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.
I know this is a piece of existing reusable content and not in the scope of this PR, but in reuse/tutorial/setup.rst
, it says in the beginning that "We recommend starting from a clean Ubuntu 22.04", but in the command below when launching a multipass instance, it used 24.04. It's better to be consistent.
And, is 22.04 going to work or not? If I already have a 22.04 VM (maybe not multipass), will it work? Must rockcraft work together with multipass and LXD, or it can work alone? Do I have to create a new VM for this tutorial and do I have to use multipass for it?
Tutorials are for new users, who might not have a comprehensive understanding of the prerequisites: What is multipass? Why do I need a VM to build an OCI image, because Docker doesn't require a VM to build an image? These are the questions a new user (I am speaking from a new user's standpoint, in fact, I am a new user, and I have only used rockcraft once during my onboarding process) might have in mind when following the tutorial.
The sheer cognitive load would scare a new user away: They have to figure out what multipass is, what LXD is, why LXD has connection issues with Docker (which is a whole separate document linked in the tutorial), why I need Docker since rockcraft can build an OCI image, why would I use rockcraft to build an image since Docker is required anyway, etc.
I think if the setup is a whole lot easier (for example, brew install rockcraft
on mac, apt install
on Debian, then init, pack, done), it would attract more new users.
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.
I think it is a good point, we should remove the reference to which version of Ubuntu we start with from the shared setup
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.
Yeah, I have removed the version of Ubuntu, now it is something like:
we recommend starting from a clean Ubuntu installation. If we don't have one available, we can create one using Multipass
so also it it a "bit" clearer than Multipass is not required, and the requirement is Ubuntu. By the way, one of the reasons for Multipass is to be able to run the tutorial in macOS/Windows operating systems (rockcraft requires a Linux distribution with snapd installed).
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 recommend starting from a clean Ubuntu installation
Why do we need a clean installation though?
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 recommend a clean installation (clearly, it is not a requirement). Frankly, while there are issues with docker, I think it is a good recommendation...
docs/tutorial/go.rst
Outdated
it works. | ||
|
||
Test the Go application by using ``curl`` to send a request to the root | ||
endpoint. You may need a new terminal for this, if you are using Multipass use |
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.
Nitpicking: "You may need a new terminal for this" -- you definitely need a new terminal for this since the go-hello-world is a long-running process and when starting it, we didn't put it in the background. Might need some rewording here.
Also: "if you are using Multipass" -- we are using multipass, as specified clearly in the setup section.
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.
I think the reason I originally chose may
rather than will
is because there are other ways a user could test this. I do agree we can probably just write will
here, and can also fix up the rest of the tutorials
On Multipass, it is not guaranteed they are, we suggest using it
development process to benefit from the extra utilities provided. | ||
|
||
|
||
Run the Go rock with Docker |
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.
In this section, all the docker commands run with sudo, which I think isn't the best idea. Maybe we can do this properly by creating a docker group and adding the current user into that group following this doc?
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.
Sounds reasonable, we can probably do that in the shared setup instructions
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.
I have updated to use docker as a regular user. I have not updated the rest of tutorials (basically all of them). I would rather do it in another PR.
docs/tutorial/go.rst
Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
When deploying the Go rock, you can always get the application logs via | ||
``pebble``: |
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.
This is the very first occurrence of "pebble" in the whole rockcraft doc website: It doesn't show up on the home page, it doesn't show up in the first two tutorials, either.
Following the doc's structure, I would read the homepage, follow the first two tutorials, then follow the Go tutorial because other languages don't interest me, and bam, I met the term "pebble", and it's confusing: What is pebble?
Although there is a link, but again, this adds cognitive load for a tutorial that is supposed to be simple, as simple as building and running an OCI image.
Even if the user is already familiar with pebble or switched to the pebble doc and then back, they would still have a question mark: I already built an executable binary, why can't I just add it in the OCI image and run it, why would I need a service manager for a single executable?
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.
I think we can link to information about pebble, I don't think we should get into the details of explaining pebble here. We should update the rest of the tutorials as well
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.
I updated the tutorial so the first reference to pebble has the link. I do not think pebble will be a hurdle for the user here, as the user can just gloss over it (and run the command and see the logs). It they want to have more information about it, there is no other options except reading the docs (and explaining it here will make the tutorial complex).
Cleanup | ||
~~~~~~~ | ||
|
||
Now we have a fully functional rock for a Go application! This concludes |
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.
I find the cleanup section in the middle of a tutorial a little weird. I read "cleanup" then immediately "update go application" -- if I'm still working on the app, why do I need to clean it up now? The next step builds the image with a different tag anyway. I think it's better to keep everything that is cleanup together at the end, simply delete the multipass VM which is created in the setup section. And we can make the cleanup section as a reusable content and use it in other tutorials as well.
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.
The reason is that when we run the next image it will use the same port. I do agree we should just have this without necessarily a cleanup title and just stop the container and remove the image. We should update the rest of the tutorials as well
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.
I have updated the title to be "stop the application" instead of "cleanup". We need a title as the previous one is "View the application logs". The alternative is to put it into the "update go application".
docs/tutorial/go.rst
Outdated
|
||
.. collapse:: If using Multipass... | ||
|
||
If you created an instance using Multipass, you can also clean it up. |
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 you created an instance using Multipass" -- I did create an instance with multipass, it's the only option provided in the setup section. Is there another option? If so, maybe we can enrich the setup part. If not, we can reword this, simply delete the VM is fine?
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.
I think it depends, some users don't want to use multipass
Thank you very much for your review!. With respect to not being able to run it, it should be related to the need to refresh to the latest/edge channel (using for example |
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.
Looks good to me, thank you!
Left only a minor nitpick. Feel free to ignore that. :)
Co-authored-by: Rafid Bin Mostofa <[email protected]>
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.
Thanks! @medubelko can you please take a look at these new docs?
docs/tutorial/go.rst
Outdated
Rockcraft will compile the Go application. Run the Go application using | ||
``./go-hello-world`` to verify that it works. | ||
|
||
Test the Go application by using ``curl`` to send a request to the root |
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.
I feel like there's a jump here because 'hello world' code in Go does not typically start up an http server. Maybe some context like "The code in main.go
starts up an HTTP server listening on port 8000
, so we test it by using curl
..."
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.
@javierdelapuente Thanks for providing this for us! I found the sequence of events quite easy to follow.
I've left quite a few suggestions because tutorials end up being very long documents. If we can close these quickly I can help merge the PR before the end of the week.
docs/tutorial/go.rst
Outdated
In this tutorial, we'll create a simple Go application and learn how to | ||
containerise it in a rock, using Rockcraft's ``go-framework`` | ||
:ref:`extension <go-framework-reference>`. |
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.
For tutorials, it's important to communicate:
- An estimated completion time.
- What skills and knowledge the user ought to already have.
- The new knowledge and skills the user will gain through completion.
It would be ideal if we could add such information here.
Here's the generic form I used in another product's main tutorial. Feel free to crib from it:
It should take [x] minutes for you to complete.
You won’t need to come prepared with intricate knowledge of software packaging, but familiarity with Linux paradigms, terminal operations, and [so on] is required.
Once you complete this tutorial, you’ll [accomplish x]. You’ll gain [skill or familiarity with y], and have the experience to [task or skill].
Upon changing the Go application and re-packing the rock, if | ||
the changes are not taking effect, try running ``rockcraft clean`` and pack | ||
the rock again with ``rockcraft pack``. |
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.
Instead of linking here, I feel it would be better to simply instruct the user to run rockcraft clean
prior to repacking the rock and remove this section. Even if clean
isn't always required, it helps the reader build muscle memory of the commands they'll often need to reach for when iteratively building and testing.
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.
thanks!
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Co-authored-by: Michael DuBelko <[email protected]>
Adds a tutorial and reference docs for the Go extension