ocp

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ocp provides functionality for interacting with the OCP API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonS3

type AmazonS3 struct {
	Bucket      string `json:"bucket" yaml:"bucket"`
	Key         string `json:"key" yaml:"key"`
	Region      string `json:"region,omitempty" yaml:"region,omitempty"`
	Credentials string `json:"credentials,omitempty" yaml:"credentials,omitempty"`
	URL         string `json:"url,omitempty" yaml:"url,omitempty"`
}

AmazonS3 defines the configuration for a bundle stored in an Amazon S3 bucket.

type AzureBlobStorage

type AzureBlobStorage struct {
	AccountURL  string `json:"account_url" yaml:"account_url"`
	Container   string `json:"container" yaml:"container"`
	Path        string `json:"path" yaml:"path"`
	Credentials string `json:"credentials,omitempty" yaml:"credentials,omitempty"`
}

AzureBlobStorage defines the configuration for an Azure Blob Storage container.

type Bearer added in v0.36.0

type Bearer struct {
	TokenPath string `json:"token_path" yaml:"token_path"`
}

Bearer defines the structure for bearer token credentials.

type BundleConfig

type BundleConfig struct {
	Name          string            `json:"-" yaml:"-"`
	Labels        map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	ObjectStorage ObjectStorage     `json:"object_storage,omitempty" yaml:"object_storage,omitempty"`
	Requirements  []Requirement     `json:"requirements,omitempty" yaml:"requirements,omitempty"`
	ExcludedFiles []string          `json:"excluded_files,omitempty" yaml:"excluded_files,omitempty"`
}

BundleConfig represents the configuration of a bundle in the OCP APIs.

type Client

type Client struct {
	HTTPClient http.Client
	URL        string

	Cache *cache.Cache
	// contains filtered or unexported fields
}

Client is a client for the OCP APIs.

func (*Client) DeleteBundle added in v0.30.0

func (c *Client) DeleteBundle(ctx context.Context, name string) (err error)

DeleteBundle calls the DELETE /v1/bundles/{name} endpoint in the OCP API.

func (*Client) DeleteSource added in v0.30.0

func (c *Client) DeleteSource(ctx context.Context, id string) (err error)

DeleteSource calls the DELETE /v1/sources/{name} endpoint in the OCP API.

func (*Client) GetSource

func (c *Client) GetSource(ctx context.Context, path string) (resp *GetSourceResponse, err error)

GetSource calls the GET /v1/sources/{id} endpoint in the OCP API.

func (*Client) InvalidateCache

func (c *Client) InvalidateCache()

InvalidateCache invalidates the entire cache

func (*Client) PutBundle

func (c *Client) PutBundle(ctx context.Context, bundle *PutBundleRequest) (err error)

PutBundle calls the PUT /v1/bundles/{name} endpoint in the OCP API.

func (*Client) PutSource

func (c *Client) PutSource(
	ctx context.Context,
	id string,
	request *PutSourceRequest,
) (resp *PutSourceResponse, err error)

PutSource calls the PUT /v1/sources/{id} endpoint in the OCP API.

type ClientInterface

type ClientInterface interface {
	GetSource(ctx context.Context, id string) (*GetSourceResponse, error)
	PutSource(ctx context.Context, id string, request *PutSourceRequest) (*PutSourceResponse, error)
	DeleteSource(ctx context.Context, id string) error
	PutBundle(ctx context.Context, bundle *PutBundleRequest) error
	DeleteBundle(ctx context.Context, name string) error
}

ClientInterface defines the interface for the OCP client.

func New

func New(url string, token string) ClientInterface

New creates a new OCP ClientInterface.

type Datasource

type Datasource struct {
	Name           string                 `json:"name" yaml:"name"`
	Path           string                 `json:"path,omitempty" yaml:"path,omitempty"`
	Type           string                 `json:"type" yaml:"type"`
	TransformQuery string                 `json:"transform_query,omitempty" yaml:"transform_query,omitempty"`
	Config         map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"`
	Credentials    *SecretRef             `json:"credentials,omitempty" yaml:"credentials,omitempty"`
}

Datasource represents a datasource for a source.

type EmptyStruct added in v0.36.0

type EmptyStruct struct{}

EmptyStruct is an empty struct used for mapping empty values in S3EnvironmentCredentials

type FileSystemStorage

type FileSystemStorage struct {
	Path string `json:"path" yaml:"path"` // Path to the bundle on the local filesystem.
}

FileSystemStorage defines the configuration for a local filesystem storage.

type GCPCloudStorage

type GCPCloudStorage struct {
	Project     string `json:"project" yaml:"project"`
	Bucket      string `json:"bucket" yaml:"bucket"`
	Object      string `json:"object" yaml:"object"`
	Credentials string `json:"credentials,omitempty" yaml:"credentials,omitempty"`
}

GCPCloudStorage defines the configuration for a Google Cloud Storage bucket.

type GetSourceResponse

type GetSourceResponse struct {
	StatusCode int
	Body       []byte
	Source     *SourceConfig
	Message    string
}

GetSourceResponse is the response type for calls to the GET /v1/sources/{id} endpoint in the OCP API.

type GitConfig

type GitConfig struct {
	Repo          string   `json:"repo"`
	Reference     string   `json:"reference,omitempty"`
	Commit        string   `json:"commit,omitempty"`
	Path          string   `json:"path,omitempty"`
	IncludedFiles []string `json:"included_files,omitempty"`
	ExcludedFiles []string `json:"excluded_files,omitempty"`
	CredentialID  string   `json:"credentials,omitempty"`
}

