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

Add Agones Kubernetes API docs generator #645

Merged
merged 1 commit into from
Mar 25, 2019

Conversation

aLekSer
Copy link
Collaborator

@aLekSer aLekSer commented Mar 12, 2019

Add gen-crd-api-reference-docs utility into build-image, generate Agones CRD reference html document, map this doc to existent docs structure.
Covers #409.

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 12, 2019

This is an initial commit. Some changes to the templates could occur in the future. Current look and feel:

Agones CRD Reference

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 0d57e618-eea9-4b9a-a7d2-955b0ccb8f15

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 12, 2019

Issue with resulting file position in Cloud Build:

Output to a file /go/src/agones.dev/agones/site/content/en/docs/Reference/agones_crd_api_reference.html
diff /workspace/site/content/en/docs/Reference/agones_crd_api_reference.html /tmp/generated.html

Locally I have for test-gen-api-docs: expected_docs := $(site_path)/$(REL_PATH) :

diff /Users/alexander.apalikov/go/src/agones.dev/agones/site/content/en/docs/Reference/agones_crd_api_reference.html /tmp/generated.html

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 7d2b8038-01f1-489c-9e06-38b1c8f6bb5b

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: ec4f0130-15f3-407e-8536-f52a56a023ac

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 12, 2019

Found an issue, I have added the special kubebuilder declaration in /pkg/apis/stable/v1alpha1/gameserver.go, which is redundant, like that:

// +kubebuilder:resource:path=gameservers

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 96fa6cbf-bb93-4d46-8ea3-4b4bd8bbb781

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-b226b37

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

We should probably reference the new page on https://agones.dev/site/docs/guides/access-api/

Otherwise, this looks amazing! Had some questions below about how to manage the bleeding edge.

@@ -24,6 +24,23 @@
# Website targets
#

REL_PATH := content/en/docs/Reference/agones_crd_api_reference.html
API_DOC_PATH := "$(mount_path)/site/$(REL_PATH)"
GEN_API_DOCS ?= docker run -e FILE=$(API_DOC_PATH) --rm -i $(common_mounts) $(build_tag) bash -c "/go/src/agones.dev/agones/site/gen-api-docs.sh"
Copy link
Member

Choose a reason for hiding this comment

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

Curious as to the motivation to put all of this in variables? Seems like it wouldn't change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added those options to be able to split test html result and normal one. GEN_API_DOCS used twice, that's why it was extracted.

@@ -59,6 +76,7 @@ site-deploy-preview: site-static-preview

site-test:
# generate actual html and run test against - provides a more accurate tests
$(MAKE) test-gen-api-docs
Copy link
Member

Choose a reason for hiding this comment

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

I don't have a good answer for this - but because the website works off master - if we change our CRD data structures, that will change the website as well, and be out of sync until next release.

Only idea I've got - that in the advent of that happening - rename the old page and put an expiryDate of the next release in the toml.... but how would we get a publishDate in the new one, and still pass tests?

I'm just thinking out loud here, but any ideas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried to use custom short code in front-matter and it seems that variables are not supported there.
So currently I am thinking of combining one full generated html with expiryVersion shortcode. And new one with publishVersion shortcode in the same file.
And during test just compare the second half with publishVersion. And during release move bottom half to the top and generate new one at the bottom.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds fancy - but makes sense to me! I assume you can make that work? 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have updated gen-api-docs.sh script. It now handles base_version environment variable.
What it does is get all lines before publishVersion line. Then extract what in the middle of this feature shortcode. Compares with what was generated if diff then do version compare.
Then set expiryVersion of old part with new base_version fresh generated doc now have new publishVersion.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 75d62778-eb37-40d8-a9da-f1efd4fcafc9

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 14, 2019

Reworked generation script it now handles the version in publishVersion shortcode.
Old code becomes expiredVersion with new base_version. Test now compares only what is in the middle of publishVersion with the output of go tool gen-crd-api-reference-docs.
Two calls to awk and one sed do the job.
We don't need to care about switching the versions on release process - it is automated for this file.

