Skip to content

Commit

Permalink
Hotfix of provider configuration and username change (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-j-luna authored Jul 31, 2022
1 parent dfe7adc commit 3347683
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cd examples && terraform init && terraform apply --auto-approve
### Close the Deployment

```shell
./bin/akash tx deployment close --dseq <dseq> --owner $AKASH_ACCOUNT_ADDRESS --from $AKASH_KEY_NAME -y --gas=auto --gas-adjustment=1.15 --gas-prices=0.025uakt
./bin/akash tx deployment close --dseq 6958689 --owner $AKASH_ACCOUNT_ADDRESS --from $AKASH_KEY_NAME -y --gas=auto --gas-adjustment=1.15 --gas-prices=0.025uakt
```

### Get deployment details
Expand Down
64 changes: 37 additions & 27 deletions akash/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,64 @@ import (
"terraform-provider-akash/akash/client"
)

const KeyName = "key_name"
const KeyringBackend = "keyring_backend"
const AccountAddress = "account_address"
const Net = "net"
const ChainVersion = "chain_version"
const ChainId = "chain_id"
const Node = "node"
const Home = "home"
const Path = "path"

// Provider -
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"key_name": &schema.Schema{
KeyName: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_KEY_NAME", ""),
},
"keyring_backend": &schema.Schema{
KeyringBackend: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_KEYRING_BACKEND", "os"),
},
"account_address": &schema.Schema{
AccountAddress: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_ACCOUNT_ADDRESS", ""),
},
"net": &schema.Schema{
Net: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_NET", "akash"),
},
"chain_version": &schema.Schema{
ChainVersion: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_VERSION", ""),
},
"chain_id": &schema.Schema{
ChainId: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_CHAIN_ID", ""),
},
"node": &schema.Schema{
Node: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_NODE", ""),
},
"home": &schema.Schema{
Home: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_HOME", func() string {
homeDir, _ := os.UserHomeDir()
return homeDir + "/.akash"
}()),
},
"path": &schema.Schema{
Path: &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("AKASH_PATH", "akash"),
Expand All @@ -77,15 +87,15 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
tflog.Info(ctx, "Configuring the provider")

config := map[string]string{
"key_name": d.Get("key_name").(string),
"keyring_backend": d.Get("keyring_backend").(string),
"account_address": d.Get("account_address").(string),
"net": d.Get("net").(string),
"chain_version": d.Get("chain_version").(string),
"chain_id": d.Get("chain_id").(string),
"node": d.Get("node").(string),
"home": d.Get("home").(string),
"path": d.Get("path").(string),
KeyName: d.Get(KeyName).(string),
KeyringBackend: d.Get(KeyringBackend).(string),
AccountAddress: d.Get(AccountAddress).(string),
Net: d.Get(Net).(string),
ChainVersion: d.Get(ChainVersion).(string),
ChainId: d.Get(ChainId).(string),
Node: d.Get(Node).(string),
Home: d.Get(Home).(string),
Path: d.Get(Path).(string),
}

// Warning or errors can be collected in a slice type
Expand All @@ -96,15 +106,15 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
}

configuration := client.AkashConfiguration{
KeyName: config["key_name"],
KeyringBackend: config["keyring_backend"],
AccountAddress: config["accountAddress"],
Net: config["net"],
Version: config["version"],
ChainId: config["chain_id"],
Node: config["node"],
Home: config["home"],
Path: config["path"],
KeyName: config[KeyName],
KeyringBackend: config[KeyringBackend],
AccountAddress: config[AccountAddress],
Net: config[Net],
Version: config[ChainVersion],
ChainId: config[ChainId],
Node: config[Node],
Home: config[Home],
Path: config[Path],
}

tflog.Debug(ctx, fmt.Sprintf("Starting provider with %+v", configuration))
Expand Down
10 changes: 2 additions & 8 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
terraform {
required_providers {
akash = {
version = "0.0.2"
source = "joao-luna-98/akash"
version = "0.0.3"
source = "cloud-j-luna/akash"
}
}
}

provider "akash" {
account_address = "akash1qyfg4zl2dku8ry7gjkhf88vnc3zrn6vmnzlvr9"
keyring_backend = "os"
key_name = "terraform"
node = "http://akash.c29r3.xyz:80/rpc"
chain_id = "akashnet-2"
chain_version = "0.16.4"
}

resource "akash_deployment" "my_deployment" {
Expand Down

0 comments on commit 3347683

Please sign in to comment.