Skip to content

Commit 2b217a9

Browse files
authored
Merge pull request #72 from upbound/bootcheck
add basic plumbing for provider startup checks
2 parents 0e9bac8 + bfc9933 commit 2b217a9

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

cmd/provider/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package main
88

99
import (
1010
"context"
11+
"log"
1112
"os"
1213
"path/filepath"
1314
"time"
@@ -36,10 +37,18 @@ import (
3637

3738
"github.com/upbound/provider-opentofu/apis"
3839
"github.com/upbound/provider-opentofu/apis/v1beta1"
40+
"github.com/upbound/provider-opentofu/internal/bootcheck"
3941
workspace "github.com/upbound/provider-opentofu/internal/controller"
4042
"github.com/upbound/provider-opentofu/internal/controller/features"
4143
)
4244

45+
func init() {
46+
err := bootcheck.CheckEnv()
47+
if err != nil {
48+
log.Fatalf("bootcheck failed. provider will not be started: %v", err)
49+
}
50+
}
51+
4352
func main() {
4453
var (
4554
app = kingpin.New(filepath.Base(os.Args[0]), "Terraform HCL support for Crossplane via OpenTofu.").DefaultEnvars()

internal/bootcheck/default.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build !custombootcheck
2+
// +build !custombootcheck
3+
4+
package bootcheck
5+
6+
func CheckEnv() error {
7+
// No-op by default. Use build tags for build-time isolation of custom preflight checks.
8+
// Ensure to update the build tags on L1-L2 so that they are mutually exclusive across implementations.
9+
return nil
10+
}

0 commit comments

Comments
 (0)