mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-23 21:09:15 -05:00
Remove version support from mod plugin require block. Closes #3750
This commit is contained in:
@@ -13,8 +13,6 @@ import (
|
|||||||
type PluginVersion struct {
|
type PluginVersion struct {
|
||||||
// the plugin name, as specified in the mod requires block. , e.g. turbot/mod1, aws
|
// the plugin name, as specified in the mod requires block. , e.g. turbot/mod1, aws
|
||||||
RawName string `cty:"name" hcl:"name,label"`
|
RawName string `cty:"name" hcl:"name,label"`
|
||||||
// deprecated: use MinVersionString
|
|
||||||
VersionString string `cty:"version" hcl:"version,optional"`
|
|
||||||
// the minumum version which satisfies the requirement
|
// the minumum version which satisfies the requirement
|
||||||
MinVersionString string `cty:"min_version" hcl:"min_version,optional"`
|
MinVersionString string `cty:"min_version" hcl:"min_version,optional"`
|
||||||
Constraint *semver.Constraints
|
Constraint *semver.Constraints
|
||||||
@@ -43,25 +41,6 @@ func (p *PluginVersion) String() string {
|
|||||||
func (p *PluginVersion) Initialise(block *hcl.Block) hcl.Diagnostics {
|
func (p *PluginVersion) Initialise(block *hcl.Block) hcl.Diagnostics {
|
||||||
var diags hcl.Diagnostics
|
var diags hcl.Diagnostics
|
||||||
p.DeclRange = hclhelpers.BlockRange(block)
|
p.DeclRange = hclhelpers.BlockRange(block)
|
||||||
// handle deprecation warnings/errors
|
|
||||||
if p.VersionString != "" {
|
|
||||||
if p.MinVersionString != "" {
|
|
||||||
diags = append(diags, &hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Both 'min_version' and deprecated 'version' property are set",
|
|
||||||
Subject: &p.DeclRange,
|
|
||||||
})
|
|
||||||
return diags
|
|
||||||
}
|
|
||||||
// raise deprecation warning
|
|
||||||
diags = append(diags, &hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagWarning,
|
|
||||||
Summary: fmt.Sprintf("Property 'version' is deprecated - use 'min_version' instead, in plugin '%s' require block", p.RawName),
|
|
||||||
Subject: &p.DeclRange,
|
|
||||||
})
|
|
||||||
// copy into new property
|
|
||||||
p.MinVersionString = p.VersionString
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert min version into constraint (including prereleases)
|
// convert min version into constraint (including prereleases)
|
||||||
minVersion, err := semver.NewVersion(strings.TrimPrefix(p.MinVersionString, "v"))
|
minVersion, err := semver.NewVersion(strings.TrimPrefix(p.MinVersionString, "v"))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mod "bad_mod_with_require_not_met" {
|
|||||||
|
|
||||||
require {
|
require {
|
||||||
plugin "gcp" {
|
plugin "gcp" {
|
||||||
version = "99.21.0"
|
min_version = "99.21.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ local
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "install a mod with protocol in url" {
|
@test "install a mod with protocol in url" {
|
||||||
run steampipe mod install https://github.com/turbot/steampipe-mod-hackernews-insights@0.3.0 --force
|
run steampipe mod install https://github.com/turbot/steampipe-mod-hackernews-insights@0.4.0 --force
|
||||||
# should install with the protocol in the url prefix
|
# should install with the protocol in the url prefix
|
||||||
assert_output '
|
assert_output '
|
||||||
Installed 1 mod:
|
Installed 1 mod:
|
||||||
|
|
||||||
local
|
local
|
||||||
└── github.com/turbot/steampipe-mod-hackernews-insights@v0.3.0'
|
└── github.com/turbot/steampipe-mod-hackernews-insights@v0.4.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Installed 4 mods:
|
# Installed 4 mods:
|
||||||
|
|||||||
@@ -113,35 +113,6 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
|||||||
assert_output --partial "1"
|
assert_output --partial "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "old plugin.version property" {
|
|
||||||
# go to the mod directory and run steampipe to get the deprectaion warning
|
|
||||||
# or error, and check the output
|
|
||||||
cd $FILE_PATH/test_data/mods/mod_with_old_plugin_block_with_version
|
|
||||||
run steampipe query "select 1"
|
|
||||||
echo $output
|
|
||||||
|
|
||||||
assert_output --partial "Warning: Property 'version' is deprecated - use 'min_version' instead, in plugin 'chaos' require block"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "old plugin.version property with new plugin.min_version property" {
|
|
||||||
# go to the mod directory and run steampipe to get the deprectaion warning
|
|
||||||
# or error, and check the output
|
|
||||||
cd $FILE_PATH/test_data/mods/mod_with_both_version_and_minversion_in_plugin_block
|
|
||||||
run steampipe query "select 1"
|
|
||||||
|
|
||||||
assert_output --partial "Both 'min_version' and deprecated 'version' property are set"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "new plugin.min_version property set" {
|
|
||||||
# go to the mod directory and run steampipe to get the deprectaion warning
|
|
||||||
# or error, and check the output
|
|
||||||
cd $FILE_PATH/test_data/mods/mod_with_minversion_in_plugin_block
|
|
||||||
run steampipe query "select 1"
|
|
||||||
echo $output
|
|
||||||
|
|
||||||
assert_output --partial "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "legacy 'requires' block" {
|
@test "legacy 'requires' block" {
|
||||||
# go to the mod directory and run steampipe to get the deprectaion warning
|
# go to the mod directory and run steampipe to get the deprectaion warning
|
||||||
# or error, and check the output
|
# or error, and check the output
|
||||||
|
|||||||
Reference in New Issue
Block a user