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

Add template command #76

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Add template command #76

merged 1 commit into from
Dec 17, 2024

Conversation

strokyl
Copy link
Collaborator

@strokyl strokyl commented Dec 16, 2024

All the time I use the cli, I found hard to bootstrap my yaml file for resource. The idea of this PR is to extract example from the openapi.
Here a usage example:

╭─lduzan@duzan ~/code/ctl ‹propose_template› 
╰─$ conduktor template                                                                                                                                                1 ↵
Get a yaml example for a given kind

Usage:
  conduktor template [flags]
  conduktor template [command]

Available Commands:
  Alert                         Get a yaml example for resource of kind Alert
  AliasTopic                    Get a yaml example for resource of kind AliasTopic
  Application                   Get a yaml example for resource of kind Application
  ApplicationGroup              Get a yaml example for resource of kind ApplicationGroup
  ApplicationInstance           Get a yaml example for resource of kind ApplicationInstance
  ApplicationInstancePermission Get a yaml example for resource of kind ApplicationInstancePermission
  ConcentrationRule             Get a yaml example for resource of kind ConcentrationRule
  Connector                     Get a yaml example for resource of kind Connector
  GatewayGroup                  Get a yaml example for resource of kind GatewayGroup
  GatewayServiceAccount         Get a yaml example for resource of kind GatewayServiceAccount
  Group                         Get a yaml example for resource of kind Group
  IndexedTopic                  Get a yaml example for resource of kind IndexedTopic
  Interceptor                   Get a yaml example for resource of kind Interceptor
  KafkaCluster                  Get a yaml example for resource of kind KafkaCluster
  KafkaConnectCluster           Get a yaml example for resource of kind KafkaConnectCluster
  KsqlDBCluster                 Get a yaml example for resource of kind KsqlDBCluster
  ServiceAccount                Get a yaml example for resource of kind ServiceAccount
  Subject                       Get a yaml example for resource of kind Subject
  Topic                         Get a yaml example for resource of kind Topic
  TopicPolicy                   Get a yaml example for resource of kind TopicPolicy
  User                          Get a yaml example for resource of kind User
  VirtualCluster                Get a yaml example for resource of kind VirtualCluster

Flags:
  -f, --file string   Write example to file
  -h, --help          help for template

Global Flags:
      --permissive   permissive mode, allow undefined environment variables
  -v, --verbose      show more information for debugging

Use "conduktor template [command] --help" for more information about a command.
╭─lduzan@duzan ~/code/ctl ‹propose_template› 
╰─$ conduktor template KafkaCluster                                                                                                                                   1 ↵
apiVersion: v2
kind: KafkaCluster
metadata:
    name: my-kafka-cluster
    labels:
        env: prod
spec:
    displayName: yo
    bootstrapServers: localhost:9092
    properties:
        sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin-secret";
    color: '#FF0000'
    icon: icon
    schemaRegistry:
        url: https://my-schema-registry:8081
        security:
            username: admin
            password: admin-secret
            type: BasicAuth
        ignoreUntrustedCertificate: false
        type: ConfluentLike

╭─lduzan@duzan ~/code/ctl ‹propose_template› 
╰─$ conduktor template Topic -f topic.yaml
╭─lduzan@duzan ~/code/ctl ‹propose_template●› 
╰─$ cat topic.yaml 
apiVersion: v2
kind: Topic
metadata:
    name: my-topic
    cluster: my-cluster
    labels:
        conduktor.io/application: application-a
        conduktor.io/application-instance: staging
        user-labels: I am a user label
    catalogVisibility: PUBLIC
    descriptionIsEditable: true
    description: This is a topic description
    sqlStorage:
        retentionTimeInSecond: 42
spec:
    partitions: 1
    replicationFactor: 1
    configs:
        cleanup.policy: delete
        retention.ms: '86400000'
╭─lduzan@duzan ~/code/ctl ‹propose_template●› 
╰─$ conduktor template Topic -f topic.yaml
File topic.yaml already exists

@strokyl strokyl force-pushed the propose_template branch 3 times, most recently from deb5fb8 to 80996ad Compare December 17, 2024 10:29
@strokyl strokyl merged commit 3153ac9 into main Dec 17, 2024
4 checks passed
@strokyl strokyl deleted the propose_template branch December 17, 2024 11:58
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.

2 participants