-
Notifications
You must be signed in to change notification settings - Fork 813
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
Convert shell script to Go #3413
Conversation
Build Failed 😱 Build Id: 4a6b92de-88d8-45e1-babc-ff78d326c5f7 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Succeeded 👏 Build Id: cb88331b-8784-4b36-ab67-8834f183ef0c 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:
|
Build Succeeded 👏 Build Id: add2ca0e-d222-477a-8f03-015fc6436d13 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:
|
@gongmax I'll let you decide when we've got what we need from this 👍🏻 |
Build Succeeded 👏 Build Id: d6a83ed9-30ad-45db-9590-68c9aa8a1726 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:
|
Meta question: Is it time to convert this into a little Go program? |
Build Succeeded 👏 Build Id: 1d354c62-854f-4b55-a0fc-e8393518eccb 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:
|
@markmandel, I really need your help to convert the bash script into a Go script. It looks like the initial steps in the bash script to set the shell options (errexit, nounset, and pipefail) aren't required in Go. Please correct me if I'm wrong. Could you please kindly split the tasks and share the steps? |
install/helm/agones/templates/crds/k8s/_io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.yaml
Show resolved
Hide resolved
Build Failed 😱 Build Id: 0f496cc1-c315-4e85-85a3-0a4e47f67473 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Will also need a |
} | ||
|
||
// Start the kubectl proxy. | ||
cmd := exec.Command("kubectl", "proxy") |
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.
So we're running kubectl proxy
here... so it should be started.
We might want to print/log the output from the command, to make sure it's doing what we expect.
(this might need to be put in a Go routine, since calling any of the output commands such as: https://pkg.go.dev/os/exec#Cmd.Output will block).
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.
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.
Can he be implemented using client-go here?
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.
Goroutine encountered an error: Failed to start kubectl proxy: signal: interrupt
. I've excluded it.
I used the same target, gen-embedded-openapi
, and it successfully executed using the Go script with the -mod=mod
option. No modifications were needed in the Kubernetes checklist.
Pending task:
Check nullable=true
missing in yaml file
Build Failed 😱 Build Id: 3107b9d9-3295-4f51-bb75-daa2f2d09503 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: 3d1fc787-038f-481d-b272-de3cb32f6a90 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: 7fa293a3-0c19-41a5-8b20-6d8e6d54031e To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
go.mod
Outdated
@@ -74,6 +74,7 @@ require ( | |||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect | |||
github.com/hashicorp/hcl v1.0.0 // indirect | |||
github.com/imdario/mergo v0.3.6 // indirect | |||
github.com/itchyny/json2yaml v0.1.4 // indirect |
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 should all be reset - there should be changes to the go.mod here or the go.sum I don't think.
vendor/modules.txt
Outdated
@@ -239,6 +239,8 @@ github.com/heptiolabs/healthcheck | |||
# github.com/imdario/mergo v0.3.6 | |||
## explicit | |||
github.com/imdario/mergo | |||
# github.com/itchyny/json2yaml v0.1.4 |
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 don't think this should be here either.
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.
CI build complains🤔
go: inconsistent vendoring in /go/src/agones.dev/agones:
github.com/itchyny/json2yaml@v0.1.4: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
To ignore the vendor directory, use -mod=readonly or -mod=mod.
To sync the vendor directory, run:
go mod vendor
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.
Alright, if you say so, there must be a reason behind it. I've reverted the changes in go.sum, go.mod, and vendor/modules.txt
Yaml files look good to me. Could you please review the updated yaml files and share your thoughts?
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.
Oh no, If I run the code the go.sum and go.mod files are automatically updated. I guess this is because of -mod=mod
?
gen-embedded-openapi: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run -mod=mod build/scripts/k8s-export-openapi/main.go
However, the code is failing without -mod=mod
. What could be the solution?
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.
Maybe a silly question - what happens if we do:
gen-embedded-openapi: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path)/build/scripts/k8s-export-openapi $(DOCKER_RUN_ARGS) $(build_tag) \
go run -mod=mod ./main.go
(Might not need the -mod=mod
either at that point?)
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 believe that if the workdir
changes, the paths to other files in the code will also need to be modified.
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.
Try it? I expect the script will fail, but we'll see if it updates the other go.mod and go.sum files -- and if it doesn't, then we know making the path changes worth it.
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 good news is - with the agones/go.mod and agones/go.sum changes reverted - CI is passing again - so that's at least a step in the right direction!
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.
Script passed with the below modifications and it didn't modify the go.mod and go.sum files.
tmpDir := "../../tmp"
boilerplateContent, err := os.ReadFile("../../boilerplate.yaml.txt")
outputPath := filepath.Join("../../../install/helm/agones/templates/crds/k8s", "_"+filename+".yaml")
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.
Love it 😄
Build Succeeded 👏 Build Id: e96e0a2a-da2f-41ff-8f48-4e392e5710d7 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:
|
Build Succeeded 👏 Build Id: 5a0fbf76-e380-435f-832d-822bce7d3456 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:
|
CI build came out green. Does everything look good? |
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 looks good to me! @gongmax did you want to also give it a once over before I merge, to make sure I didn't miss anything?
Taking a look... |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gongmax, Kalaiselvi84, markmandel 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:
Approvers can indicate their approval by writing |
YAY! THE BASH MONSTROSITY I SHOULD NEVER HAVE WRITTEN IN THE FIRST PLACE IS NOW GONE! |
What type of PR is this?
/kind cleanup
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #
Special notes for your reviewer: