Skip to content

Commit f4120cd

Browse files
⚠️ Warn if an MQL resource does not have id set. (#5825)
* ⚠️ Warn if an MQL resource does not have id set. Signed-off-by: Preslav <preslav@mondoo.com> * improve warn msg. Signed-off-by: Preslav <preslav@mondoo.com> * Made the warn msg a debug msg. Signed-off-by: Preslav <preslav@mondoo.com> * regen all providers Signed-off-by: Preslav <preslav@mondoo.com> --------- Signed-off-by: Preslav <preslav@mondoo.com>
1 parent 01c6090 commit f4120cd

File tree

32 files changed

+512
-96
lines changed

32 files changed

+512
-96
lines changed

providers-sdk/v1/lr/go.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ package resources
120120
import (
121121
"errors"%s
122122
123+
"github.com/rs/zerolog/log"
123124
"go.mondoo.com/cnquery/v11/llx"
124125
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
125126
"go.mondoo.com/cnquery/v11/types"%s
@@ -167,7 +168,11 @@ func NewResource(runtime *plugin.Runtime, name string, args map[string]*llx.RawD
167168
}
168169
169170
if res != nil {
170-
id := name+"\x00"+res.MqlID()
171+
mqlId := res.MqlID()
172+
if mqlId == "" {
173+
log.Debug().Msgf("resource %s has no MQL ID defined, this is usually an issue with the resource, please open a GitHub issue at https://github.com/mondoohq/cnquery/issues", name)
174+
}
175+
id := name + "\x00" + mqlId
171176
if x, ok := runtime.Resources.Get(id); ok {
172177
return x, nil
173178
}
@@ -183,7 +188,11 @@ func NewResource(runtime *plugin.Runtime, name string, args map[string]*llx.RawD
183188
return nil, err
184189
}
185190
186-
id := name+"\x00"+res.MqlID()
191+
mqlId := res.MqlID()
192+
if mqlId == "" {
193+
log.Debug().Msgf("resource %s has no MQL ID defined, this is usually an issue with the resource, please open a GitHub issue at https://github.com/mondoohq/cnquery/issues", name)
194+
}
195+
id := name + "\x00" + mqlId
187196
if x, ok := runtime.Resources.Get(id); ok {
188197
return x, nil
189198
}
@@ -206,7 +215,11 @@ func CreateResource(runtime *plugin.Runtime, name string, args map[string]*llx.R
206215
return nil, err
207216
}
208217
209-
id := name+"\x00"+res.MqlID()
218+
mqlId := res.MqlID()
219+
if mqlId == "" {
220+
log.Debug().Msgf("resource %s has no MQL ID defined, this is usually an issue with the resource, please open a GitHub issue at https://github.com/mondoohq/cnquery/issues", name)
221+
}
222+
id := name + "\x00" + mqlId
210223
if x, ok := runtime.Resources.Get(id); ok {
211224
return x, nil
212225
}

providers-sdk/v1/testutils/mockprovider/resources/mockprovider.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/ansible/resources/ansible.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/arista/resources/arista.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/atlassian/resources/atlassian.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/aws/resources/aws.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/azure/resources/azure.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/cloudflare/resources/cloudflare.lr.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)