Skip to content

Commit

Permalink
⭐️ asset url for k8s (#3730)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock authored Apr 9, 2024
1 parent 1ebc09a commit 17de88b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
11 changes: 11 additions & 0 deletions providers/k8s/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package config

import (
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v10/providers/k8s/provider"
"go.mondoo.com/cnquery/v10/providers/k8s/resources"
Expand Down Expand Up @@ -60,4 +61,14 @@ var Config = plugin.Provider{
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=k8s"},
Key: "platform",
Title: "Platform",
Values: map[string]*inventory.AssetUrlBranch{
"*": nil,
},
},
},
}
11 changes: 6 additions & 5 deletions providers/k8s/connection/admission/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ func (c *Connection) Name() string {

func (c *Connection) Platform() *inventory.Platform {
return &inventory.Platform{
Name: "k8s-admission",
Family: []string{"k8s"},
Kind: "code",
Runtime: c.Runtime(),
Title: "Kubernetes Admission",
Name: "k8s-admission",
Family: []string{"k8s"},
Kind: "code",
Runtime: c.Runtime(),
Title: "Kubernetes Admission",
TechnologyUrlSegments: []string{"k8s"},
}
}

Expand Down
17 changes: 9 additions & 8 deletions providers/k8s/connection/api/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,15 @@ func (c *Connection) SupportedResourceTypes() (*resources.ApiResourceIndex, erro
func (c *Connection) Platform() *inventory.Platform {
v := c.ServerVersion()
return &inventory.Platform{
Name: "k8s-cluster",
Build: v.BuildDate,
Version: v.GitVersion,
Arch: v.Platform,
Family: []string{"k8s"},
Kind: "api",
Runtime: c.Runtime(),
Title: "Kubernetes Cluster",
Name: "k8s-cluster",
Build: v.BuildDate,
Version: v.GitVersion,
Arch: v.Platform,
Family: []string{"k8s"},
Kind: "api",
Runtime: c.Runtime(),
Title: "Kubernetes Cluster",
TechnologyUrlSegments: []string{"k8s", "k8s-cluster"},
}
}

Expand Down
11 changes: 6 additions & 5 deletions providers/k8s/connection/manifest/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ func (c *Connection) Runtime() string {

func (c *Connection) Platform() *inventory.Platform {
return &inventory.Platform{
Name: "k8s-manifest",
Family: []string{"k8s"},
Kind: "code",
Runtime: c.Runtime(),
Title: "Kubernetes Manifest",
Name: "k8s-manifest",
Family: []string{"k8s"},
Kind: "code",
Runtime: c.Runtime(),
Title: "Kubernetes Manifest",
TechnologyUrlSegments: []string{"k8s", "k8s-manifest"},
}
}

Expand Down
3 changes: 3 additions & 0 deletions providers/k8s/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,9 @@ func createPlatformData(objectKind, runtime string) (*inventory.Platform, error)
default:
return nil, fmt.Errorf("could not determine object kind %s", objectKind)
}

platformData.TechnologyUrlSegments = []string{"k8s", platformData.Name}

return platformData, nil
}

Expand Down

0 comments on commit 17de88b

Please sign in to comment.