ampcatalog

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ampcatalog is codeaf's own copy of the parts of the amp-labs provider catalog that this program reads.

WHY A COPY RATHER THAN THE LIBRARY. The catalog codeaf wants is data: a few hundred rows of display name, base URL, auth type, and where a key rides on a request. The library that publishes it is a full connector SDK, and importing the one package that holds those rows drags in its whole world — the AWS SDK, OpenTelemetry, an HTML parser, x/text's CJK encodings, a struct validator, and (via a test helper left in the import graph) the testing package itself. Measured on its own that import is 9.6 MB of a 44 MB binary, for a table.

So the table is taken at build time and kept here. `go generate ./...` runs gen/main.go, which imports the real catalog and writes providers.json beside this file; the library stays a module requirement and stops being a linked dependency. A catalog refresh is `go generate ./internal/connect/ampcatalog` and reading the diff — and the diff is readable, which is the second reason the snapshot is JSON rather than a Go literal.

THE SHAPE IS THE LIBRARY'S, DELIBERATELY. The type names, field names and constant names below are the ones amp uses, spelled the same way, so the call sites read identically against either and so a future field is a two-line change in gen/main.go rather than a translation layer. Only the fields codeaf actually reads are carried; a field nobody reads is a field nobody can be wrong about.

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderNotFound = errors.New("provider not found")

ErrProviderNotFound is returned for a name the snapshot does not carry. It mirrors the library's own error for the same case, because the one caller treats any error as "skip this row".

Functions

This section is empty.

Types

type ApiKeyAsBasicOpts

type ApiKeyAsBasicOpts struct {
	KeyFormat string `json:"keyFormat,omitempty"`
}

ApiKeyAsBasicOpts is how that key has to be spelled before it is encoded.

type ApiKeyOpts

type ApiKeyOpts struct {
	AttachmentType ApiKeyOptsAttachmentType `json:"attachmentType"`
	DocsURL        string                   `json:"docsURL,omitempty"`
	Header         *ApiKeyOptsHeader        `json:"header,omitempty"`
	Query          *ApiKeyOptsQuery         `json:"query,omitempty"`
}

ApiKeyOpts says where the key goes and under what name.

type ApiKeyOptsAttachmentType

type ApiKeyOptsAttachmentType string

ApiKeyOptsAttachmentType is where a key rides on a request.

const (
	Header ApiKeyOptsAttachmentType = "header"
	Query  ApiKeyOptsAttachmentType = "query"
)

type ApiKeyOptsHeader

type ApiKeyOptsHeader struct {
	Name        string `json:"name"`
	ValuePrefix string `json:"valuePrefix,omitempty"`
}

ApiKeyOptsHeader is a key carried in a request header.

type ApiKeyOptsQuery

type ApiKeyOptsQuery struct {
	Name string `json:"name"`
}

ApiKeyOptsQuery is a key carried in the query string.

type AuthHealthCheck

type AuthHealthCheck struct {
	Url                string `json:"url"`
	Method             string `json:"method,omitempty"`
	SuccessStatusCodes []int  `json:"successStatusCodes,omitempty"`
}

AuthHealthCheck is the cheap authenticated call that proves a key works.

type AuthType

type AuthType string

AuthType is how a service expects to be authenticated.

All six the catalog uses are named, not only the two codeaf can drive itself: the switches that read this fall through the other four, and a falling-through case a reader can name is easier to be sure about than a bare string.

const (
	ApiKey AuthType = "apiKey"
	Basic  AuthType = "basic"
	Custom AuthType = "custom"
	Jwt    AuthType = "jwt"
	None   AuthType = "none"
	Oauth2 AuthType = "oauth2"
)

type BasicAuthOpts

type BasicAuthOpts struct {
	DocsURL           string             `json:"docsURL,omitempty"`
	ApiKeyAsBasicOpts *ApiKeyAsBasicOpts `json:"apiKeyAsBasicOpts,omitempty"`
}

BasicAuthOpts covers the services that collect an API key through basic auth.

type MetadataItemInput

type MetadataItemInput struct {
	Name         string `json:"name"`
	DisplayName  string `json:"displayName,omitempty"`
	DefaultValue string `json:"defaultValue,omitempty"`
}

MetadataItemInput is one such question.

type Provider

type Provider string

Provider is a catalog key — the service's id, as amp spells it.

func AllNames

func AllNames() []Provider

AllNames returns every provider the snapshot carries, in no particular order. The one caller sorts, which is what makes two builds register the same list in the same order.

type ProviderInfo

type ProviderInfo struct {
	DisplayName     string            `json:"displayName,omitempty"`
	BaseURL         string            `json:"baseURL"`
	AuthType        AuthType          `json:"authType"`
	ApiKeyOpts      *ApiKeyOpts       `json:"apiKeyOpts,omitempty"`
	BasicOpts       *BasicAuthOpts    `json:"basicOpts,omitempty"`
	Metadata        *ProviderMetadata `json:"metadata,omitempty"`
	AuthHealthCheck *AuthHealthCheck  `json:"authHealthCheck,omitempty"`
}

ProviderInfo is one catalog row, cut to what codeaf reads.

func ReadInfo

func ReadInfo(provider Provider) (*ProviderInfo, error)

ReadInfo returns one row. The value is shared, not copied: every caller in this program reads it and none writes to it, which is also true of the library this replaces.

type ProviderMetadata

type ProviderMetadata struct {
	Input []MetadataItemInput `json:"input,omitempty"`
}

ProviderMetadata is what a service needs asking about before it can be addressed — the workspace in https://<workspace>.example.com.

Directories

Path Synopsis
Command gen writes internal/connect/ampcatalog/providers.json from the amp-labs catalog.
Command gen writes internal/connect/ampcatalog/providers.json from the amp-labs catalog.

Jump to

Keyboard shortcuts

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