Skip to content

Commit

Permalink
Merge pull request #63 from OpenSLO/sumo-agaurav
Browse files Browse the repository at this point in the history
fix cgo related issue and missing tf variable for mon folder
  • Loading branch information
agaurav authored Mar 27, 2023
2 parents 28b7cc1 + a833fbf commit 2b3e27f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
16 changes: 12 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ before:
- go generate ./...
builds:
- env:
- CGO_ENABLED=1
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64
goarm:
- "7"
ignore:
- goos: linux
goarch: arm64
- goos: linux
- goos: windows
goarch: arm
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser
archives:
- replacements:
darwin: Darwin
Expand Down
5 changes: 3 additions & 2 deletions libs/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func GenTerraform(slosMv map[string]*SLOMultiVerse, c GenConf) (string, error) {
panic(err)
}

makeOSLODepGraph(slosMv, c)
//to be moved to conditional compilation later
//graph.MakeOSLODepGraph(slosMv, c)

return genTerraformForAlpha(slosAlpha, c)
}
Expand Down Expand Up @@ -275,7 +276,7 @@ func SetupOutDir(c GenConf) error {
{Path: filepath.Join(c.OutDir, ViewsFolder), Vars: nil},
{Path: filepath.Join(c.OutDir, MonitorsFolder), Vars: []string{VarNameMonRootFolder}},
{Path: filepath.Join(c.OutDir, DashboardsFolder), Vars: []string{VarNameDashRootFolder}},
{Path: filepath.Join(c.OutDir, NativeSLOFolder), Vars: []string{VarNameNativeSLORootFolder}},
{Path: filepath.Join(c.OutDir, NativeSLOFolder), Vars: []string{VarNameNativeSLORootFolder, VarNameSLOMonitorRootFolder}},
}
}

Expand Down
19 changes: 10 additions & 9 deletions libs/graph.go → libs/graph/graph.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
package libs
package graph

import (
"github.com/OpenSLO/slogen/libs"
"github.com/goccy/go-graphviz/cgraph"

"github.com/goccy/go-graphviz"
)

func makeOSLODepGraph(confs map[string]*SLOMultiVerse, c GenConf) *graphviz.Graphviz {
func MakeOSLODepGraph(confs map[string]*libs.SLOMultiVerse, c libs.GenConf) *graphviz.Graphviz {
g := graphviz.New()
graph, err := g.Graph()
if err != nil {
log.Fatal(err)
libs.Log().Fatal(err)
}
defer func() {
if err := graph.Close(); err != nil {
log.Fatal(err)
libs.Log().Fatal(err)
}
g.Close()
}()

err = createNodes(graph, confs)
if err != nil {
log.Errorw("error generating slo graph nodes", "err", err)
libs.Log().Errorw("error generating slo graph nodes", "err", err)
}

err = createEdges(graph, confs)
if err != nil {
log.Errorw("error generating slo graph edges", "err", err)
libs.Log().Errorw("error generating slo graph edges", "err", err)
}

filePath := c.OutDir + "/" + "slo-dep-graph.png"
Expand All @@ -36,7 +37,7 @@ func makeOSLODepGraph(confs map[string]*SLOMultiVerse, c GenConf) *graphviz.Grap
return g
}

func createNodes(graph *cgraph.Graph, confs map[string]*SLOMultiVerse) error {
func createNodes(graph *cgraph.Graph, confs map[string]*libs.SLOMultiVerse) error {

var err error
for _, v := range confs {
Expand Down Expand Up @@ -70,7 +71,7 @@ func createNodes(graph *cgraph.Graph, confs map[string]*SLOMultiVerse) error {
}

if err != nil {
log.Errorw("error generating slo graph", "err", err)
libs.Log().Errorw("error generating slo graph", "err", err)
return err
}
//node.
Expand All @@ -79,7 +80,7 @@ func createNodes(graph *cgraph.Graph, confs map[string]*SLOMultiVerse) error {
return nil
}

func createEdges(graph *cgraph.Graph, confs map[string]*SLOMultiVerse) error {
func createEdges(graph *cgraph.Graph, confs map[string]*libs.SLOMultiVerse) error {

for _, v := range confs {

Expand Down
36 changes: 35 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -16,10 +16,44 @@ limitations under the License.
package main

import (
"fmt"
"github.com/OpenSLO/slogen/cmd"
"runtime"
"runtime/debug"
)

// nolint: gochecknoglobals
var (
version = "dev"
commit = ""
date = ""
builtBy = ""
)

func main() {

fmt.Printf("\nrunning version: %s\n\n-------------------\n\n",
buildVersion(version, commit, date, builtBy),
)

cmd.Execute()
}

func buildVersion(version, commit, date, builtBy string) string {
result := version
if commit != "" {
result = fmt.Sprintf("%s\ncommit: %s", result, commit)
}
if date != "" {
result = fmt.Sprintf("%s\nbuilt at: %s", result, date)
}
if builtBy != "" {
result = fmt.Sprintf("%s\nbuilt by: %s", result, builtBy)
}
result = fmt.Sprintf("%s\ngoos: %s\ngoarch: %s", result, runtime.GOOS, runtime.GOARCH)
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
result = fmt.Sprintf("%s\nmodule version: %s, checksum: %s", result, info.Main.Version, info.Main.Sum)
}

return result
}

0 comments on commit 2b3e27f

Please sign in to comment.