Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ node_modules
.env.development.local
.env.test.local
.env.production.local
*.iml
.idea
*.orig

npm-debug.log*
yarn-debug.log*
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
- [#213](https://github.com/kobsio/kobs/pull/213): [techdocs] Add TechDocs plugin, to access the documentation for your services within kobs.
- [#215](https://github.com/kobsio/kobs/pull/215): [azure] Add Azure plugin, to monitor your Azure resources.
- [#219](https://github.com/kobsio/kobs/pull/219): [azure] Add permissions for Azure plugin, so that access to resources and actions can be restricted based on resource groups.
- [#220](https://github.com/kobsio/kobs/pull/220): [azure] Add auto formatting for the returned metrics of an container instance and fix the tooltip positioning in the metrics chart.
- [#220](https://github.com/kobsio/kobs/pull/220): [azure] Add auto formatting for the returned metrics of a container instance and fix the tooltip positioning in the metrics chart.
- [#221](https://github.com/kobsio/kobs/pull/221): [azure] :warning: _Breaking change:_ :warning: Add support for kubernetes services and refactor various places in the Azure plugin.
- [#222](https://github.com/kobsio/kobs/pull/222): [azure] Simple cost management on subscription level
- [#224](https://github.com/kobsio/kobs/pull/224): [harbor] Add support for multi-arch images.

### Fixed
Expand Down
15 changes: 14 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ module github.com/kobsio/kobs
go 1.17

require (
github.com/Azure/azure-sdk-for-go v59.4.0+incompatible
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance v0.0.0-20211201094935-a52477d726c1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice v0.2.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.2.0
github.com/Azure/go-autorest/autorest v0.11.19
github.com/Azure/go-autorest/autorest/azure/auth v0.5.9
github.com/Azure/go-autorest/autorest/date v0.3.0
github.com/ClickHouse/clickhouse-go v1.5.1
github.com/fluxcd/helm-controller/api v0.13.0
github.com/fluxcd/kustomize-controller/api v0.18.0
Expand Down Expand Up @@ -37,19 +41,27 @@ require (
)

require (
github.com/Azure/azure-sdk-for-go v59.3.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.14 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
github.com/fluxcd/pkg/apis/kustomize v0.2.0 // indirect
github.com/fluxcd/pkg/runtime v0.12.2 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -87,6 +99,7 @@ require (
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rs/xid v1.2.1 // indirect
github.com/rs/zerolog v1.20.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/vjeantet/grok v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
Expand Down
26 changes: 25 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go v59.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v59.3.0+incompatible h1:dPIm0BO4jsMXFcCI/sLTPkBtE7mk8WMuRHA0JeWhlcQ=
github.com/Azure/azure-sdk-for-go v59.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw=
github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0=
Expand All @@ -55,18 +56,35 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs=
github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw=
github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw=
github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA=
github.com/Azure/go-autorest/autorest v0.11.19 h1:7/IqD2fEYVha1EPeaiytVKhzmPV223pfkRIQUGOK2IE=
github.com/Azure/go-autorest/autorest v0.11.19/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA=
github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg=
github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A=
github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M=
github.com/Azure/go-autorest/autorest/adal v0.9.14 h1:G8hexQdV5D4khOXrWG2YuLCFKhWYmWD8bHYaXN5ophk=
github.com/Azure/go-autorest/autorest/adal v0.9.14/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M=
github.com/Azure/go-autorest/autorest/azure/auth v0.5.9 h1:Y2CgdzitFDsdMwYMzf9LIZWrrTFysqbRc7b94XVVJ78=
github.com/Azure/go-autorest/autorest/azure/auth v0.5.9/go.mod h1:hg3/1yw0Bq87O3KvvnJoAh34/0zbP7SFizX/qN5JvjU=
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 h1:dMOmEJfkLKW/7JsokJqkyoYSgmR08hi9KrhjZb+JALY=
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2/go.mod h1:7qkJkT+j6b+hIpzMOwPChJhTqS8VbsqqgULzMNRugoM=
github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw=
github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk=
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk=
github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE=
github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac=
github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E=
github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg=
github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
Expand Down Expand Up @@ -157,6 +175,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
Expand Down Expand Up @@ -200,6 +221,7 @@ github.com/fluxcd/pkg/runtime v0.12.0/go.mod h1:EyaTR2TOYcjL5U//C4yH3bt2tvTgIOSX
github.com/fluxcd/pkg/runtime v0.12.2 h1:4iOpx2j/w15kNemDOnZrF6ugJ/rhSmRu7aI+xn23+BI=
github.com/fluxcd/pkg/runtime v0.12.2/go.mod h1:tuWdqpWPhgjQvYrSnojdZ4plyU8DRU1NDzsfOhnzl2g=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
Expand Down Expand Up @@ -607,6 +629,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand Down
8 changes: 6 additions & 2 deletions plugins/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func Register(clusters *clusters.Clusters, plugins *plugin.Plugins, config Confi
var instances []*instance.Instance

for _, cfg := range config {
instance, err := instance.New(cfg)
inst, err := instance.New(cfg)
if err != nil {
log.WithError(err).WithFields(logrus.Fields{"name": cfg.Name}).Fatalf("Could not create Azure instance")
}

instances = append(instances, instance)
instances = append(instances, inst)

plugins.Append(plugin.Plugin{
Name: cfg.Name,
Expand All @@ -74,6 +74,10 @@ func Register(clusters *clusters.Clusters, plugins *plugin.Plugins, config Confi
containerInstancesRouter.Put("/containergroup/restart", router.restartContainerGroup)
})

r.Route("/costmanagement", func(costManagementRouter chi.Router) {
costManagementRouter.Get("/actualcost", router.getActualCost)
})

r.Route("/kubernetesservices", func(kubernetesServicesRouter chi.Router) {
kubernetesServicesRouter.Get("/managedclusters", router.getManagedClusters)
kubernetesServicesRouter.Get("/managedcluster/details", router.getManagedCluster)
Expand Down
38 changes: 38 additions & 0 deletions plugins/azure/costmanagement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package azure

import (
"net/http"
"strconv"

"github.com/kobsio/kobs/pkg/api/middleware/errresponse"

"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
"github.com/sirupsen/logrus"
)

func (router *Router) getActualCost(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
log.WithFields(logrus.Fields{"name": name}).Tracef("getActualCost")

timeframe, err := strconv.Atoi(r.URL.Query().Get("timeframe"))
if err != nil {
errresponse.Render(w, r, nil, http.StatusBadRequest, "Invalid timeframe parameter")
return
}

i := router.getInstance(name)
if i == nil {
errresponse.Render(w, r, nil, http.StatusBadRequest, "Could not find instance name")
return
}

costUsage, err := i.CostManagement.GetActualCost(r.Context(), timeframe)
if err != nil {
errresponse.Render(w, r, err, http.StatusInternalServerError, "Could not query cost usage")
return
}

render.JSON(w, r, costUsage)

}
2 changes: 2 additions & 0 deletions plugins/azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"@azure/arm-containerinstance": "^7.1.0",
"@azure/arm-containerservice": "^14.3.0",
"@kobsio/plugin-core": "*",
"@nivo/core": "^0.74.0",
"@nivo/line": "^0.74.0",
"@nivo/pie": "^0.74.0",
"@patternfly/react-core": "^4.128.2",
"@patternfly/react-log-viewer": "^4.20.4",
"@types/react": "^17.0.0",
Expand Down
78 changes: 78 additions & 0 deletions plugins/azure/pkg/instance/costmanagement/costmanagement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package costmanagement

import (
"context"
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2019-11-01/costmanagement"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)

// Client is the client to interact with the container instance API.
type Client struct {
subscriptionID string
queryClient *costmanagement.QueryClient
}

// GetActualCost query the actual costs for the configured subscription and given timeframe grouped by resourceGroup
func (c *Client) GetActualCost(ctx context.Context, timeframe int) (costmanagement.QueryResult, error) {
scope := fmt.Sprintf("subscriptions/%s", c.subscriptionID)
res, err := c.queryClient.Usage(ctx, scope, buildQueryParams(timeframe))
if err != nil {
return costmanagement.QueryResult{}, err
}

return res, nil
}

func buildQueryParams(timeframe int) costmanagement.QueryDefinition {
agg := make(map[string]*costmanagement.QueryAggregation)
tc := costmanagement.QueryAggregation{
Name: to.StringPtr("Cost"),
Function: costmanagement.FunctionTypeSum,
}
agg["totalCost"] = &tc

grouping := []costmanagement.QueryGrouping{
{
Type: costmanagement.QueryColumnTypeDimension,
Name: to.StringPtr("resourceGroup"),
},
}

ds := costmanagement.QueryDataset{
Granularity: "None",
Configuration: nil,
Aggregation: agg,
Grouping: &grouping,
Filter: nil,
}

now := date.Time{Time: time.Now()}
from := date.Time{Time: now.AddDate(0, 0, timeframe*-1)}
tp := costmanagement.QueryTimePeriod{
From: &from,
To: &now,
}

return costmanagement.QueryDefinition{
Type: costmanagement.ExportTypeActualCost,
Timeframe: costmanagement.TimeframeTypeCustom,
TimePeriod: &tp,
Dataset: &ds,
}
}

// New returns a new client to interact with the cost management API.
func New(subscriptionID string, authorizer autorest.Authorizer) *Client {
client := costmanagement.NewQueryClient(subscriptionID)
client.Authorizer = authorizer

return &Client{
subscriptionID: subscriptionID,
queryClient: &client,
}
}
11 changes: 11 additions & 0 deletions plugins/azure/pkg/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package instance

import (
"github.com/kobsio/kobs/plugins/azure/pkg/instance/containerinstances"
"github.com/kobsio/kobs/plugins/azure/pkg/instance/costmanagement"
"github.com/kobsio/kobs/plugins/azure/pkg/instance/kubernetesservices"
"github.com/kobsio/kobs/plugins/azure/pkg/instance/monitor"
"github.com/kobsio/kobs/plugins/azure/pkg/instance/resourcegroups"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -38,6 +40,7 @@ type Instance struct {
ResourceGroups *resourcegroups.Client
KubernetesServices *kubernetesservices.Client
ContainerInstances *containerinstances.Client
CostManagement *costmanagement.Client
Monitor *monitor.Client
}

Expand All @@ -48,17 +51,25 @@ func New(config Config) (*Instance, error) {
return nil, err
}

authorizerClientCredentialsConfig := auth.NewClientCredentialsConfig(config.Credentials.ClientID, config.Credentials.ClientSecret, config.Credentials.TenantID)
authorizer, err := authorizerClientCredentialsConfig.Authorizer()
if err != nil {
return nil, err
}

resourceGroups := resourcegroups.New(config.Credentials.SubscriptionID, credentials)
kubernetesServices := kubernetesservices.New(config.Credentials.SubscriptionID, credentials)
containerInstances := containerinstances.New(config.Credentials.SubscriptionID, credentials)
monitor := monitor.New(config.Credentials.SubscriptionID, credentials)
costManagement := costmanagement.New(config.Credentials.SubscriptionID, authorizer)

return &Instance{
Name: config.Name,
PermissionsEnabled: config.PermissionsEnabled,
ResourceGroups: resourceGroups,
KubernetesServices: kubernetesServices,
ContainerInstances: containerInstances,
CostManagement: costManagement,
Monitor: monitor,
}, nil
}
1 change: 1 addition & 0 deletions plugins/azure/src/assets/services/cost-management.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ContainerGroups: React.FunctionComponent<IContainerGroupsProps> = ({
if (json.error) {
throw new Error(json.error);
} else {
throw new Error('An unknown error occured');
throw new Error('An unknown error occurred');
}
}
} catch (err) {
Expand Down
Loading