Remove version support from mod plugin require block. Closes #3750

This commit is contained in:
Puskar Basu
2024-02-27 20:58:44 +05:30
committed by GitHub
parent d8ddcad4cc
commit a02c9a69fb
4 changed files with 3 additions and 53 deletions

View File

@@ -13,8 +13,6 @@ import (
type PluginVersion struct {
// the plugin name, as specified in the mod requires block. , e.g. turbot/mod1, aws
RawName string `cty:"name" hcl:"name,label"`
// deprecated: use MinVersionString
VersionString string `cty:"version" hcl:"version,optional"`
// the minumum version which satisfies the requirement
MinVersionString string `cty:"min_version" hcl:"min_version,optional"`
Constraint *semver.Constraints
@@ -43,25 +41,6 @@ func (p *PluginVersion) String() string {
func (p *PluginVersion) Initialise(block *hcl.Block) hcl.Diagnostics {
var diags hcl.Diagnostics
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)
minVersion, err := semver.NewVersion(strings.TrimPrefix(p.MinVersionString, "v"))

View File

@@ -4,7 +4,7 @@ mod "bad_mod_with_require_not_met" {
require {
plugin "gcp" {
version = "99.21.0"
min_version = "99.21.0"
}
}
}

View File

@@ -80,13 +80,13 @@ local
}
@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
assert_output '
Installed 1 mod:
local
└── github.com/turbot/steampipe-mod-hackernews-insights@v0.3.0'
└── github.com/turbot/steampipe-mod-hackernews-insights@v0.4.0'
}
# Installed 4 mods:

View File

@@ -113,35 +113,6 @@ load "$LIB_BATS_SUPPORT/load.bash"
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" {
# go to the mod directory and run steampipe to get the deprectaion warning
# or error, and check the output