Skip to content

Commit

Permalink
🐛 set gcp logging sink bucket to nil when nil
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey committed Sep 25, 2023
1 parent da98e29 commit 3dd0cd8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions providers/gcp/resources/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package resources
import (
"context"
"fmt"
"strings"

"go.mondoo.com/cnquery/llx"
"go.mondoo.com/cnquery/providers-sdk/v1/util/convert"
"go.mondoo.com/cnquery/providers/gcp/connection"
"go.mondoo.com/cnquery/types"
"strings"

"cloud.google.com/go/logging/logadmin"
"google.golang.org/api/iterator"
Expand All @@ -27,7 +28,6 @@ func (g *mqlGcpProjectLoggingservice) id() (string, error) {
}

func (g *mqlGcpProject) logging() (*mqlGcpProjectLoggingservice, error) {

if g.Id.Error != nil {
return nil, g.Id.Error
}
Expand Down Expand Up @@ -263,17 +263,22 @@ func (g *mqlGcpProjectLoggingservice) sinks() ([]interface{}, error) {
if err != nil {
return nil, err
}
sink, err := CreateResource(g.MqlRuntime, "gcp.project.loggingservice.sink", map[string]*llx.RawData{
args := map[string]*llx.RawData{
"id": llx.StringData(s.ID),
"projectId": llx.StringData(projectId),
"destination": llx.StringData(s.Destination),
"filter": llx.StringData(s.Filter),
"writerIdentity": llx.StringData(s.WriterIdentity),
"includeChildren": llx.BoolData(s.IncludeChildren),
})
}
if !strings.HasPrefix(s.Destination, "storage.googleapis.com/") {
args["storageBucket"] = llx.NilData
}
sink, err := CreateResource(g.MqlRuntime, "gcp.project.loggingservice.sink", args)
if err != nil {
return nil, err
}

sinks = append(sinks, sink)
}
return sinks, nil
Expand Down

0 comments on commit 3dd0cd8

Please sign in to comment.