Skip to content

Commit

Permalink
feat: Use sleep interval as variable
Browse files Browse the repository at this point in the history
  • Loading branch information
iagoalonsomrf committed Jul 9, 2024
1 parent 30e4eaf commit 95604b5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
8 changes: 7 additions & 1 deletion dockerhub/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ func Provider() *schema.Provider {
DefaultFunc: schema.EnvDefaultFunc("DOCKER_PASSWORD", nil),
Description: "Password for authentication.",
},
"sleep_interval": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("SLEEP_INTERVAL", "750"),
Description: "Amount of milliseconds to sleep between requests. Defaults to 750",
},
},
ResourcesMap: map[string]*schema.Resource{
"dockerhub_repository": resourceRepository(),
Expand All @@ -36,5 +42,5 @@ func Provider() *schema.Provider {
}

func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
return rtd.NewClient(d.Get("username").(string), d.Get("password").(string)), nil
return rtd.NewClient(d.Get("username").(string), d.Get("password").(string), d.Get("sleep_interval").(string)), nil
}
10 changes: 6 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ terraform {
```terraform
provider "dockerhub" {
# Note: This cannot be a Personal Access Token
username = "USERNAME" # or use DOCKER_USERNAME environment variable
password = "PASSWORD" # or use DOCKER_PASSWORD environment variable
username = "USERNAME" # or use DOCKER_USERNAME environment variable
password = "PASSWORD" # or use DOCKER_PASSWORD environment variable
sleep_interval = "750" # milliseconds
}
```

Expand All @@ -49,8 +50,9 @@ provider "dockerhub" {
```terraform
# Configure the Docker Hub Provider
provider "dockerhub" {
username = "azurediamond"
password = "hunter2"
username = "azurediamond"
password = "hunter2"
sleep_interval = "750"
}
# Create an organization group for developers
Expand Down
5 changes: 3 additions & 2 deletions examples/full.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Configure the Docker Hub Provider
provider "dockerhub" {
username = "azurediamond"
password = "hunter2"
username = "azurediamond"
password = "hunter2"
sleep_interval = "750"
}

# Create an organization group for developers
Expand Down
5 changes: 3 additions & 2 deletions examples/provider/configuration.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
provider "dockerhub" {
# Note: This cannot be a Personal Access Token
username = "USERNAME" # or use DOCKER_USERNAME environment variable
password = "PASSWORD" # or use DOCKER_PASSWORD environment variable
username = "USERNAME" # or use DOCKER_USERNAME environment variable
password = "PASSWORD" # or use DOCKER_PASSWORD environment variable
sleep_interval = "750" # milliseconds
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Marfeel/terraform-provider-dockerhub
go 1.16

require (
github.com/Marfeel/dockerhub/v2 v2.4.0
github.com/Marfeel/dockerhub/v2 v2.4.1-0.20240709151401-994dd6e9fbdf
github.com/agext/levenshtein v1.2.3 // indirect
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS
cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M=
cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Marfeel/dockerhub/v2 v2.4.0 h1:MC15Llv7Oow7HqjnFgB9fV3H+cQbkLo075bjF7a2Dsk=
github.com/Marfeel/dockerhub/v2 v2.4.0/go.mod h1:0oJJy/ogptA+kYjmrviXU/GEwDkj09XrqsQ2lw/9KNg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Marfeel/dockerhub/v2 v2.4.1-0.20240709151401-994dd6e9fbdf h1:hPA4Pi8ktXutbUL32Oe/RzliRYvEVbXhTt1WOEcuvYA=
github.com/Marfeel/dockerhub/v2 v2.4.1-0.20240709151401-994dd6e9fbdf/go.mod h1:0oJJy/ogptA+kYjmrviXU/GEwDkj09XrqsQ2lw/9KNg=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down

0 comments on commit 95604b5

Please sign in to comment.