@aLekSer aLekSer force-pushed the api-docs-generation branch 2 times, most recently from 4fa7575 to 9e6b85a Compare March 14, 2019 14:38
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 507ee387-19d4-4874-a52d-d1751d1e54cb

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: dd261584-206a-4d53-a568-3d419ea693c3

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: ff3a87dc-93b5-465d-8773-c8f900f38e91

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-2996acc

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: ca835708-a565-4674-a317-627f3f0af47c

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 615bafc8-a477-4be4-9411-534826f41cfe

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-69a97ad

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 16, 2019

I think I need to add md instructions on how to use new make target gen-api-docs. It was created to work in a similar way to make gen-install when we call this on each crd update and just git add the resulted .../Reference/agones_crd_api_reference.html. So basically two subsequent calls of $(MAKE) test-gen-api-docs would result in pass the test, but on CI if someone forgot to commit this html than test would fail.

@aLekSer aLekSer force-pushed the api-docs-generation branch 2 times, most recently from 363d979 to 87798f8 Compare March 18, 2019 16:17
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 50f9b339-45ab-4cf6-9ea2-0c84f8b0f855

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-363d979

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f83d51da-1af9-497d-8958-b857fd814143

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-87798f8

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 19, 2019

Fixed one issue, there was a commit-id in a default template. So I removed it, so now different git commit would generate the same html.
https://github.com/GoogleCloudPlatform/agones/pull/645/files#diff-b75745dde8c5e52ecb85780a42ac3669

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: dca396f0-df09-43bd-b952-a267c69edc80

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-1d683f7

@@ -24,6 +24,22 @@
# Website targets
#

REL_PATH := content/en/docs/Reference/agones_crd_api_reference.html
GEN_API_DOCS ?= docker run -e FILE="$(mount_path)/site/$(REL_PATH)" -e VERSION=${base_version} --rm -i $(common_mounts) $(build_tag) bash -c "/go/src/agones.dev/agones/site/gen-api-docs.sh"
Copy link
Member

Choose a reason for hiding this comment

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

Super minor nit on this - should this be := rather than ?= , since I don't think anyone should be overwriting the GEN_API_DOCS command?

which can be accessed and manipulated through the Kubernetes API.
which can be accessed and manipulated through the Kubernetes API.

{{% feature publishVersion="0.9.0" %}}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the CRDs have changed - could we publish this all now? (0.8.0?)

Copy link
Collaborator Author

@aLekSer aLekSer Mar 25, 2019

Choose a reason for hiding this comment

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

Updated publishVersion, test still pass.

@markmandel
Copy link
Member

Apologies - looks like I never submitted those comments :/ they've been sitting there forever. But otherwise, this is good to go.

@aLekSer
Copy link
Collaborator Author

aLekSer commented Mar 25, 2019

Merged master, fixed publishVersion and Makefile parameter.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 22e8da75-dd1b-49d1-b804-ec69259ed6d7

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: fc9feedc-adba-4e18-b303-ce1eaff06f66

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-8e3b89f

Add gen-crd-api-reference-docs utility into build-image, generate
Agones CRD reference html document, map this doc to existent docs
structure.
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f9a616c7-3582-465a-832e-fb93fa661b61

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/645/head:pr_645 && git checkout pr_645
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-4a1b4a9

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Awesome! 👍

@markmandel markmandel merged commit 7368392 into googleforgames:master Mar 25, 2019
@markmandel markmandel added area/site The website itself - including redirects, styling, search, etc kind/documentation Documentation for Agones kind/feature New features for Agones labels Mar 26, 2019
@markmandel markmandel added this to the 0.9.0 milestone Mar 26, 2019
@@ -123,6 +123,11 @@ RUN mkdir /tmp/hugo && \
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
apt-get install -y nodejs

# install API reference docs generator
RUN mkdir -p /go/src/github.com/ahmetb && \
cd /go/src/github.com/ahmetb && git clone https://github.com/ahmetb/gen-crd-api-reference-docs && \
Copy link

Choose a reason for hiding this comment

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

I think you should probably pin to a commit here.
Given there's a copy of the template in this repo, I don't want to accidentally break the downstream.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @ahmetb for the review. I was thinking about that, will provide an update in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/site The website itself - including redirects, styling, search, etc kind/documentation Documentation for Agones kind/feature New features for Agones
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants