Skip to content

Commit

Permalink
Add config.Provider.Context to specify any provider specific context
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Dec 15, 2023
1 parent b674f3d commit a28ab0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package config

import (
"context"
"fmt"
"regexp"

Expand Down Expand Up @@ -131,6 +132,10 @@ type Provider struct {
// TerraformProvider is the Terraform schema of the provider.
TerraformProvider *schema.Provider

// Context represents any provider specific context to be used
// with this Provider.
Context context.Context

// refInjectors is an ordered list of `ReferenceInjector`s for
// injecting references across this Provider's resources.
refInjectors []ReferenceInjector
Expand Down Expand Up @@ -222,12 +227,21 @@ func WithFeaturesPackage(s string) ProviderOption {
}
}

// WithMainTemplate configures the main program template used to generate
// the resource provider (subpackage) mains.
func WithMainTemplate(template string) ProviderOption {
return func(p *Provider) {
p.MainTemplate = template
}
}

// WithContext configures the context for this Provider.
func WithContext(ctx context.Context) ProviderOption {
return func(p *Provider) {
p.Context = ctx
}
}

// NewProvider builds and returns a new Provider from provider
// tfjson schema, that is generated using Terraform CLI with:
// `terraform providers schema --json`
Expand Down

0 comments on commit a28ab0a

Please sign in to comment.