GitConfig represents the git source control configuration for a source.

type GitRequirement

type GitRequirement struct {
	Commit *string `json:"commit,omitempty" yaml:"commit,omitempty"`
}

GitRequirement represents Git requirement.

type OPAConfig

type OPAConfig struct {
	BundleService        *OPAServiceConfig
	LogService           *OPAServiceConfig
	UniqueName           string
	Namespace            string
	BundleResource       string
	DecisionLogReporting configv2alpha2.DecisionLogReporting
}

OPAConfig stores the information going into the ConfigMap for the OPA

type OPAServiceConfig added in v0.36.0

type OPAServiceConfig struct {
	Name                         string              `json:"name" yaml:"name"`
	Credentials                  *ServiceCredentials `json:"credentials" yaml:"credentials"`
	ResponseHeaderTimeoutSeconds int                 `json:"response_header_timeout_seconds,omitempty" yaml:"response_header_timeout_seconds,omitempty"` //nolint:lll
	URL                          string              `json:"url" yaml:"url"`
}

OPAServiceConfig defines a services added to the OPAs' config files.

type ObjectStorage

type ObjectStorage struct {
	AmazonS3 *AmazonS3 `json:"aws,omitempty" yaml:"aws,omitempty"`
}

ObjectStorage represents the object storage configuration for a bundle.

type PutBundleRequest

type PutBundleRequest struct {
	Name          string            `json:"-" yaml:"-"`
	Labels        map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	ObjectStorage ObjectStorage     `json:"object_storage,omitempty" yaml:"object_storage,omitempty"`
	Requirements  []Requirement     `json:"requirements,omitempty" yaml:"requirements,omitempty"`
	ExcludedFiles []string          `json:"excluded_files,omitempty" yaml:"excluded_files,omitempty"`
}

PutBundleRequest is the request body for the PUT /v1/bundles/{name} endpoint in the OCP API.

type PutBundleResponse

type PutBundleResponse struct {
	StatusCode string `json:"status_code"`
	Code       string `json:"code"`
	Message    string `json:"message"`
}

PutBundleResponse is the response type for calls to the PUT /v1/bundles/{name} endpoint in the OCP API.

type PutSourceRequest

type PutSourceRequest struct {
	Name          string            `json:"name,omitempty" yaml:"name,omitempty"`
	Builtin       *string           `json:"builtin,omitempty" yaml:"builtin,omitempty"`
	Git           *GitConfig        `json:"git,omitempty" yaml:"git,omitempty"`
	Datasources   []Datasource      `json:"datasources,omitempty" yaml:"datasources,omitempty"`
	EmbeddedFiles map[string]string `json:"files,omitempty" yaml:"files,omitempty"`
	// Root directory for the source files, used to resolve file paths below.
	Directory    string        `json:"directory,omitempty" yaml:"directory,omitempty"`
	Paths        []string      `json:"paths,omitempty" yaml:"paths,omitempty"`
	Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"`
}

PutSourceRequest is the request body for the PUT /v1/sources/{id} endpoint in the OCP API.

type PutSourceResponse

type PutSourceResponse struct {
	StatusCode int
	Body       []byte
	Message    string
}

PutSourceResponse is the response type for calls to the PUT /v1/sources/{id} endpoint in the OCP API.

type Requirement

type Requirement struct {
	Source string         `json:"source,omitempty" yaml:"source,omitempty"`
	Git    GitRequirement `json:"git,omitempty" yaml:"git,omitempty"`
}

Requirement represents a requirement for a bundle and a source.

func NewRequirement

func NewRequirement(source string) Requirement

NewRequirement creates a new Requirement for a bundle.

func ToRequirements

func ToRequirements(sources []string) []Requirement

ToRequirements converts a list of sources to a list of Requirements.

type S3Signing added in v0.36.0

type S3Signing struct {
	S3EnvironmentCredentials map[string]EmptyStruct `json:"environment_credentials" yaml:"environment_credentials"`
}

S3Signing defines the structure for S3 signing configuration.

type Secret

type Secret struct {
	Name  string                 `json:"-" yaml:"-"`
	Value map[string]interface{} `json:"-" yaml:"-"`
}

Secret represents a secret for a datasource in a source.

type SecretRef

type SecretRef struct {
	Name string `json:"-" yaml:"-"`
}

SecretRef represents a reference to a secret for a datasource in a source.

type ServiceCredentials added in v0.36.0

type ServiceCredentials struct {
	Bearer *Bearer    `json:"bearer,omitempty" yaml:"bearer,omitempty"`
	S3     *S3Signing `json:"s3_signing,omitempty" yaml:"s3_signing,omitempty"`
}

ServiceCredentials defines the structure for service credentials.

type SourceConfig

type SourceConfig struct {
	Name          string            `json:"name,omitempty" yaml:"name,omitempty"`
	Builtin       *string           `json:"builtin,omitempty" yaml:"builtin,omitempty"`
	Git           GitConfig         `json:"git,omitempty" yaml:"git,omitempty"`
	Datasources   []Datasource      `json:"datasources,omitempty" yaml:"datasources,omitempty"`
	EmbeddedFiles map[string]string `json:"files,omitempty" yaml:"files,omitempty"`
	// Root directory for the source files, used to resolve file paths below.
	Directory    string        `json:"directory,omitempty" yaml:"directory,omitempty"`
	Paths        []string      `json:"paths,omitempty" yaml:"paths,omitempty"`
	Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"`
}

SourceConfig represents the configuration of a source in the OCP APIs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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