-
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.
Initial support for Terraform Plugin SDK v2 (#179)
Reference: bflad/tfproviderlint#178
- Loading branch information
1 parent
ed7f1cf
commit 5489e89
Showing
1,023 changed files
with
137,027 additions
and
23,613 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
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,23 +1,37 @@ | ||
package customdiff | ||
|
||
import ( | ||
"fmt" | ||
"go/ast" | ||
"go/types" | ||
|
||
"github.com/bflad/tfproviderlint/helper/astutils" | ||
"github.com/bflad/tfproviderlint/helper/terraformtype" | ||
) | ||
|
||
const ( | ||
PackageName = `customdiff` | ||
PackagePath = `github.com/hashicorp/terraform-plugin-sdk/customdiff` | ||
PackageModule = terraformtype.ModuleTerraformPluginSdk | ||
PackageModulePath = `helper/customdiff` | ||
PackageName = `customdiff` | ||
PackagePath = PackageModule + `/` + PackageModulePath | ||
) | ||
|
||
// IsFunc returns if the function call is in the customdiff package | ||
func IsFunc(e ast.Expr, info *types.Info, funcName string) bool { | ||
return astutils.IsPackageFunc(e, info, PackagePath, funcName) | ||
return astutils.IsModulePackageFunc(e, info, PackageModule, PackageModulePath, funcName) | ||
} | ||
|
||
// IsNamedType returns if the type name matches and is from the helper/customdiff package | ||
func IsNamedType(t *types.Named, typeName string) bool { | ||
return astutils.IsPackageNamedType(t, PackagePath, typeName) | ||
return astutils.IsModulePackageNamedType(t, PackageModule, PackageModulePath, typeName) | ||
} | ||
|
||
// PackagePathVersion returns the import path for a module version | ||
func PackagePathVersion(moduleVersion int) string { | ||
switch moduleVersion { | ||
case 0, 1: | ||
return PackagePath | ||
default: | ||
return fmt.Sprintf("%s/v%d/%s", PackageModule, moduleVersion, PackageModulePath) | ||
} | ||
} |
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,23 +1,37 @@ | ||
package resource | ||
|
||
import ( | ||
"fmt" | ||
"go/ast" | ||
"go/types" | ||
|
||
"github.com/bflad/tfproviderlint/helper/astutils" | ||
"github.com/bflad/tfproviderlint/helper/terraformtype" | ||
) | ||
|
||
const ( | ||
PackageName = `resource` | ||
PackagePath = `github.com/hashicorp/terraform-plugin-sdk/helper/resource` | ||
PackageModule = terraformtype.ModuleTerraformPluginSdk | ||
PackageModulePath = `helper/resource` | ||
PackageName = `resource` | ||
PackagePath = PackageModule + `/` + PackageModulePath | ||
) | ||
|
||
// IsFunc returns if the function call is in the resource package | ||
func IsFunc(e ast.Expr, info *types.Info, funcName string) bool { | ||
return astutils.IsPackageFunc(e, info, PackagePath, funcName) | ||
return astutils.IsModulePackageFunc(e, info, PackageModule, PackageModulePath, funcName) | ||
} | ||
|
||
// IsNamedType returns if the type name matches and is from the helper/resource package | ||
func IsNamedType(t *types.Named, typeName string) bool { | ||
return astutils.IsPackageNamedType(t, PackagePath, typeName) | ||
return astutils.IsModulePackageNamedType(t, PackageModule, PackageModulePath, typeName) | ||
} | ||
|
||
// PackagePathVersion returns the import path for a module version | ||
func PackagePathVersion(moduleVersion int) string { | ||
switch moduleVersion { | ||
case 0, 1: | ||
return PackagePath | ||
default: | ||
return fmt.Sprintf("%s/v%d/%s", PackageModule, moduleVersion, PackageModulePath) | ||
} | ||
} |
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,28 +1,42 @@ | ||
package schema | ||
|
||
import ( | ||
"fmt" | ||
"go/ast" | ||
"go/types" | ||
|
||
"github.com/bflad/tfproviderlint/helper/astutils" | ||
"github.com/bflad/tfproviderlint/helper/terraformtype" | ||
) | ||
|
||
const ( | ||
PackageName = `schema` | ||
PackagePath = `github.com/hashicorp/terraform-plugin-sdk/helper/schema` | ||
PackageModule = terraformtype.ModuleTerraformPluginSdk | ||
PackageModulePath = `helper/schema` | ||
PackageName = `schema` | ||
PackagePath = PackageModule + `/` + PackageModulePath | ||
) | ||
|
||
// IsFunc returns if the function call is in the package | ||
func IsFunc(e ast.Expr, info *types.Info, funcName string) bool { | ||
return astutils.IsPackageFunc(e, info, PackagePath, funcName) | ||
return astutils.IsModulePackageFunc(e, info, PackageModule, PackageModulePath, funcName) | ||
} | ||
|
||
// IsNamedType returns if the type name matches and is from the package | ||
func IsNamedType(t *types.Named, typeName string) bool { | ||
return astutils.IsPackageNamedType(t, PackagePath, typeName) | ||
return astutils.IsModulePackageNamedType(t, PackageModule, PackageModulePath, typeName) | ||
} | ||
|
||
// IsReceiverMethod returns if the receiver method call is in the package | ||
func IsReceiverMethod(e ast.Expr, info *types.Info, receiverName string, methodName string) bool { | ||
return astutils.IsPackageReceiverMethod(e, info, PackagePath, receiverName, methodName) | ||
return astutils.IsModulePackageReceiverMethod(e, info, PackageModule, PackageModulePath, receiverName, methodName) | ||
} | ||
|
||
// PackagePathVersion returns the import path for a module version | ||
func PackagePathVersion(moduleVersion int) string { | ||
switch moduleVersion { | ||
case 0, 1: | ||
return PackagePath | ||
default: | ||
return fmt.Sprintf("%s/v%d/%s", PackageModule, moduleVersion, PackageModulePath) | ||
} | ||
} |
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,18 +1,32 @@ | ||
package validation | ||
|
||
import ( | ||
"fmt" | ||
"go/ast" | ||
"go/types" | ||
|
||
"github.com/bflad/tfproviderlint/helper/astutils" | ||
"github.com/bflad/tfproviderlint/helper/terraformtype" | ||
) | ||
|
||
const ( | ||
PackageName = `validation` | ||
PackagePath = `github.com/hashicorp/terraform-plugin-sdk/helper/validation` | ||
PackageModule = terraformtype.ModuleTerraformPluginSdk | ||
PackageModulePath = `helper/validation` | ||
PackageName = `validation` | ||
PackagePath = PackageModule + `/` + PackageModulePath | ||
) | ||
|
||
// IsFunc returns if the function call is in the package | ||
func IsFunc(e ast.Expr, info *types.Info, funcName string) bool { | ||
return astutils.IsPackageFunc(e, info, PackagePath, funcName) | ||
return astutils.IsModulePackageFunc(e, info, PackageModule, PackageModulePath, funcName) | ||
} | ||
|
||
// PackagePathVersion returns the import path for a module version | ||
func PackagePathVersion(moduleVersion int) string { | ||
switch moduleVersion { | ||
case 0, 1: | ||
return PackagePath | ||
default: | ||
return fmt.Sprintf("%s/v%d/%s", PackageModule, moduleVersion, PackageModulePath) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package terraformtype | ||
|
||
const ( | ||
ModuleTerraformPluginSdk = `github.com/hashicorp/terraform-plugin-sdk` | ||
) |
Oops, something went wrong.