This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
generated from crossplane-contrib/provider-jet-template
-
Notifications
You must be signed in to change notification settings - Fork 21
Switch to shared gRPC server implementation #58
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,20 +22,22 @@ import ( | |||||
"path/filepath" | ||||||
"time" | ||||||
|
||||||
"gopkg.in/alecthomas/kingpin.v2" | ||||||
kerrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
"k8s.io/client-go/tools/leaderelection/resourcelock" | ||||||
ctrl "sigs.k8s.io/controller-runtime" | ||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||||||
|
||||||
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||||||
xpcontroller "github.com/crossplane/crossplane-runtime/pkg/controller" | ||||||
"github.com/crossplane/crossplane-runtime/pkg/feature" | ||||||
"github.com/crossplane/crossplane-runtime/pkg/logging" | ||||||
"github.com/crossplane/crossplane-runtime/pkg/ratelimiter" | ||||||
"github.com/crossplane/crossplane-runtime/pkg/resource" | ||||||
|
||||||
tjcontroller "github.com/crossplane/terrajet/pkg/controller" | ||||||
"github.com/crossplane/terrajet/pkg/terraform" | ||||||
"gopkg.in/alecthomas/kingpin.v2" | ||||||
kerrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
"k8s.io/client-go/tools/leaderelection/resourcelock" | ||||||
ctrl "sigs.k8s.io/controller-runtime" | ||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||||||
|
||||||
"github.com/crossplane-contrib/provider-jet-gcp/apis" | ||||||
"github.com/crossplane-contrib/provider-jet-gcp/apis/v1alpha1" | ||||||
|
@@ -47,14 +49,15 @@ import ( | |||||
|
||||||
func main() { | ||||||
var ( | ||||||
app = kingpin.New(filepath.Base(os.Args[0]), "Terraform based Crossplane provider for GCP").DefaultEnvars() | ||||||
debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() | ||||||
syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration() | ||||||
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() | ||||||
terraformVersion = app.Flag("terraform-version", "Terraform version.").Required().Envar("TERRAFORM_VERSION").String() | ||||||
providerSource = app.Flag("terraform-provider-source", "Terraform provider source.").Required().Envar("TERRAFORM_PROVIDER_SOURCE").String() | ||||||
providerVersion = app.Flag("terraform-provider-version", "Terraform provider version.").Required().Envar("TERRAFORM_PROVIDER_VERSION").String() | ||||||
maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int() | ||||||
app = kingpin.New(filepath.Base(os.Args[0]), "Terraform based Crossplane provider for GCP").DefaultEnvars() | ||||||
debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() | ||||||
syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration() | ||||||
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() | ||||||
terraformVersion = app.Flag("terraform-version", "Terraform version.").Required().Envar("TERRAFORM_VERSION").String() | ||||||
providerSource = app.Flag("terraform-provider-source", "Terraform provider source.").Required().Envar("TERRAFORM_PROVIDER_SOURCE").String() | ||||||
providerVersion = app.Flag("terraform-provider-version", "Terraform provider version.").Required().Envar("TERRAFORM_PROVIDER_VERSION").String() | ||||||
nativeProviderPath = app.Flag("native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to be consistent with other flags and its environment var? |
||||||
maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int() | ||||||
|
||||||
namespace = app.Flag("namespace", "Namespace used to set as default scope in default secret store config.").Default("crossplane-system").Envar("POD_NAMESPACE").String() | ||||||
enableExternalSecretStores = app.Flag("enable-external-secret-stores", "Enable support for ExternalSecretStores.").Default("false").Envar("ENABLE_EXTERNAL_SECRET_STORES").Bool() | ||||||
|
@@ -86,6 +89,11 @@ func main() { | |||||
kingpin.FatalIfError(err, "Cannot create controller manager") | ||||||
kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add GCP APIs to scheme") | ||||||
|
||||||
var runner terraform.ProviderRunner = terraform.NewNoOpProviderRunner() | ||||||
if len(*nativeProviderPath) != 0 { | ||||||
runner = terraform.NewSharedProvider(log, *nativeProviderPath, "registry.terraform.io/hashicorp/google") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use "registry.terraform.io/hashicorp/google" => "registry.terraform.io/" + |
||||||
} | ||||||
|
||||||
o := tjcontroller.Options{ | ||||||
Options: xpcontroller.Options{ | ||||||
Logger: log, | ||||||
|
@@ -95,7 +103,7 @@ func main() { | |||||
Features: &feature.Flags{}, | ||||||
}, | ||||||
Provider: config.GetProvider(), | ||||||
WorkspaceStore: terraform.NewWorkspaceStore(log), | ||||||
WorkspaceStore: terraform.NewWorkspaceStore(log, terraform.WithProviderRunner(runner)), | ||||||
SetupFn: clients.TerraformSetupBuilder(*terraformVersion, *providerSource, *providerVersion), | ||||||
} | ||||||
if *enableExternalSecretStores { | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we put it next to other
TERRAFORM_
env vars in the bottom, to also have all parameters together?