Skip to content

Commit 766278f

Browse files
committed
improve url handling
1 parent 75ba00c commit 766278f

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PROVIDER_NAME=mcbroken
33
PROVIDER_FULL_PATH=$(REGISTRY)/$(NAMESPACE)/$(PROVIDER_NAME)
44
PROVIDER_FULL_NAME=terraform-provider-$(PROVIDER_NAME)
55
PROJECT=$(NAMESPACE)/$(PROVIDER_FULL_NAME)
6-
VERSION=0.1.1
6+
VERSION=0.1.2
77

88
build-mac: PLUGIN_DIR = ~/.terraform.d/plugins/local/provider/$(PROVIDER_NAME)/$(VERSION)/darwin_amd64
99
build-mac:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,32 @@ provider "mcbroken" {}
3232
3333
// Data source to get all available cities/national average of broken ice cream machines
3434
data "mcbroken_cities" "all" {}
35+
3536
// Data source to get current outage percentage of a specific city
3637
data "mcbroken_city" "Dallas" {
3738
city = "Dallas"
3839
}
40+
3941
// If specified city isn't found, returns -1
4042
data "mcbroken_city" "not_found" {
4143
city = "not_found"
4244
}
45+
4346
// Get national average of broken ice cream machines
4447
output "global_broken_average" {
4548
value = data.mcbroken_cities.all.broken
4649
}
50+
4751
// Get list of all cities and their outage percentage
4852
output "all_available_cities" {
4953
value = data.mcbroken_cities.all.cities
5054
}
55+
5156
// Get outage percentage of a specific city
5257
output "user_specified_city" {
5358
value = data.mcbroken_city.Dallas.broken
5459
}
60+
5561
// When user specified city isn't found, return -1
5662
output "user_specified_city_not_found" {
5763
value = data.mcbroken_city.not_found.broken

docs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,32 @@ provider "mcbroken" {}
1717
1818
// Data resource to get all available cities/national average of broken ice cream machines
1919
data "mcbroken_cities" "all" {}
20+
2021
// Data resource to get current outage percentage of a specific city
2122
data "mcbroken_city" "Dallas" {
2223
city = "Dallas"
2324
}
25+
2426
// If specified city isn't found, returns -1
2527
data "mcbroken_city" "not_found" {
2628
city = "not_found"
2729
}
30+
2831
// Get national average of broken ice cream machines
2932
output "global_broken_average" {
3033
value = data.mcbroken_cities.all.broken
3134
}
35+
3236
// Get list of all cities and their outage percentage
3337
output "all_available_cities" {
3438
value = data.mcbroken_cities.all.cities
3539
}
40+
3641
// Get outage percentage of a specific city
3742
output "user_specified_city" {
3843
value = data.mcbroken_city.Dallas.broken
3944
}
45+
4046
// When user specified city isn't found, return -1
4147
output "user_specified_city_not_found" {
4248
value = data.mcbroken_city.not_found.broken

examples/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ terraform {
22
required_providers {
33
mcbroken = {
44
source = "local/provider/mcbroken"
5-
version = "0.1.1"
65
}
76
}
87
}
@@ -11,26 +10,32 @@ provider "mcbroken" {}
1110

1211
// Data resource to get all available cities/national average of broken ice cream machines
1312
data "mcbroken_cities" "all" {}
13+
1414
// Data resource to get current outage percentage of a specific city
1515
data "mcbroken_city" "Dallas" {
1616
city = "Dallas"
1717
}
18+
1819
// If specified city isn't found, returns -1
1920
data "mcbroken_city" "not_found" {
2021
city = "not_found"
2122
}
23+
2224
// Get national average of broken ice cream machines
2325
output "global_broken_average" {
2426
value = data.mcbroken_cities.all.broken
2527
}
28+
2629
// Get list of all cities and their outage percentage
2730
output "all_available_cities" {
2831
value = data.mcbroken_cities.all.cities
2932
}
33+
3034
// Get outage percentage of a specific city
3135
output "user_specified_city" {
3236
value = data.mcbroken_city.Dallas.broken
3337
}
38+
3439
// When user specified city isn't found, return -1
3540
output "user_specified_city_not_found" {
3641
value = data.mcbroken_city.not_found.broken

mcbroken/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
3838
Summary: "Unable to parse url",
3939
Detail: "Mcbroken endpoint provided is not a valid url",
4040
})
41-
41+
return nil, diags
4242
}
4343

4444
providerConfig["url"] = mcbrokenEndpoint

0 commit comments

Comments
 (0)