@@ -95,10 +95,7 @@ func listStackPlugins(ctx context.Context, client *gcom.APIClient, data *ListerD
95
95
func resourcePluginInstallationCreate (ctx context.Context , d * schema.ResourceData , client * gcom.APIClient ) diag.Diagnostics {
96
96
stackSlug := d .Get ("stack_slug" ).(string )
97
97
pluginSlug := d .Get ("slug" ).(string )
98
- version := "latest"
99
- if v , ok := d .GetOk ("version" ); ok {
100
- version = v .(string )
101
- }
98
+ version := d .Get ("version" ).(string )
102
99
103
100
req := gcom.PostInstancePluginsRequest {
104
101
Plugin : pluginSlug ,
@@ -140,15 +137,20 @@ func resourcePluginInstallationRead(ctx context.Context, d *schema.ResourceData,
140
137
if err , shouldReturn := common .CheckReadError ("plugin" , d , err ); shouldReturn {
141
138
return err
142
139
}
143
- catalogPlugin , _ , err := client .PluginsAPI .GetPlugin (ctx , pluginSlug .(string )).Execute ()
144
- if err , shouldReturn := common .CheckReadError ("plugin" , d , err ); shouldReturn {
145
- return err
140
+ desiredVersion := d .Get ("version" ).(string )
141
+ catalogVersion := ""
142
+ if desiredVersion == LatestVersion {
143
+ catalogPlugin , _ , err := client .PluginsAPI .GetPlugin (ctx , pluginSlug .(string )).Execute ()
144
+ if err , shouldReturn := common .CheckReadError ("plugin" , d , err ); shouldReturn {
145
+ return err
146
+ }
147
+ catalogVersion = catalogPlugin .Version
146
148
}
147
149
148
150
d .Set ("stack_slug" , installation .InstanceSlug )
149
151
d .Set ("slug" , installation .PluginSlug )
150
- desiredVersion := d . Get ( "version" ).( string )
151
- if desiredVersion == LatestVersion && installation .Version == catalogPlugin . Version {
152
+
153
+ if desiredVersion == LatestVersion && installation .Version == catalogVersion {
152
154
d .Set ("version" , LatestVersion )
153
155
} else {
154
156
d .Set ("version" , installation .Version )
0 commit comments