forked from carlpett/terraform-provider-sops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional support for passing env variables into provider
Needed to support dynamic auth as described in [issue][1], as we are using sops dependency which is using native aws sdk, it will read such configuration from env variables of the process. Additionally, I upgraded deprecated terraform SDK such as replacing `Read` into `ReadContext` and added [1]: carlpett#112
- Loading branch information
Showing
3 changed files
with
67 additions
and
16 deletions.
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
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 |
---|---|---|
@@ -1,14 +1,29 @@ | ||
package sops | ||
|
||
import ( | ||
"context" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func Provider() *schema.Provider { | ||
return &schema.Provider{ | ||
Schema: map[string]*schema.Schema{ | ||
"environment": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
}, | ||
DataSourcesMap: map[string]*schema.Resource{ | ||
"sops_file": dataSourceFile(), | ||
"sops_external": dataSourceExternal(), | ||
}, | ||
ConfigureContextFunc: providerConfigure, | ||
} | ||
} | ||
|
||
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { | ||
env := d.Get("environment").(map[string]interface{}) | ||
return env, nil | ||
} |