Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Jan 13, 2025
1 parent 1daec69 commit f960085
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 90 deletions.
53 changes: 47 additions & 6 deletions .github/workflows/apps/output_supported_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,53 @@ func fetchLatestVersion(module string) (string, error) {
}

versions := strings.Fields(stdout.String())
latestVersion := ""

if len(versions) < 1 {
return "", fmt.Errorf("no versions found for module: %s", module)
}

return versions[len(versions)-1], nil
if len(versions) == 1 {
// go get -d <module>@latest
// go list -m <module>
// Run `go get -d <module>@latest` to fetch the latest version of the module.
cmdGet := exec.CommandContext(ctx, "go", "get", module+"@latest")
var getStdout, getStderr bytes.Buffer
cmdGet.Stdout = &getStdout
cmdGet.Stderr = &getStderr

// Execute the `go get` command.
err := cmdGet.Run()
// if err != nil {
// return "", fmt.Errorf("failed to fetch latest version with go get: %s", getStderr.String())
// }

// Run `go list -m <module>` to retrieve the exact version fetched.
cmdList := exec.CommandContext(ctx, "go", "list", "-m", module)
var listStdout, listStderr bytes.Buffer
cmdList.Stdout = &listStdout
cmdList.Stderr = &listStderr

// Execute the `go list` command.
err = cmdList.Run()
if err != nil {
return "", fmt.Errorf("failed to retrieve module version with go list: %s", listStderr.String())
}
result := strings.Fields(listStdout.String())
if len(result) < 2 {
return "", fmt.Errorf("unexpected output format from go list: %s", listStdout.String())
}
latestVersion = result[1]
// if latestVersion == "" {
// return "", fmt.Errorf("failed to determine the latest version for module: %s", module)
// }
}

if len(versions) > 1 {
latestVersion = versions[len(versions)-1]
}

