Skip to content

feat(set-labels): migrate to SDK v1.0.4 with WithDocs support#1258

Merged
liamfallon merged 1 commit into
kptdev:mainfrom
Nordix:set_labels_sdk_withdocs
Jun 24, 2026
Merged

feat(set-labels): migrate to SDK v1.0.4 with WithDocs support#1258
liamfallon merged 1 commit into
kptdev:mainfrom
Nordix:set_labels_sdk_withdocs

Conversation

@efiacor

@efiacor efiacor commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
  • Add //go:embed for README.md and metadata.yaml
  • Pass fn.WithDocs(readme, metadata) to fn.AsMain for --help and --doc
  • Update fn.WithContext to use context.Context directly (API change)
  • Bump SDK dependency from v1.0.3 to v1.0.4

The function now supports:

  • --help: renders human-readable docs from README.md
  • --doc: renders machine-readable JSON for kpt fn doc
  • Standalone file mode (positional args)

This is Phase 2 of the SDK migration plan for the 8 already-migrated functions. The orphaned generated/docs.go is left in place for now to avoid disrupting the shared mdtogo Makefile target.

@efiacor
efiacor requested review from a team and Copilot June 9, 2026 10:31
@efiacor efiacor self-assigned this Jun 9, 2026
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 9, 2026
@efiacor efiacor added enhancement New feature or request go Pull requests that update Go code and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the set-labels KRM function to SDK fn v1.0.4 and wires in embedded function documentation so the binary can serve --help (human docs) and --doc (kpt fn doc JSON) via the SDK’s WithDocs support.

Changes:

  • Embed README.md and metadata.yaml into the Go binary and pass them via fn.WithDocs(...) to fn.AsMain.
  • Migrate fn.WithContext usage to the new context.Context-based API.
  • Bump github.com/kptdev/krm-functions-sdk/go/fn from v1.0.3 to v1.0.4.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
functions/go/set-labels/run.go Embeds README/metadata and enables --help/--doc via fn.WithDocs; updates WithContext call signature.
functions/go/set-labels/run_js.go Updates JS/WASM runner to new WithContext signature (now takes context.Context).
functions/go/set-labels/go.mod Bumps SDK dependency to v1.0.4.
functions/go/set-labels/go.sum Updates sums for SDK v1.0.4 and newly pulled transitive deps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread functions/go/set-labels/run_js.go Outdated
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for krm-function-catalog canceled.

Name Link
🔨 Latest commit 5a57914
🔍 Latest deploy log https://app.netlify.com/projects/krm-function-catalog/deploys/6a27eb6d7b5bb90008139fe6

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for krm-function-catalog canceled.

Name Link
🔨 Latest commit a392e9d
🔍 Latest deploy log https://app.netlify.com/projects/krm-function-catalog/deploys/6a27ef0a68b3f3000835d96d

- Add //go:embed for README.md and metadata.yaml
- Pass fn.WithDocs(readme, metadata) to fn.AsMain for --help and --doc
- Update fn.WithContext to use context.Context directly (API change)
- Bump SDK dependency from v1.0.3 to v1.0.4

The function now supports:
- --help: renders human-readable docs from README.md
- --doc: renders machine-readable JSON for kpt fn doc
- Standalone file mode (positional args)

This is Phase 2 of the SDK migration plan for the 8 already-migrated
functions. The orphaned generated/docs.go is left in place for now to
avoid disrupting the shared mdtogo Makefile target.

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
@efiacor
efiacor force-pushed the set_labels_sdk_withdocs branch from 5a57914 to a392e9d Compare June 9, 2026 10:46
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 9, 2026
@efiacor

efiacor commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Addresses kptdev/kpt#4516

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 10, 2026
@efiacor
efiacor requested a review from a team June 10, 2026 16:13
@liamfallon
liamfallon merged commit 2eb6685 into kptdev:main Jun 24, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update Go code lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants