@@ -82,6 +82,11 @@ func resourceRegistry() *schema.Resource {
8282 Description : "The interval in days to start pulling new images from the registry, Defaults to 1" ,
8383 Optional : true ,
8484 },
85+ "auto_cleanup" : {
86+ Type : schema .TypeBool ,
87+ Description : "Automatically clean up images and repositories which are no longer present in the registry from Aqua console" ,
88+ Optional : true ,
89+ },
8590 "image_creation_date_condition" : {
8691 Type : schema .TypeString ,
8792 Description : "Additional condition for pulling and rescanning images, Defaults to 'none'" ,
@@ -177,6 +182,7 @@ func resourceRegistryCreate(d *schema.ResourceData, m interface{}) error {
177182 AutoPullRescan : d .Get ("auto_pull_rescan" ).(bool ),
178183 AutoPullMax : d .Get ("auto_pull_max" ).(int ),
179184 AutoPullTime : d .Get ("auto_pull_time" ).(string ),
185+ AutoCleanUp : d .Get ("auto_cleanup" ).(bool ),
180186 ImageCreationDateCondition : d .Get ("image_creation_date_condition" ).(string ),
181187 PullImageAge : d .Get ("pull_image_age" ).(string ),
182188 PullImageCount : d .Get ("pull_image_count" ).(int ),
@@ -230,6 +236,9 @@ func resourceRegistryRead(d *schema.ResourceData, m interface{}) error {
230236 if err = d .Set ("auto_pull_interval" , r .AutoPullInterval ); err != nil {
231237 return err
232238 }
239+ if err = d .Set ("auto_cleanup" , r .AutoCleanUp ); err != nil {
240+ return err
241+ }
233242 if err = d .Set ("image_creation_date_condition" , r .ImageCreationDateCondition ); err != nil {
234243 return err
235244 }
@@ -288,7 +297,7 @@ func resourceRegistryUpdate(d *schema.ResourceData, m interface{}) error {
288297 autoPullInterval = 1
289298 }
290299
291- if d .HasChanges ("name" , "username" , "password" , "url" , "type" , "auto_pull" , "auto_pull_rescan" , "auto_pull_max" , "auto_pull_time" , "auto_pull_interval" , "image_creation_date_condition" , "scanner_name" , "prefixes" , "pull_image_count" , "pull_image_age" , "options" ) {
300+ if d .HasChanges ("name" , "username" , "password" , "url" , "type" , "auto_pull" , "auto_pull_rescan" , "auto_pull_max" , "auto_pull_time" , "auto_pull_interval" , "auto_cleanup" , " image_creation_date_condition" , "scanner_name" , "prefixes" , "pull_image_count" , "pull_image_age" , "options" ) {
292301
293302 prefixes := d .Get ("prefixes" ).([]interface {})
294303 scanner_name := d .Get ("scanner_name" ).([]interface {})
@@ -309,6 +318,7 @@ func resourceRegistryUpdate(d *schema.ResourceData, m interface{}) error {
309318 AutoPullRescan : d .Get ("auto_pull_rescan" ).(bool ),
310319 AutoPullMax : d .Get ("auto_pull_max" ).(int ),
311320 AutoPullTime : d .Get ("auto_pull_time" ).(string ),
321+ AutoCleanUp : d .Get ("auto_cleanup" ).(bool ),
312322 AutoPullInterval : autoPullInterval ,
313323 ImageCreationDateCondition : d .Get ("image_creation_date_condition" ).(string ),
314324 PullImageAge : d .Get ("pull_image_age" ).(string ),
0 commit comments