return latestVersion, nil
}
func isModuleInstrumented(moduleName string, instrumentedSet map[string]struct{}) bool {
// whether the module has automatic tracing supported (by Orchestrion)
Expand Down Expand Up @@ -115,7 +157,7 @@ func GetMinVersion(packageName, repositoryName string) (ModuleVersion, error) {
for _, req := range f.Require {
if repoRegex.MatchString(req.Mod.Path) {
return ModuleVersion{
Name: req.Mod.Path,
Name: packageName,
MinVersion: req.Mod.Version,
MaxVersion: "",
Repository: req.Mod.Path,
Expand Down Expand Up @@ -176,7 +218,7 @@ func writeMarkdownFile(modules []ModuleVersion, filePath string) error {

for _, mod := range modules {
if mod.Name != "" {
fmt.Fprintf(file, "| %s | %s | v%s | %s | %+v\n", mod.Name, mod.Repository, mod.MinVersion, mod.MaxVersion, mod.isInstrumented)
fmt.Fprintf(file, "| %s | %s | %s | %s | %+v\n", mod.Name, mod.Repository, mod.MinVersion, mod.MaxVersion, mod.isInstrumented)
}
}
return nil
Expand Down Expand Up @@ -228,14 +270,13 @@ func initializeInstrumentedSet() map[string]struct{} {

func processPackages(packageMap map[string]string) ([]ModuleVersion, error) {
var modules []ModuleVersion
for pkg, info := range instrumentation.GetPackages() {
for pkg, repository := range instrumentation.GetPackages() {
package_name := string(pkg)
repository := info.TracedPackage
packageMap[repository] = package_name

module, err := GetMinVersion(package_name, repository)
if err != nil {
fmt.Printf("Error getting min version for package %s: %v\n", package_name, err)
// fmt.Printf("Error getting min version for package %s: %v\n", package_name, err)
continue
}
modules = append(modules, module)
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/supported-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ jobs:

- run: echo 'Smoke Tests workflow passed'

- run: go run .github/workflows/apps/output_integration_versions.go
- run: go run .github/workflows/apps/output_supported_versions.go

- run: go mod tidy

- run: git diff

# note: This will only run when there *are* changes to integration versions
Expand Down
10 changes: 6 additions & 4 deletions instrumentation/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,6 @@ var packages = map[Package]PackageInfo{
},
}



func staticName(name string) func(OperationContext) string {
return func(_ OperationContext) string {
return name
Expand Down Expand Up @@ -847,6 +845,10 @@ func isAWSMessagingSendOp(awsService, awsOperation string) bool {
return false
}

func GetPackages() map[Package]PackageInfo {
return packages
func GetPackages() map[Package]string {
copy := make(map[Package]string)
for pkg, info := range packages {
copy[pkg] = info.TracedPackage
}
return copy
}
76 changes: 0 additions & 76 deletions integration_go.mod

This file was deleted.

6 changes: 3 additions & 3 deletions supported_versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Shopify/sarama | github.com/Shopify/sarama | v1.38.1 | v1.45.0 | true
| aws/aws-sdk-go | github.com/aws/aws-sdk-go | v1.44.327 | v1.55.5 | true
| aws/aws-sdk-go-v2 | github.com/aws/aws-sdk-go-v2 | v1.20.3 | v2.0.0-preview.4+incompatible | true
| bradfitz/gomemcache | github.com/bradfitz/gomemcache | v0.0.0-20230611145640-acc696258285 | github.com/bradfitz/gomemcache | false
| bradfitz/gomemcache | github.com/bradfitz/gomemcache | v0.0.0-20230611145640-acc696258285 | v0.0.0-20230905024940-24af94b03874 | false
| cloud.google.com/go/pubsub.v1 | cloud.google.com/go/pubsub | v1.36.1 | v1.45.3 | true
| confluentinc/confluent-kafka-go/kafka | github.com/confluentinc/confluent-kafka-go | v1.9.2 | v1.9.3-RC3 | false
| confluentinc/confluent-kafka-go/kafka.v2 | github.com/confluentinc/confluent-kafka-go/v2 | v2.2.0 | v2.8.0 | false
Expand All @@ -14,7 +14,7 @@
| emicklei/go-restful.v3 | github.com/emicklei/go-restful/v3 | v3.11.0 | v3.12.1 | false
| envoyproxy/go-control-plane | github.com/envoyproxy/go-control-plane | v0.13.1 | v0.13.4 | false
| gin-gonic/gin | github.com/gin-gonic/gin | v1.9.1 | v1.10.0 | true
| globalsign/mgo | github.com/globalsign/mgo | v0.0.0-20181015135952-eeefdecb41b8 | github.com/globalsign/mgo | false
| globalsign/mgo | github.com/globalsign/mgo | v0.0.0-20181015135952-eeefdecb41b8 | v0.0.0-20181015135952-eeefdecb41b8 | false
| go-chi/chi | github.com/go-chi/chi | v1.5.4 | v4.1.2+incompatible | true
| go-chi/chi.v5 | github.com/go-chi/chi/v5 | v5.0.10 | v5.2.0 | true
| go-pg/pg.v10 | github.com/go-pg/pg/v10 | v10.11.1 | v10.14.0 | false
Expand All @@ -25,7 +25,7 @@
| gocql/gocql | github.com/gocql/gocql | v1.6.0 | v1.7.0 | true
| gofiber/fiber.v2 | github.com/gofiber/fiber/v2 | v2.52.5 | v2.52.6 | true
| gomodule/redigo | github.com/gomodule/redigo | v1.8.9 | v1.9.2 | false
| google.golang.org/api | google.golang.org/api | v0.169.0 | v0.215.0 | false
| google.golang.org/api | google.golang.org/api | v0.169.0 | v0.216.0 | false
| google.golang.org/grpc | google.golang.org/grpc | v1.69.0 | v1.71.0-dev | true
| gorilla/mux | github.com/gorilla/mux | v1.8.0 | v1.8.1 | true
| graph-gophers/graphql-go | github.com/graph-gophers/graphql-go | v1.5.0 | v1.5.0 | true
Expand Down

0 comments on commit f960085

Please sign in to comment.