detect

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package detect reads a directory and reports the services grat could manage there.

A detector answers one question: given these files, what command would start this project, and what would that service be called. It answers only where the files say so. Where a marker is present but the detail cannot be read, the finding records that instead, because a plausible command that does not work costs more than no command at all: it looks right in the configuration and fails at the first start.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	// Root is the directory that was inspected.
	Root string
	// Services are the ones that could be derived completely.
	Services []Service
	// Unresolved are the markers that were recognised but not understood.
	Unresolved []Unresolved
}

Finding is everything one directory yielded.

func Directory

func Directory(root string) Finding

Directory reports what grat could manage in root.

It reads files and never runs anything, so it is safe against a directory that was fetched rather than written. A directory that is not a project yields an empty finding rather than an error.

func (Finding) Any

func (finding Finding) Any() bool

Any reports whether the directory looks like a project at all, which is true as soon as anything was recognised, understood or not.

type Service

type Service struct {
	// Name is what the service is called in the configuration. The role follows
	// from it through config.InferRole.
	Name string
	// Command is the complete foreground command, with $PORT where the service
	// takes its port from the environment.
	Command string
	// Role is what the name implies, resolved here so a caller does not repeat it.
	Role config.Role
	// Evidence is the file the command was derived from, relative to the project
	// root, so a person can check the answer against the thing it came from.
	Evidence string
}

Service is one thing grat could manage, derived from what a directory holds.

type Unresolved

type Unresolved struct {
	// Marker is the file that identified the stack, relative to the project root.
	Marker string
	// Reason says what could not be read out of it.
	Reason string
}

Unresolved records a marker that was recognised without yielding a command. It carries what was found and what could not be determined, so the caller can say that rather than invent the missing part.

Jump to

Keyboard shortcuts

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