redpanda

package module
v0.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 23 Imported by: 2

Documentation

Index

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
}

AdminAPIClient is a client for the Redpanda Admin API.

func NewAdminAPIClient

func NewAdminAPIClient(baseURL string) *AdminAPIClient

NewAdminAPIClient creates a new AdminAPIClient.

func (*AdminAPIClient) CreateUser

func (cl *AdminAPIClient) CreateUser(ctx context.Context, username, password string) error

CreateUser creates a new user in Redpanda using Admin API.

func (*AdminAPIClient) Password added in v0.36.0

func (cl *AdminAPIClient) Password() string

Password returns the password of the AdminAPIClient.

func (*AdminAPIClient) Username added in v0.36.0

func (cl *AdminAPIClient) Username() string

Username returns the username of the AdminAPIClient.

func (*AdminAPIClient) WithAuthentication added in v0.36.0

func (cl *AdminAPIClient) WithAuthentication(username, password string) *AdminAPIClient

WithAuthentication sets the username and password for the AdminAPIClient.

func (*AdminAPIClient) WithHTTPClient added in v0.28.0

func (cl *AdminAPIClient) WithHTTPClient(c *http.Client) *AdminAPIClient

WithHTTPClient sets the HTTP client for the AdminAPIClient.

type Container

type Container struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

Container represents the Redpanda container type used in the module.

func Run added in v0.32.0

Run creates an instance of the Redpanda container type

Example
// runRedpandaContainer {
ctx := context.Background()

redpandaContainer, err := redpanda.Run(ctx,
	"docker.redpanda.com/redpandadata/redpanda:v23.3.3",
	redpanda.WithEnableSASL(),
	redpanda.WithEnableKafkaAuthorization(),
	redpanda.WithEnableWasmTransform(),
	redpanda.WithBootstrapConfig("data_transforms_per_core_memory_reservation", 33554432),
	redpanda.WithBootstrapConfig("data_transforms_per_function_memory_limit", 16777216),
	redpanda.WithNewServiceAccount("superuser-1", "test"),
	redpanda.WithNewServiceAccount("superuser-2", "test"),
	redpanda.WithNewServiceAccount("no-superuser", "test"),
	redpanda.WithSuperusers("superuser-1", "superuser-2"),
	redpanda.WithEnableSchemaRegistryHTTPBasicAuth(),
)
defer func() {
	if err := testcontainers.TerminateContainer(redpandaContainer); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start container: %s", err)
	return
}
// }

state, err := redpandaContainer.State(ctx)
if err != nil {
	log.Printf("failed to get container state: %s", err)
	return
}

fmt.Println(state.Running)
Output:

true

func RunContainer deprecated

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error)

Deprecated: use Run instead RunContainer creates an instance of the Redpanda container type

func (*Container) AdminAPIAddress

func (c *Container) AdminAPIAddress(ctx context.Context) (string, error)

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) HTTPProxyAddress added in v0.39.0

func (c *Container) HTTPProxyAddress(ctx context.Context) (string, error)

HTTPProxyAddress returns the address to the HTTP Proxy API (pandaproxy). This is an HTTP-based API and thus the returned format will be: http://host:port.

func (*Container) KafkaSeedBroker

func (c *Container) KafkaSeedBroker(ctx context.Context) (string, error)

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

func (c *Container) SchemaRegistryAddress(ctx context.Context) (string, error)

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 HTTPProxyAuthMethod added in v0.39.0

type HTTPProxyAuthMethod string

HTTPProxyAuthMethod defines the authentication method for HTTP Proxy.

const (
	HTTPProxyAuthMethodNone      HTTPProxyAuthMethod = "none"
	HTTPProxyAuthMethodHTTPBasic HTTPProxyAuthMethod = "http_basic"
	HTTPProxyAuthMethodOIDC      HTTPProxyAuthMethod = "oidc"
)

type Option

type Option func(*options) error

Option is an option for the Redpanda container.

func WithAdminAPIAuthentication added in v0.36.0

func WithAdminAPIAuthentication() Option

WithAdminAPIAuthentication enables Admin API Authentication. It sets `admin_api_require_auth` configuration to true and configures a bootstrap user account. See https://docs.redpanda.com/current/deploy/deployment-option/self-hosted/manual/production/production-deployment/#bootstrap-a-user-account

func WithAutoCreateTopics added in v0.22.0

func WithAutoCreateTopics() Option

WithAutoCreateTopics enables topic auto creation.

func WithBootstrapConfig added in v0.33.0

func WithBootstrapConfig(cfg string, val any) Option

WithBootstrapConfig adds an arbitrary config kvp to the Redpanda container. Per the name, this config will be interpolated into the generated bootstrap config file, which is particularly useful for configs requiring a restart when otherwise applied to a running Redpanda instance.

func WithEnableKafkaAuthorization

func WithEnableKafkaAuthorization() Option

WithEnableKafkaAuthorization enables authorization for connections on the Kafka API.

func WithEnableSASL

func WithEnableSASL() Option

WithEnableSASL enables SASL scram sha 256 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 added in v0.28.0

func WithEnableWasmTransform() Option

WithEnableWasmTransform enables wasm transform. Should not be used with RP versions before 23.3

func WithHTTPProxyAuthMethod added in v0.39.0

func WithHTTPProxyAuthMethod(method HTTPProxyAuthMethod) Option

WithHTTPProxyAuthMethod sets the authentication method for HTTP Proxy. If an invalid method is provided, it defaults to "none".

func WithListener added in v0.28.0

func WithListener(lis string) Option

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 least one network must be attached to the container, if not an error will be thrown when starting the container.

func WithNewServiceAccount

func WithNewServiceAccount(username, password string) Option

WithNewServiceAccount includes a new user with username (key) and password (value) that shall be created, so that you can use these to authenticate against Redpanda (either for the Kafka API or Schema Registry HTTP access).

func WithSuperusers

func WithSuperusers(superusers ...string) Option

WithSuperusers defines the superusers added to the redpanda config. By default, there are no superusers.

func WithTLS added in v0.24.0

func WithTLS(cert, key []byte) Option

func (Option) Customize

Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL