Skip to content
Open
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
36 changes: 36 additions & 0 deletions otel/cmd/otel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Package cmd contains the main entry point for the otel tool.
//
// This package is not intended to be used by other packages and is subject to change.
//
package cmd

import (
"context"
"flag"
"fmt"
"log"
"os"
"path/filepath"

"github.com/pkg/errors"
)

// Command represents a command.
type Command struct {
// ... existing code ...
}

// NewCommand returns a new command.
func NewCommand() *Command {
// ... existing code ...
}

// Run runs the command.
func (c *Command) Run(ctx context.Context) error {
// ... existing code ...

// Add a new flag to prevent updating dependencies.
c.Flags().String("otel-no-update-deps", "false", "prevent updating dependencies")

// ... existing code ...
}
52 changes: 52 additions & 0 deletions otel/internal/dependencies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Package internal contains internal implementation details of the otel tool.
//
// This package is not intended to be used by other packages and is subject to change.
//
package internal

import (
"context"
"fmt"
"go/build"
"go/parser"
"go/token"
"log"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"golang.org/x/tools/go/packages"
)

// dependencies represents the dependencies of a Go package.
type dependencies struct {
// The package path.
path string
// The dependencies of the package.
deps []string
}

// getDependencies returns the dependencies of a Go package.
func getDependencies(ctx context.Context, pkgPath string) ([]string, error) {
// ... existing code ...

// Add a new flag to prevent updating dependencies.
if os.Getenv("OTEL_NO_UPDATE_DEPS") == "true" {
return deps, nil
}

// ... existing code ...
}

// updateDependencies updates the dependencies of a Go package.
func updateDependencies(ctx context.Context, pkgPath string, deps []string) error {
// ... existing code ...

// Add a new flag to prevent updating dependencies.
if os.Getenv("OTEL_NO_UPDATE_DEPS") == "true" {
return nil
}

// ... existing code ...
}
Loading