Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions cmd/config/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,16 @@ func (cmd *ApplyCmd) loadConfig(
var err error

if cmd.Config != "" {
devContainerConfig, err = devcconfig.ParseDevContainerJSONFile(cmd.Config)
devContainerConfig, err = devcconfig.ParseDevContainerJSONFile(
context.Background(),
cmd.Config,
)
} else {
cwd, cwdErr := os.Getwd()
if cwdErr != nil {
return nil, fmt.Errorf("get working directory: %w", cwdErr)
}
devContainerConfig, err = devcconfig.ParseDevContainerJSON(cwd, "")
devContainerConfig, err = devcconfig.ParseDevContainerJSON(context.Background(), cwd, "")
}
if err != nil {
return nil, fmt.Errorf("parse devcontainer config: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion cmd/config/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ func (cmd *ReadCmd) resolveConfig() (

var parsedConfig *devcconfig.DevContainerConfig
if cmd.Config != "" {
parsedConfig, err = devcconfig.ParseDevContainerJSONFile(cmd.Config)
parsedConfig, err = devcconfig.ParseDevContainerJSONFile(context.Background(), cmd.Config)
} else {
parsedConfig, err = devcconfig.ParseDevContainerJSON(
context.Background(),
workspaceFolder,
"",
)
Expand Down
8 changes: 6 additions & 2 deletions cmd/feature/outdated.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ func (cmd *OutdatedCmd) loadConfig() (*devconfig.DevContainerConfig, error) {

var parsedConfig *devconfig.DevContainerConfig
if cmd.Config != "" {
parsedConfig, err = devconfig.ParseDevContainerJSONFile(cmd.Config)
parsedConfig, err = devconfig.ParseDevContainerJSONFile(context.Background(), cmd.Config)
} else {
parsedConfig, err = devconfig.ParseDevContainerJSON(workspaceFolder, "")
parsedConfig, err = devconfig.ParseDevContainerJSON(
context.Background(),
workspaceFolder,
"",
)
}
if err != nil {
return nil, fmt.Errorf("parse devcontainer config: %w", err)
Expand Down
5 changes: 3 additions & 2 deletions cmd/feature/resolvedeps.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package feature

import (
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -122,15 +123,15 @@ func buildResolvedList(sorted []*config.FeatureSet) []resolvedFeature {

func (cmd *ResolveDepsCmd) loadConfig() (*config.DevContainerConfig, error) {
if cmd.Config != "" {
return config.ParseDevContainerJSONFile(cmd.Config)
return config.ParseDevContainerJSONFile(context.Background(), cmd.Config)
}

absPath, err := filepath.Abs(cmd.WorkspaceFolder)
if err != nil {
return nil, err
}

return config.ParseDevContainerJSON(absPath, "")
return config.ParseDevContainerJSON(context.Background(), absPath, "")
}

func (cmd *ResolveDepsCmd) printText(resolved []resolvedFeature) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/feature/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (cmd *UpgradeCmd) applyUpgrades(configPath string, outdated []outdatedEntry
old := entry.repo + ":" + entry.current
updated := entry.repo + ":" + entry.latest
content = strings.ReplaceAll(content, old, updated)
log.Infof("Upgraded %s: %s → %s", entry.repo, entry.current, entry.latest)
log.Infof("Upgraded %s: %s to %s", entry.repo, entry.current, entry.latest)
}

//nolint:gosec // G306 -- matching existing file permissions in the codebase
Expand Down
4 changes: 1 addition & 3 deletions cmd/internal/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/spf13/cobra"
)

var AgentExecutedAnnotation = "devsy.sh/agent-executed"

// NewAgentCmd is the hidden parent for commands that run inside a workspace or
// container, invoked by the daemon over the agent tunnel.
func NewAgentCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
Expand Down Expand Up @@ -48,7 +46,7 @@ func agentPreRunE(globalFlags *flags.GlobalFlags) func(*cobra.Command, []string)
if root.Annotations == nil {
root.Annotations = map[string]string{}
}
root.Annotations[AgentExecutedAnnotation] = "true"
root.Annotations[config.AgentExecutedAnnotation] = "true"

log.Init(log.Config{
Quiet: globalFlags.Quiet,
Expand Down
6 changes: 5 additions & 1 deletion cmd/internal/runusercommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,11 @@ func (cmd *RunUserCommandsCmd) loadContainerIDConfig(
configFolder = "."
}

devContainerConfig, err := devcconfig.ParseDevContainerJSON(configFolder, cmd.Config)
devContainerConfig, err := devcconfig.ParseDevContainerJSON(
context.Background(),
configFolder,
cmd.Config,
)
if err != nil {
_ = devcconfig.WriteErrorJSON(os.Stderr, err.Error())
return nil, fmt.Errorf("parse devcontainer config: %w", err)
Expand Down
3 changes: 1 addition & 2 deletions cmd/pro/check_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"

cmdinternal "github.com/devsy-org/devsy/cmd/internal"
"github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/cmd/pro/proutil"
"github.com/devsy-org/devsy/pkg/config"
Expand Down Expand Up @@ -55,7 +54,7 @@ func NewCheckUpdateCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
root.Annotations = map[string]string{}
}
// Don't print debug message
root.Annotations[cmdinternal.AgentExecutedAnnotation] = "true" //nolint:goconst
root.Annotations[config.AgentExecutedAnnotation] = "true" //nolint:goconst
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/pro/daemon/netcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"strconv"

cmdinternal "github.com/devsy-org/devsy/cmd/internal"
"github.com/devsy-org/devsy/cmd/pro/completion"
proflags "github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/cmd/pro/proutil"
Expand Down Expand Up @@ -54,7 +53,7 @@ func NewNetcheckCmd(flags *proflags.GlobalFlags) *cobra.Command {
root.Annotations = map[string]string{}
}
// Don't print debug message
root.Annotations[cmdinternal.AgentExecutedAnnotation] = "true"
root.Annotations[config.AgentExecutedAnnotation] = "true"
},
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/pro/daemon/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"

cmdinternal "github.com/devsy-org/devsy/cmd/internal"
"github.com/devsy-org/devsy/cmd/pro/completion"
proflags "github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/cmd/pro/proutil"
Expand Down Expand Up @@ -51,8 +50,7 @@ func NewStatusCmd(flags *proflags.GlobalFlags) *cobra.Command {
if root.Annotations == nil {
root.Annotations = map[string]string{}
}
// Don't print debug message
root.Annotations[cmdinternal.AgentExecutedAnnotation] = "true"
root.Annotations[config.AgentExecutedAnnotation] = "true"
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/pro/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"

cmdinternal "github.com/devsy-org/devsy/cmd/internal"
"github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/cmd/pro/proutil"
"github.com/devsy-org/devsy/pkg/client/clientimplementation"
Expand Down Expand Up @@ -57,7 +56,7 @@ func NewHealthCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
root.Annotations = map[string]string{}
}
// Don't print debug message
root.Annotations[cmdinternal.AgentExecutedAnnotation] = "true" //nolint:goconst
root.Annotations[config.AgentExecutedAnnotation] = "true" //nolint:goconst
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/pro/provider/list/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/devsy-org/devsy/pkg/log"
"github.com/devsy-org/devsy/pkg/platform"
"github.com/devsy-org/devsy/pkg/platform/client"
"github.com/devsy-org/devsy/pkg/platform/labels"
"github.com/devsy-org/devsy/pkg/platform/project"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -85,7 +84,7 @@ func (cmd *WorkspacesCmd) Run(ctx context.Context) error {
if instance.GetLabels() == nil {
instance.Labels = map[string]string{}
}
instance.Labels[labels.ProjectLabel] = p.GetName()
instance.Labels[config.K8sProjectLabel] = p.GetName()

workspaces = append(workspaces, instance)
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/pro/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package provider
import (
"os"

cmdinternal "github.com/devsy-org/devsy/cmd/internal"
"github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/cmd/pro/provider/create"
"github.com/devsy-org/devsy/cmd/pro/provider/get"
Expand Down Expand Up @@ -33,16 +32,13 @@ func NewProProviderCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
globalFlags.Debug = true
}

// Disable debug hints if we execute pro commands from Devsy Desktop
// We're reusing the cmdinternal.AgentExecutedAnnotation for simplicity, could rename in the future
if os.Getenv(config.EnvUI) == config.BoolTrue {
cmd.VisitParents(func(c *cobra.Command) {
// find the root command
if c.Name() == config.BinaryName {
if c.Annotations == nil {
c.Annotations = map[string]string{}
}
c.Annotations[cmdinternal.AgentExecutedAnnotation] = config.BoolTrue
c.Annotations[config.AgentExecutedAnnotation] = config.BoolTrue
}
})
}
Expand Down
17 changes: 9 additions & 8 deletions e2e/tests/up-docker-compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/devsy-org/devsy/e2e/framework"
"github.com/devsy-org/devsy/pkg/compose"
pkgconfig "github.com/devsy-org/devsy/pkg/config"
docker "github.com/devsy-org/devsy/pkg/docker"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
Expand Down Expand Up @@ -73,10 +74,10 @@ var _ = ginkgo.Describe(
ids, err = dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
if err != nil {
return 0
Expand Down Expand Up @@ -116,10 +117,10 @@ var _ = ginkgo.Describe(
ids2, err := dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
framework.ExpectNoError(err)
gomega.Expect(ids2[0]).To(gomega.Equal(ids[0]), "Should use original container")
Expand All @@ -146,10 +147,10 @@ var _ = ginkgo.Describe(
ids, err = dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
if err != nil {
return 0
Expand All @@ -168,10 +169,10 @@ var _ = ginkgo.Describe(
ids2, err := dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
framework.ExpectNoError(err)
gomega.Expect(ids2[0]).NotTo(gomega.Equal(ids[0]), "Should restart container")
Expand Down
9 changes: 7 additions & 2 deletions e2e/tests/up-docker-compose/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/devsy-org/devsy/e2e/framework"
"github.com/devsy-org/devsy/pkg/compose"
pkgconfig "github.com/devsy-org/devsy/pkg/config"
docker "github.com/devsy-org/devsy/pkg/docker"
provider2 "github.com/devsy-org/devsy/pkg/provider"
"github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -197,8 +198,12 @@ func findComposeContainer(
workspaceUID, serviceName string,
) ([]string, error) {
return dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf("%s=%s", compose.ProjectLabel, composeHelper.GetProjectName(workspaceUID)),
fmt.Sprintf("%s=%s", compose.ServiceLabel, serviceName),
fmt.Sprintf(
"%s=%s",
pkgconfig.ComposeProjectLabel,
composeHelper.GetProjectName(workspaceUID),
),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, serviceName),
})
}

Expand Down
13 changes: 7 additions & 6 deletions e2e/tests/up-docker-compose/up_docker_compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/devsy-org/devsy/e2e/framework"
"github.com/devsy-org/devsy/pkg/compose"
pkgconfig "github.com/devsy-org/devsy/pkg/config"
docker "github.com/devsy-org/devsy/pkg/docker"
"github.com/docker/docker/api/types/container"
"github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -498,10 +499,10 @@ var _ = ginkgo.Describe(
ids, err := tc.dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
tc.composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
framework.ExpectNoError(err)
gomega.Expect(ids).To(gomega.HaveLen(1), "1 compose container to be created")
Expand Down Expand Up @@ -552,10 +553,10 @@ var _ = ginkgo.Describe(
ids, err := tc.dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
tc.composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
framework.ExpectNoError(err)
gomega.Expect(ids).To(gomega.HaveLen(1), "1 compose container to be created")
Expand Down Expand Up @@ -586,10 +587,10 @@ var _ = ginkgo.Describe(
ids, err := tc.dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf(
"%s=%s",
compose.ProjectLabel,
pkgconfig.ComposeProjectLabel,
tc.composeHelper.GetProjectName(workspace.UID),
),
fmt.Sprintf("%s=%s", compose.ServiceLabel, "app"),
fmt.Sprintf("%s=%s", pkgconfig.ComposeServiceLabel, "app"),
})
framework.ExpectNoError(err)
gomega.Expect(ids).To(gomega.HaveLen(1), "1 compose container to be created")
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/up/docker_wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/devsy-org/devsy/e2e/framework"
"github.com/devsy-org/devsy/pkg/devcontainer/config"
pkgconfig "github.com/devsy-org/devsy/pkg/config"
docker "github.com/devsy-org/devsy/pkg/docker"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
Expand Down Expand Up @@ -48,7 +48,7 @@ var _ = ginkgo.Describe("testing up command for windows", ginkgo.Label("up-docke
projectName := workspace.ID

ids, err := dockerHelper.FindContainer(ctx, []string{
fmt.Sprintf("%s=%s", config.DockerIDLabel, workspace.UID),
fmt.Sprintf("%s=%s", pkgconfig.DevcontainerIDLabel, workspace.UID),
})
framework.ExpectNoError(err)
gomega.Expect(ids).To(gomega.HaveLen(1), "1 compose container to be created")
Expand Down
Loading
Loading