platform

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(factory Factory)

Register registers a platform factory This is typically called from init() functions in platform packages

Types

type Client

type Client interface {
	// Call makes an HTTP request to the platform's API
	Call(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)

	// Platform returns the platform type this client supports
	Platform() Type
}

Client defines the interface for platform-specific API clients

func GetClient

func GetClient(platformType Type) (Client, error)

GetClient is a convenience method to create a client for the specified platform

type Detector

type Detector struct{}

Detector detects the platform type from various sources

func NewDetector

func NewDetector() *Detector

NewDetector creates a new platform detector

func (*Detector) DetectFromEndpoint

func (d *Detector) DetectFromEndpoint(endpoint string) (Type, error)

DetectFromEndpoint detects platform from API endpoint pattern GitHub uses patterns like "repos/", "orgs/", "users/" GitLab uses patterns like "projects/", "groups/"

func (*Detector) DetectFromSpec

func (d *Detector) DetectFromSpec(specPath string) (Type, error)

DetectFromSpec detects platform from spec file path Looks for patterns like "github/" or "gitlab/" in the path

type Factory

type Factory interface {
	// CreateClient creates a new platform client
	CreateClient() (Client, error)

	// Platform returns the platform type this factory creates clients for
	Platform() Type

	// DefaultResponseHeaders returns the default headers to include in snapshots
	DefaultResponseHeaders() []string
}

Factory creates platform-specific clients and provides platform metadata

func Get

func Get(platformType Type) (Factory, error)

Get returns the factory for the specified platform

type Type

type Type string

Type represents a supported platform

const (
	GitHub Type = "github"
	GitLab Type = "gitlab"
)

Jump to

Keyboard shortcuts

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