Skip to content

Commit

Permalink
Merge branch 'main' into PC-13027-support-for-azure-prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidwisn authored Jun 18, 2024
2 parents 58857f9 + 7143c20 commit fa841c1
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 39 deletions.
2 changes: 2 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ words:
- noprefix
- nriq
- nrql
- objectimpl
- opentsdb
- opsgenie
- pagerduty
Expand Down Expand Up @@ -133,6 +134,7 @@ words:
- timeseries
- timeslice
- timeslices
- tmpl
- tpng
- tsdb
- twindow
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v1.4.0
github.com/MicahParks/jwkset v0.5.18
github.com/MicahParks/keyfunc/v3 v3.3.3
github.com/aws/aws-sdk-go v1.54.2
github.com/aws/aws-sdk-go v1.54.3
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/goccy/go-yaml v1.11.3
github.com/golang-jwt/jwt/v5 v5.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/MicahParks/jwkset v0.5.18 h1:WLdyMngF7rCrnstQxA7mpRoxeaWqGzPM/0z40PJU
github.com/MicahParks/jwkset v0.5.18/go.mod h1:q8ptTGn/Z9c4MwbcfeCDssADeVQb3Pk7PnVxrvi+2QY=
github.com/MicahParks/keyfunc/v3 v3.3.3 h1:c6j9oSu1YUo0k//KwF1miIQlEMtqNlj7XBFLB8jtEmY=
github.com/MicahParks/keyfunc/v3 v3.3.3/go.mod h1:f/UMyXdKfkZzmBeBFUeYk+zu066J1Fcl48f7Wnl5Z48=
github.com/aws/aws-sdk-go v1.54.2 h1:Wo6AVWcleNHrYa48YzfYz60hzxGRqsJrK5s/qePe+3I=
github.com/aws/aws-sdk-go v1.54.2/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/aws/aws-sdk-go v1.54.3 h1:Bk+EXoq6v5I1xmHR9GQGpsMWZZFXs+FD+5uPyEmfgX0=
github.com/aws/aws-sdk-go v1.54.3/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
16 changes: 16 additions & 0 deletions internal/cmd/objectimpl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# docgen

`objectimpl` is a tool that generates boilerplate functions for manifest objects
in order to implement `manifest.Object` interface.

It utilizes `text/template` to generate the code.

## Usage

Add the following `generate` directive to the file that contains
the `manifest.Object` object definition.
Replace the `<OBJECT_KIND>` with the struct name of your object, e.g. `Project`.

```go
//go:generate go run ../../../internal/cmd/objectimpl <OBJECT_KIND>
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"unicode"
)

//go:embed generate-object-impl.tpl
//go:embed object.tmpl
var templateStr string

type generator struct {
Expand Down Expand Up @@ -80,7 +80,7 @@ func main() {
errFatal(err.Error())
}
outputName := filepath.Join(cwd, fmt.Sprintf("%s_object.go", strings.TrimSuffix(filename, ".go")))
if err = os.WriteFile(outputName, formatted, 0600); err != nil {
if err = os.WriteFile(outputName, formatted, 0o600); err != nil {
errFatal(err.Error())
}
}
Expand Down Expand Up @@ -168,11 +168,7 @@ func (g *generator) hasOrganizationAndManifestSource(fields *ast.FieldList) bool
return hasOrganization && hasManifestSource
}

func errFatal(f string, a ...interface{}) {
if len(a) == 0 {
fmt.Fprintln(os.Stderr, f)
} else {
fmt.Fprintf(os.Stderr, f+"\n", a...)
}
func errFatal(f string) {
fmt.Fprintln(os.Stderr, f)
os.Exit(1)
}
File renamed without changes.
2 changes: 1 addition & 1 deletion manifest/v1alpha/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go Agent
//go:generate go run ../../../internal/cmd/objectimpl Agent

// New creates new Agent instance.
func New(metadata Metadata, spec Spec) Agent {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/agent/agent_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go Alert
//go:generate go run ../../../internal/cmd/objectimpl Alert

// New creates a new Alert based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) Alert {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/alert/alert_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/alertmethod/alert_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go AlertMethod
//go:generate go run ../../../internal/cmd/objectimpl AlertMethod

// New creates a new AlertMethod based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) AlertMethod {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/alertmethod/alert_method_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/alertpolicy/alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go AlertPolicy
//go:generate go run ../../../internal/cmd/objectimpl AlertPolicy

func New(metadata Metadata, spec Spec) AlertPolicy {
return AlertPolicy{
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/alertpolicy/alert_policy_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/alertsilence/alert_silence.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go AlertSilence
//go:generate go run ../../../internal/cmd/objectimpl AlertSilence

// New creates a new AlertSilence based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) AlertSilence {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/alertsilence/alert_silence_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/annotation/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go Annotation
//go:generate go run ../../../internal/cmd/objectimpl Annotation

// New creates a new Annotation based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) Annotation {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/annotation/annotation_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/budgetadjustment/budget_adjustment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go BudgetAdjustment
//go:generate go run ../../../internal/cmd/objectimpl BudgetAdjustment

func New(metadata Metadata, spec Spec) BudgetAdjustment {
return BudgetAdjustment{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/dataexport/data_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go DataExport
//go:generate go run ../../../internal/cmd/objectimpl DataExport

// New creates a new DataExport based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) DataExport {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/dataexport/data_export_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/direct/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go Direct
//go:generate go run ../../../internal/cmd/objectimpl Direct

func New(metadata Metadata, spec Spec) Direct {
return Direct{
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/direct/direct_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go Project
//go:generate go run ../../../internal/cmd/objectimpl Project

// New creates a new Project based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) Project {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/project/project_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/rolebinding/role_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go RoleBinding
//go:generate go run ../../../internal/cmd/objectimpl RoleBinding

func New(metadata Metadata, spec Spec) RoleBinding {
return RoleBinding{
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/rolebinding/role_binding_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go Service
//go:generate go run ../../../internal/cmd/objectimpl Service

// New creates a new Service based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) Service {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/service/service_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/slo/slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

//go:generate go run ../../../scripts/generate-object-impl.go SLO
//go:generate go run ../../../internal/cmd/objectimpl SLO

// New creates a new SLO based on provided Metadata nad Spec.
func New(metadata Metadata, spec Spec) SLO {
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/slo/slo_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest/v1alpha/usergroup/user_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

//go:generate go run ../../../scripts/generate-object-impl.go UserGroup
//go:generate go run ../../../internal/cmd/objectimpl UserGroup

func New(metadata Metadata, spec Spec) UserGroup {
return UserGroup{
Expand Down
2 changes: 1 addition & 1 deletion manifest/v1alpha/usergroup/user_group_object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa841c1

Please sign in to comment.