Documentation
¶
Overview ¶
Package fakemeshstack stands in for one meshStack: its API, its Keycloak and its API docs.
Its main consumer is the demo in docs/demo, which records the CLI against it. Tests use it rarely, as the rule "Test against a live meshStack" in AGENTS.md says.
It serves only what its callers need. A test that needs another answer sets it with Server.Route, so that this package does not grow into a meshStack simulator.
Index ¶
- Constants
- Variables
- type ApiKey
- type Counts
- type Options
- type Request
- type Server
- func (s *Server) Counts() Counts
- func (s *Server) MintToken(validFor time.Duration) string
- func (s *Server) RevokeNewestToken() (revoked bool)
- func (s *Server) Route(pattern string, handler gohttp.HandlerFunc)
- func (s *Server) ServeHTTP(w gohttp.ResponseWriter, r *gohttp.Request)
- func (s *Server) TakeRequests() []Request
- func (s *Server) TfState(key TfState) []byte
- type TfState
Constants ¶
const (
ApiDocsPath = "/api/meshstack-openapi-docs.json"
)
const DefaultVersion = "2026.39.0"
DefaultVersion is at least client.MinMeshStackVersion, or the CLI refuses the backend.
const Token = "eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9." //nolint:gosec // G101: unsigned, it authorizes nothing but a fake meshStack
Token is an unsigned JWT that expires in 2100, so the CLI sends it rather than asking for a new one: a token without an expiry counts as expired. Every Server honors it.
Variables ¶
var UserAgent = http.UserAgent{GitHubRepo: "meshcloud/fakemeshstack", Version: "test"}
UserAgent is for the client of a test, which no front end builds.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Version is what /mesh/info reports, DefaultVersion if empty.
Version string
AdminWorkspace string
// Issuer makes the Server the Keycloak of meshStack as well, under the path of the issuer. A
// caller that serves the issuer's host elsewhere routes that host to the Server too.
Issuer string
ApiKeys []ApiKey
// The objects are marshaled on every request, so a test may change one between steps. A
// workspace is found by metadata.name, every other object by metadata.uuid.
Workspaces []any
BuildingBlocks []any
BuildingBlockRuns []any
EventLogs []any
// PageSize is the largest page a list serves, defaultPageSize if 0, as meshStack caps the
// size a client asks for.
PageSize int
TfStates map[TfState][]byte
// ApiDocs is served at ApiDocsPath as last modified when New was called, so a conditional GET
// gets a 304.
ApiDocs []byte
}
type Server ¶
type Server struct {
// URL is set by Start, and empty for a Server that New made.
URL string
// contains filtered or unexported fields
}
func (*Server) RevokeNewestToken ¶
RevokeNewestToken revokes the newest token still honored, as that is the one a cache most likely holds, so revoking it makes a caller refresh.
No request may be in flight while this runs. An authorized client retries a 401 once, and the token it retries with can be one it took from the cache of another process, so revoking during a request can leave a 401 that nothing recovers from.
func (*Server) Route ¶
func (s *Server) Route(pattern string, handler gohttp.HandlerFunc)
Route answers the requests that match pattern with handler, whatever token they carry, ahead of the Server's own answers. It replaces an earlier handler for the same pattern, and a nil handler removes it.
func (*Server) TakeRequests ¶
TakeRequests returns the requests since the last call.