Skip to content

Template cmd: Fetch custom template from API#134

Merged
rlecomte merged 8 commits into
mainfrom
pen-208-cli-use-new-template-api-to-create-yml-file
May 20, 2026
Merged

Template cmd: Fetch custom template from API#134
rlecomte merged 8 commits into
mainfrom
pen-208-cli-use-new-template-api-to-create-yml-file

Conversation

@rlecomte
Copy link
Copy Markdown
Contributor

@rlecomte rlecomte commented May 19, 2026

Summary

Hooks the CLI into Console's new template API (/public/console/v2/{kind}-template) for Topic and Connector kinds. Other kinds keep returning the built-in offline example.

# Built-in offline example (any kind)
conduktor template Topic

# Fetch a named server-side template
conduktor template Topic high-throughput-topic

# List available server-side templates (one per line)
conduktor template Topic --list

# Pick a server-side template interactively
conduktor template Topic --interactive

# Combine with existing flags
conduktor template Topic high-throughput-topic -o topic.yml -e -a
conduktor template Topic -i -o topic.yml -e -a

--list and --interactive are mutually exclusive with each other and with a positional template name.

Test plan

  • go test ./...
  • make build
  • Manual: conduktor template Topic <name> against a Console with templates configured returns the expected YAML
  • Manual: conduktor template Topic -i lists server-side templates and applies the chosen one
  • Manual: conduktor template Topic -i <name> errors with Cannot use --interactive with a template name
  • Manual: conduktor template Topic -l prints template names one per line on stdout
  • Manual: conduktor template Topic -l <name> errors with Cannot use --list with a template name
  • Manual: conduktor template Topic -l -i errors with Cannot use --list with --interactive
  • Manual: conduktor template TopicTemplate <name> (and other unsupported kinds) returns the clear does not support resource templates error instead of the JSON parse error
  • Manual: conduktor template Topic (no name) still prints the built-in offline example

🤖 Generated with Claude Code

image

Copy link
Copy Markdown
Member

@qboileau qboileau left a comment

Choose a reason for hiding this comment

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

Could you also update documentation and README

Comment thread template.yml Outdated
Comment thread cmd/template.go Outdated
rlecomte and others added 4 commits May 20, 2026 09:34
Only Topic and Connector kinds expose the `*-template` endpoint. Fail
fast with a clear message instead of hitting the API and surfacing a
confusing JSON parse error for unsupported kinds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Note the new `template <kind> <name>` form and the Topic/Connector
restriction so users know when the API is reachable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Decouples the template-to-YAML rendering from the cmd layer so it can be
reused. Signature takes kindName/apiVersion as primitives to keep
printutils free of pkg/schema (avoids a printutils → schema → utils →
resource → printutils cycle).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@emupton
Copy link
Copy Markdown
Contributor

emupton commented May 20, 2026

Manual: conduktor template Topic (no name) still prints the built-in offline example

Would it not make sense here to just do an api call to fetch the templates and then let the user input which template they'd want to use?
i.e:

3 templates fetched for Topic templates
1. high-throughput-topic
2. staging
3. dead-letter-queue-topic
Please enter a choice from (1-3):

@qboileau
Copy link
Copy Markdown
Member

qboileau commented May 20, 2026

Manual: conduktor template Topic (no name) still prints the built-in offline example

Would it not make sense here to just do an api call to fetch the templates and then let the user input which template they'd want to use? i.e:

3 templates fetched for Topic templates
1. high-throughput-topic
2. staging
3. dead-letter-queue-topic
Please enter a choice from (1-3):

this interactive mode look nice but it's not usable inside scripts or by AI agents. We need a way to get a specific template from one cli call. And maybe a way to list existing templates too.

@emupton
Copy link
Copy Markdown
Contributor

emupton commented May 20, 2026

this interactive mode look nice but it's not usable inside scripts or by AI agents. We need a way to get a specific template from one cli call. And maybe a way to list existing templates too.

this is a fair call out and I wasn't thinking about primary use case for our CLI which I suppose is working from within a CI/CD pipeline, maybe a waste of effort even if it feels cool

@rlecomte
Copy link
Copy Markdown
Contributor Author

@qboileau We should keep the current behavior as it is: if no parameter, return the default template.

But this doesn't mean we can't support interactive mode. What I propose is:

# Return default template
conduktor template Topic

# Return specific template
conduktor template Topic $template-name

# Interactive mode
conduktor template -i Topic

@qboileau
Copy link
Copy Markdown
Member

would be nice to also get the list of existing templates to automate conduktor template Topic $template-name

rlecomte and others added 3 commits May 20, 2026 11:31
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rlecomte rlecomte merged commit faa5679 into main May 20, 2026
7 checks passed
@rlecomte rlecomte deleted the pen-208-cli-use-new-template-api-to-create-yml-file branch May 20, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants