Documentation
¶
Index ¶
- func NewClient(ctx context.Context, config *Config) (context.Context, apiclient.Client, error)
- func NewClientWithOptions(ctx context.Context, opts ...Option) (context.Context, apiclient.Client, error)
- type ArgoServerOpts
- type Config
- type Option
- func WithArgoServer(url, authToken string) Option
- func WithArgoServerHTTP1(http1 bool) Option
- func WithArgoServerInsecure(insecure bool) Option
- func WithArgoServerOpts(opts ArgoServerOpts) Option
- func WithConfig(config *Config) Option
- func WithContext(context string) Option
- func WithInCluster(inCluster bool) Option
- func WithKubeConfig(path string) Option
- func WithOTelConfig(otelConfig *otel.Config) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient creates a new Argo Workflows client from the given configuration. It returns the updated context and client, or an error if the connection fails.
The client can connect to Argo Workflows in two modes: 1. Via Kubernetes API (default) - uses kubeconfig or in-cluster config 2. Via Argo Server - uses HTTP/HTTPS connection
Example (default kubeconfig):
ctx, client, err := argo.NewClient(ctx, argo.DefaultConfig())
if err != nil {
return err
}
defer client.Close()
Example (in-cluster):
ctx, client, err := argo.NewClient(ctx, argo.InClusterConfig())
Example (Argo Server):
cfg := argo.ArgoServerConfig("https://argo-server:2746", "Bearer token")
ctx, client, err := argo.NewClient(ctx, cfg)
func NewClientWithOptions ¶
func NewClientWithOptions(ctx context.Context, opts ...Option) (context.Context, apiclient.Client, error)
NewClientWithOptions creates a new Argo Workflows client using functional options. This provides a more flexible way to configure the client.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithKubeConfig("/custom/path/kubeconfig"),
argo.WithContext("production"),
argo.WithOTelConfig(otelConfig),
)
Types ¶
type ArgoServerOpts ¶
type ArgoServerOpts struct {
// URL is the Argo Server base URL (e.g., "https://argo-server:2746")
URL string `yaml:"url" mapstructure:"url"`
// AuthToken is the bearer token for authentication (optional)
AuthToken string `yaml:"authToken" mapstructure:"authToken"`
// InsecureSkipVerify disables TLS certificate verification (not recommended for production)
InsecureSkipVerify bool `yaml:"insecureSkipVerify" mapstructure:"insecureSkipVerify"`
// HTTP1 forces HTTP/1.1 instead of HTTP/2
HTTP1 bool `yaml:"http1" mapstructure:"http1"`
}
ArgoServerOpts contains Argo Server connection options. This is used when connecting via Argo Server HTTP API instead of direct Kubernetes API.
type Config ¶
type Config struct {
// KubeConfigPath specifies the path to kubeconfig file.
// Empty string means:
// - Use in-cluster config if InCluster is true
// - Use default kubeconfig location (~/.kube/config) if InCluster is false
KubeConfigPath string `yaml:"kubeConfigPath" mapstructure:"kubeConfigPath"`
// Context specifies the kubeconfig context to use.
// Empty string means use the current context.
Context string `yaml:"context" mapstructure:"context"`
// InCluster indicates whether to use in-cluster Kubernetes configuration.
// When true, the client will use the service account token mounted in the pod.
InCluster bool `yaml:"inCluster" mapstructure:"inCluster"`
// ArgoServerOpts configures connection to Argo Server (alternative to direct k8s API).
// If URL is set, the client will connect via Argo Server instead of k8s API.
ArgoServerOpts ArgoServerOpts `yaml:"argoServer" mapstructure:"argoServer"`
// OTelConfig enables OpenTelemetry instrumentation (optional).
OTelConfig *otel.Config `yaml:"-"`
}
Config represents the configuration for connecting to Argo Workflows. It supports multiple connection modes: - Kubernetes API (in-cluster or with kubeconfig) - Argo Server (HTTP/HTTPS with optional authentication)
func ArgoServerConfig ¶
ArgoServerConfig returns a Config for connecting via Argo Server. This is an alternative to direct Kubernetes API access.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults. By default, it uses: - Out-of-cluster mode (InCluster = false) - Default kubeconfig location (~/.kube/config) - Current context from kubeconfig
func InClusterConfig ¶
func InClusterConfig() *Config
InClusterConfig returns a Config for in-cluster usage. This is useful when the client runs inside a Kubernetes pod.
type Option ¶
Option is a functional option for configuring Argo client.
func WithArgoServer ¶
WithArgoServer configures the client to connect via Argo Server instead of Kubernetes API. This is an alternative connection mode that uses HTTP/HTTPS.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithArgoServer("https://argo-server:2746", "Bearer token"),
)
func WithArgoServerHTTP1 ¶
WithArgoServerHTTP1 forces HTTP/1.1 instead of HTTP/2 for Argo Server connection. This can be useful for debugging or compatibility reasons.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithArgoServer("https://argo-server:2746", "Bearer token"),
argo.WithArgoServerHTTP1(true),
)
func WithArgoServerInsecure ¶
WithArgoServerInsecure enables insecure mode for Argo Server connection. This disables TLS certificate verification. WARNING: This should only be used in development/testing environments.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithArgoServer("http://argo-server:2746", ""),
argo.WithArgoServerInsecure(true),
)
func WithArgoServerOpts ¶
func WithArgoServerOpts(opts ArgoServerOpts) Option
WithArgoServerOpts sets the complete ArgoServerOpts configuration. This is useful when you want to configure all Argo Server options at once.
Example:
serverOpts := argo.ArgoServerOpts{
URL: "https://argo-server:2746",
AuthToken: "Bearer token",
InsecureSkipVerify: false,
HTTP1: false,
}
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithArgoServerOpts(serverOpts),
)
func WithConfig ¶
WithConfig applies a complete Config to the client. This is useful when you have a pre-built configuration from a config file.
Example:
config := &argo.Config{
KubeConfigPath: "/custom/kubeconfig",
Context: "production",
}
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithConfig(config),
)
func WithContext ¶
WithContext sets the kubeconfig context to use. If not set, the current context from kubeconfig will be used.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithContext("production"),
)
func WithInCluster ¶
WithInCluster enables in-cluster configuration mode. When true, the client will use the service account token mounted in the pod. This is useful when running inside a Kubernetes cluster.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithInCluster(true),
)
func WithKubeConfig ¶
WithKubeConfig sets the path to the kubeconfig file. If not set, the default location (~/.kube/config) will be used.
Example:
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithKubeConfig("/custom/path/to/kubeconfig"),
)
func WithOTelConfig ¶
WithOTelConfig enables OpenTelemetry instrumentation for the Argo client. This allows tracing and monitoring of workflow operations.
Example:
otelConfig := otel.NewConfig("my-service").
WithTracerProvider(tracerProvider).
WithMeterProvider(meterProvider)
ctx, client, err := argo.NewClientWithOptions(ctx,
argo.WithOTelConfig(otelConfig),
)