Documentation ¶
Index ¶
- type AdminAPIClient
- type Container
- type Option
- func WithAutoCreateTopics() Option
- func WithEnableKafkaAuthorization() Option
- func WithEnableSASL() Option
- func WithEnableSchemaRegistryHTTPBasicAuth() Option
- func WithEnableWasmTransform() Option
- func WithListener(lis string) Option
- func WithNewServiceAccount(username, password string) Option
- func WithSuperusers(superusers ...string) Option
- func WithTLS(cert, key []byte) Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminAPIClient ¶
type AdminAPIClient struct { BaseURL string // contains filtered or unexported fields }
func NewAdminAPIClient ¶
func NewAdminAPIClient(baseURL string) *AdminAPIClient
func (*AdminAPIClient) CreateUser ¶
func (cl *AdminAPIClient) CreateUser(ctx context.Context, username, password string) error
func (*AdminAPIClient) WithHTTPClient ¶
func (cl *AdminAPIClient) WithHTTPClient(c *http.Client) *AdminAPIClient
type Container ¶
type Container struct { testcontainers.Container // contains filtered or unexported fields }
Container represents the Redpanda container type used in the module.
func RunContainer ¶
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error)
RunContainer creates an instance of the Redpanda container type.
Example ¶
package main import ( "context" "fmt" "log" "github.com/samkhawase/testcontainers-go/modules/redpanda" ) func main() { // runRedpandaContainer { ctx := context.Background() redpandaContainer, err := redpanda.RunContainer(ctx, redpanda.WithEnableSASL(), redpanda.WithEnableKafkaAuthorization(), redpanda.WithEnableWasmTransform(), redpanda.WithNewServiceAccount("superuser-1", "test"), redpanda.WithNewServiceAccount("superuser-2", "test"), redpanda.WithNewServiceAccount("no-superuser", "test"), redpanda.WithSuperusers("superuser-1", "superuser-2"), redpanda.WithEnableSchemaRegistryHTTPBasicAuth(), ) if err != nil { log.Fatalf("failed to start container: %s", err) } // Clean up the container defer func() { if err := redpandaContainer.Terminate(ctx); err != nil { log.Fatalf("failed to terminate container: %s", err) } }() // } state, err := redpandaContainer.State(ctx) if err != nil { log.Fatalf("failed to get container state: %s", err) // nolint:gocritic } fmt.Println(state.Running) }
Output: true
func (*Container) AdminAPIAddress ¶
AdminAPIAddress returns the address to the Redpanda Admin API. This is an HTTP-based API and thus the returned format will be: http://host:port.
func (*Container) KafkaSeedBroker ¶
KafkaSeedBroker returns the seed broker that should be used for connecting to the Kafka API with your Kafka client. It'll be returned in the format: "host:port" - for example: "localhost:55687".
func (*Container) SchemaRegistryAddress ¶
SchemaRegistryAddress returns the address to the schema registry API. This is an HTTP-based API and thus the returned format will be: http://host:port.
type Option ¶
type Option func(*options)
Option is an option for the Redpanda container.
func WithAutoCreateTopics ¶
func WithAutoCreateTopics() Option
WithAutoCreateTopics enables topic auto creation.
func WithEnableKafkaAuthorization ¶
func WithEnableKafkaAuthorization() Option
WithEnableKafkaAuthorization enables authorization for connections on the Kafka API.
func WithEnableSASL ¶
func WithEnableSASL() Option
WithEnableSASL enables SASL scram sha authentication. By default, no authentication (plaintext) is used. When setting an authentication method, make sure to add users as well as authorize them using the WithSuperusers() option.
func WithEnableSchemaRegistryHTTPBasicAuth ¶
func WithEnableSchemaRegistryHTTPBasicAuth() Option
WithEnableSchemaRegistryHTTPBasicAuth enables HTTP basic authentication for Schema Registry.
func WithEnableWasmTransform ¶
func WithEnableWasmTransform() Option
WithEnableWasmTransform enables wasm transform. Should not be used with RP versions before 23.3
func WithListener ¶
WithListener adds a custom listener to the Redpanda containers. Listener will be aliases to all networks, so they can be accessed from within docker networks. At leas one network must be attached to the container, if not an error will be thrown when starting the container.
func WithNewServiceAccount ¶
func WithSuperusers ¶
WithSuperusers defines the superusers added to the redpanda config. By default, there are no superusers.