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

fix: issues with the given samples #3415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions site/book/05-developing-functions/02-developing-in-Go.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-sdk.git/go/get
cd ${FUNCTION_NAME}

# Initialize the Go module
go mod init
go mod init kpt-fn/set-annotation
Copy link
Contributor

@yuwenma yuwenma Jul 25, 2022

Choose a reason for hiding this comment

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

May the "without. a module name throws an error" caused by missing ln 32?

Since we need to run go mod tidy, it's better to cd into the ${FUNCTION_NAME}. Otherwise we need to add ln 32 after go mod init ${FUNCTION_NAME}.

Copy link
Author

Choose a reason for hiding this comment

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

I've tried both ways:

  • First cd ${FUNCTION_NAME} and then do go mod init
  • First go mod init

In both cases I get the error

go: cannot determine module path for source directory /tmp/kpt/set-annotation (outside GOPATH, module path must be specified)

Example usage:
	'go mod init example.com/m' to initialize a v0 or v1 module
	'go mod init example.com/m/v2' to initialize a v2 module

Run 'go help mod init' for more information.

Sorry, I am quite new to Go and not completely sure if I am missing some specific setup in my environment.

go mod tidy
```

Expand Down Expand Up @@ -78,7 +78,7 @@ adds the annotation. After the iteration, it adds some user message to the `Reso
```go
func Run(rl *fn.ResourceList) (bool, error) {
for _, kubeObject := range rl.Items {
if kubeObject.IsGVK("apps/v1", "Deployment") {
if kubeObject.IsGVK("apps", "v1", "Deployment") {
kubeObject.SetAnnotation("config.kubernetes.io/managed-by", "kpt")
}
}
Expand Down