mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
* feat: Add authentication and personal user endpoint This contribution adds a lot of scaffolding for the database fake and testability of coderd. A new endpoint "/user" is added to return the currently authenticated user to the requester. * Use TestMain to catch leak instead * Add userpassword package * Add WIP * Add user auth * Fix test * Add comments * Fix login response * Fix order * Fix generated code * Update httpapi/httpapi.go Co-authored-by: Bryan <bryan@coder.com> Co-authored-by: Bryan <bryan@coder.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package terraform
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/coder/coder/provisionersdk"
|
|
)
|
|
|
|
var (
|
|
// The minimum version of Terraform supported by the provisioner.
|
|
// Validation came out in 0.13.0, which was released August 10th, 2020.
|
|
// https://www.hashicorp.com/blog/announcing-hashicorp-terraform-0-13
|
|
minimumTerraformVersion = func() *version.Version {
|
|
v, err := version.NewSemver("0.13.0")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}()
|
|
)
|
|
|
|
type ServeOptions struct {
|
|
*provisionersdk.ServeOptions
|
|
|
|
// BinaryPath specifies the "terraform" binary to use.
|
|
// If omitted, the $PATH will attempt to find it.
|
|
BinaryPath string
|
|
}
|
|
|
|
// Serve starts a dRPC server on the provided transport speaking Terraform provisioner.
|
|
func Serve(ctx context.Context, options *ServeOptions) error {
|
|
if options.BinaryPath == "" {
|
|
binaryPath, err := exec.LookPath("terraform")
|
|
if err != nil {
|
|
return xerrors.Errorf("terraform binary not found: %w", err)
|
|
}
|
|
options.BinaryPath = binaryPath
|
|
}
|
|
|
|
return provisionersdk.Serve(ctx, &terraform{
|
|
binaryPath: options.BinaryPath,
|
|
}, options.ServeOptions)
|
|
}
|
|
|
|
type terraform struct {
|
|
binaryPath string
|
|
}
|