Skip to content

[feature] Kubernetes resource exporter#45

Open
Kukkerem wants to merge 2 commits intomainfrom
chore/tutorial-cont
Open

[feature] Kubernetes resource exporter#45
Kukkerem wants to merge 2 commits intomainfrom
chore/tutorial-cont

Conversation

@Kukkerem
Copy link
Copy Markdown
Contributor

@Kukkerem Kukkerem commented Apr 7, 2026

  • Replace the hardcoded tutorial stub with a real Kubernetes exporter so the example can read Namespaces, ClusterRoles, and Pods from a cluster.

  • Expand the tutorial for the new workflow and update Go/Nix dependencies to build the example.

#30 #31 #32

Replace the hardcoded tutorial stub with a real Kubernetes exporter so the example can read Namespaces, ClusterRoles, and Pods from a cluster. Expand the tutorial for the new workflow and update Go/Nix dependencies to build the example.
Copy link
Copy Markdown
Contributor

@gergely-szabo-sap gergely-szabo-sap left a comment

Choose a reason for hiding this comment

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

I suggested an improvement. Otherwise, it's a beautiful work!

🥇

Comment on lines +100 to +111
func uniqueStrings(values []string) []string {
seen := make(map[string]struct{}, len(values))
unique := make([]string, 0, len(values))
for _, value := range values {
if _, ok := seen[value]; ok {
continue
}
seen[value] = struct{}{}
unique = append(unique, value)
}
return unique
}
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.

No need to change, but a more elegant implementation of this function could be provided by using https://pkg.go.dev/maps#Keys and https://pkg.go.dev/slices#Collect.

You build up the seen map as before and simply collect the keys.

Comment on lines +20 to +23
type collectedResource struct {
key string
object resource.Object
}
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.

I find the collectedResource type too artificial in this example. Here, it serves as temporary storage for resources to be exported.

I would prefer to emit resources as soon as they are available (stream the resources) instead of collecting them in collectedResource first.

If we want to demonstrate the mkcontainer types, you could use them to cache the namespaces there. For example, if the user exports both Namespaces and Pods, you can avoid collecting the namespaces twice. Collect them in the mkcontainer type when you first need them, and retrieve them from the mkcontainer when you need them again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Validation

Development

Successfully merging this pull request may close these issues.

2 participants