Skip to content

Commit

Permalink
🧹 update the provider when its outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Mar 26, 2024
1 parent df1f32d commit e75b844
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.0
replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.3 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187

require (
go.mondoo.com/cnquery/v10 v10.9.1
go.mondoo.com/cnquery/v10 v10.9.2-0.20240326161610-cd544f00a38c
go.mondoo.com/cnspec/v10 v10.9.1
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,8 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3
go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs=
go.mondoo.com/cnquery/v10 v10.9.1 h1:E0CHShKmq2ijX0AFSaFzrHqusm/6XmYc3EtwVp9Gi48=
go.mondoo.com/cnquery/v10 v10.9.1/go.mod h1:aAcCZ6modg4DYeDTdeaeGtiQGbEjYExfjm6frUD3efY=
go.mondoo.com/cnquery/v10 v10.9.2-0.20240326161610-cd544f00a38c h1:N5h8KrI9vmx/F5BMyQyRzM2lEM8VL2uxce5coj3CpsA=
go.mondoo.com/cnquery/v10 v10.9.2-0.20240326161610-cd544f00a38c/go.mod h1:aAcCZ6modg4DYeDTdeaeGtiQGbEjYExfjm6frUD3efY=
go.mondoo.com/cnspec/v10 v10.9.1 h1:0HNj9fOTwnpRzGAWa/HyfE+FA0CUVEMhaD3OT6sRywA=
go.mondoo.com/cnspec/v10 v10.9.1/go.mod h1:co2pznLRIVElPeHd/XdoNSkpE0OsBWwaR25jzrnaSXo=
go.mondoo.com/mondoo-go v0.0.0-20240312054001-2ab23a39b500 h1:HjtfupqfqKnDaK+XUXZC/3JyIwK09C3TFNggwReuDlY=
Expand Down
12 changes: 12 additions & 0 deletions provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,18 @@ func (p *Provisioner) executeCnspec(ui packer.Ui, comm packer.Communicator) erro
return err
}
}

updated, err := providers.TryProviderUpdate(provider, providers.UpdateProvidersConfig{
Enabled: true,
RefreshInterval: 60 * 60,
})
if err != nil {
ui.Error("failed to update provider, fallback to existing one: " + err.Error())
} else {
ui.Message("successfully updated OS provider")
provider = updated
}

ui.Message("use OS provider version " + provider.Version + " (" + provider.Path + ")")

var res *scan.ScanResult
Expand Down

0 comments on commit e75b844

Please sign in to comment.