MCPcopy Create free account
hub / github.com/coder/coder / systemBinary

Function systemBinary

provisioner/terraform/serve.go:53–85  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

51}
52
53func systemBinary(ctx context.Context) (*systemBinaryDetails, error) {
54 binaryPath, err := safeexec.LookPath("terraform")
55 if err != nil {
56 return nil, xerrors.Errorf("Terraform binary not found: %w", err)
57 }
58
59 // If the "coder" binary is in the same directory as
60 // the "terraform" binary, "terraform" is returned.
61 //
62 // We must resolve the absolute path for other processes
63 // to execute this properly!
64 absoluteBinary, err := filepath.Abs(binaryPath)
65 if err != nil {
66 return nil, xerrors.Errorf("Terraform binary absolute path not found: %w", err)
67 }
68
69 // Checking the installed version of Terraform.
70 installedVersion, err := versionFromBinaryPath(ctx, absoluteBinary)
71 if err != nil {
72 return nil, xerrors.Errorf("Terraform binary get version failed: %w", err)
73 }
74
75 details := &systemBinaryDetails{
76 absolutePath: absoluteBinary,
77 version: installedVersion,
78 }
79
80 if installedVersion.LessThan(minTerraformVersion) {
81 return details, errTerraformMinorVersionMismatch
82 }
83
84 return details, nil
85}
86
87// Serve starts a dRPC server on the provided transport speaking Terraform provisioner.
88func Serve(ctx context.Context, options *ServeOptions) error {

Callers 2

ServeFunction · 0.85
Test_absoluteBinaryPathFunction · 0.85

Calls 2

versionFromBinaryPathFunction · 0.85
ErrorfMethod · 0.45

Tested by 1

Test_absoluteBinaryPathFunction · 0.68