Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Aug 12, 2024
1 parent 9eb2d6c commit 97ddae4
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 31 deletions.
15 changes: 7 additions & 8 deletions builder/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package builder
import (
"io"
"os"
"path"

output "github.com/konveyor/analyzer-lsp/output/v1/konveyor"
"github.com/konveyor/tackle2-hub/api"
Expand All @@ -16,20 +15,16 @@ type Deps struct {
}

// Write deps file.
func (b *Deps) Write() (output string, err error) {
func (b *Deps) Write(writer io.Writer) (err error) {
input, err := b.read()
if err != nil {
return
}
output = path.Join(path.Dir(b.Path), "hub."+path.Base(b.Path))
f, err := os.Create(output)
encoder := yaml.NewEncoder(writer)
_, err = writer.Write([]byte("___BEGIN-DEPENDENCIES___\n"))
if err != nil {
return
}
defer func() {
_ = f.Close()
}()
encoder := yaml.NewEncoder(f)
for _, p := range input {
for _, d := range p.Dependencies {
err = encoder.Encode(
Expand All @@ -46,6 +41,10 @@ func (b *Deps) Write() (output string, err error) {
}
}
}
_, err = writer.Write([]byte("___END-DEPENDENCIES___\n"))
if err != nil {
return
}
return
}

Expand Down
15 changes: 7 additions & 8 deletions builder/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"net/url"
"os"
"path"

output "github.com/konveyor/analyzer-lsp/output/v1/konveyor"
hub "github.com/konveyor/tackle2-hub/addon"
Expand All @@ -33,20 +32,16 @@ func (b *Issues) RuleError() (r *RuleError) {
}

// Write issues file.
func (b *Issues) Write() (output string, err error) {
func (b *Issues) Write(writer io.Writer) (err error) {
input, err := b.read()
if err != nil {
return
}
output = path.Join(path.Dir(b.Path), "hub."+path.Base(b.Path))
f, err := os.Create(output)
encoder := yaml.NewEncoder(writer)
_, err = writer.Write([]byte("___BEGIN-ISSUES___\n"))
if err != nil {
return
}
defer func() {
_ = f.Close()
}()
encoder := yaml.NewEncoder(f)
for _, ruleset := range input {
b.ruleErr.Append(ruleset)
for ruleid, v := range ruleset.Violations {
Expand Down Expand Up @@ -90,6 +85,10 @@ func (b *Issues) Write() (output string, err error) {
}
}
}
_, err = writer.Write([]byte("___END-ISSUES___\n"))
if err != nil {
return
}
return
}

Expand Down
50 changes: 50 additions & 0 deletions builder/manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package builder

import (
"os"

"github.com/konveyor/tackle2-hub/api"
"gopkg.in/yaml.v2"
)

// Manifest file.
type Manifest struct {
Analysis api.Analysis
Issues *Issues
Deps *Deps
Path string
}

// Write manifest file.
func (m *Manifest) Write() (err error) {
m.Path = "manifest.yaml"
file, err := os.Create(m.Path)
if err != nil {
return
}
defer func() {
_ = file.Close()
}()
_, err = file.Write([]byte("___BEGIN-ANALYSIS___\n"))
if err != nil {
return
}
encoder := yaml.NewEncoder(file)
err = encoder.Encode(m.Analysis)
if err != nil {
return
}
_, err = file.Write([]byte("___END-ANALYSIS___\n"))
if err != nil {
return
}
err = m.Issues.Write(file)
if err != nil {
return
}
err = m.Deps.Write(file)
if err != nil {
return
}
return
}
2 changes: 0 additions & 2 deletions cmd/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"github.com/konveyor/tackle2-addon/command"
)

type RuleError = builder.RuleError

// Analyzer application analyzer.
type Analyzer struct {
*Data
Expand Down
18 changes: 8 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/konveyor/tackle2-addon-analyzer/builder"
"github.com/konveyor/tackle2-addon/ssh"
hub "github.com/konveyor/tackle2-hub/addon"
"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/nas"
"k8s.io/utils/env"
)
Expand Down Expand Up @@ -147,21 +148,18 @@ func updateApplication(d *Data, appId uint, issues *builder.Issues, deps *builde
}
//
// Analysis.
issuePath, err := issues.Write()
if err != nil {
return
manifest := builder.Manifest{
Analysis: api.Analysis{},
Issues: issues,
Deps: deps,
}
depPath, err := deps.Write()
err = manifest.Write()
if err != nil {
return
}
appAnalysis := addon.Application.Analysis(appId)
analysis := addon.Application.Analysis(appId)
mark := time.Now()
err = appAnalysis.Create(
"",
binding.MIMEYAML,
issuePath,
depPath)
err = analysis.Create(manifest.Path, binding.MIMEYAML)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
)

replace github.com/konveyor/tackle2-hub => github.com/jortel/tackle2-hub v0.0.0-20240809173319-038b0663928b
replace github.com/konveyor/tackle2-hub => github.com/jortel/tackle2-hub v0.0.0-20240812005109-32f4c5fcc777

require (
github.com/Nerzal/gocloak/v10 v10.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jortel/go-utils v0.1.2 h1:R0TcGRCcwoL793CymcKC5AF9idWXT2cR6eQ2xpBUsoI=
github.com/jortel/go-utils v0.1.2/go.mod h1:sl6vav63ODI0sUfSz8e0pImNmCVFnVsuOFhZmwe9GDk=
github.com/jortel/tackle2-hub v0.0.0-20240809173319-038b0663928b h1:9v9XStfDzOc4fphx6z4Mm9+sj86Pz72/f8grydE+Wog=
github.com/jortel/tackle2-hub v0.0.0-20240809173319-038b0663928b/go.mod h1:5c5A3i/oARdUp1yo+iYJFFvsIlsbsVGBZT7/CQji9YY=
github.com/jortel/tackle2-hub v0.0.0-20240812005109-32f4c5fcc777 h1:RoUIgNjyrxl9dqi7LoRGe8otAfE/BNMJR/maQEPJitY=
github.com/jortel/tackle2-hub v0.0.0-20240812005109-32f4c5fcc777/go.mod h1:5c5A3i/oARdUp1yo+iYJFFvsIlsbsVGBZT7/CQji9YY=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down

0 comments on commit 97ddae4

Please sign in to comment.