file

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	resources.ResourceConfigBase `yaml:",inline"`
	Path                         string `yaml:"path" validate:"required"`
	MaxSize                      *int64 `yaml:"maxSize,omitempty"`
	// contains filtered or unexported fields
}

Config represents the configuration for a file resource.

func (*Config) Initialize

func (c *Config) Initialize(ctx context.Context) (resources.Resource, error)

Initialize validates the configuration and initializes the file resource.

func (*Config) ResourceConfigType

func (c *Config) ResourceConfigType() string

ResourceConfigType returns the resource type identifier.

func (*Config) Validate

func (c *Config) Validate() error

Validate performs specific validation including URI scheme and file size limits.

type FileResource

type FileResource struct {
	Config
	Size int64
	// contains filtered or unexported fields
}

FileResource handles reading content from a local file.

func (*FileResource) GetAnnotations

func (r *FileResource) GetAnnotations() *resources.ResourceAnnotations

GetAnnotations returns the resource annotations, dynamically computing the LastModified timestamp.

func (*FileResource) GetCurrentSize

func (r *FileResource) GetCurrentSize() (int64, error)

GetCurrentSize returns the actual size of the file on disk.

func (*FileResource) GetSize

func (r *FileResource) GetSize() *int64

GetSize returns the configured maximum size of the file.

func (*FileResource) Read

func (r *FileResource) Read(ctx context.Context, params map[string]any) (any, error)

Read retrieves the file content.

func (*FileResource) ToConfig

func (r *FileResource) ToConfig() resources.ResourceConfig

ToConfig returns the original configuration for this resource.

type FileTemplate

type FileTemplate struct {
	TemplateConfig
	// contains filtered or unexported fields
}

FileTemplate handles reading content from a file template URI.

func (*FileTemplate) Read

func (r *FileTemplate) Read(ctx context.Context, params map[string]any) (any, error)

Read retrieves the file content using template parameters.

func (*FileTemplate) ToConfig

ToConfig returns the original configuration for this template.

type TemplateConfig

type TemplateConfig struct {
	resources.ResourceTemplateConfigBase `yaml:",inline"`
	AllowedPaths                         []string `yaml:"allowedPaths,omitempty"`
	MaxSize                              *int64   `yaml:"maxSize,omitempty"`
	// contains filtered or unexported fields
}

TemplateConfig represents the configuration for a file resource template.

func (*TemplateConfig) Initialize

Initialize validates the configuration and initializes the file resource template.

func (*TemplateConfig) ResourceTemplateConfigType

func (c *TemplateConfig) ResourceTemplateConfigType() string

func (*TemplateConfig) Validate

func (c *TemplateConfig) Validate() error

Validate performs template-specific validation including URI scheme checks.

Jump to

Keyboard shortcuts

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