Skip to content
Merged
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
8 changes: 4 additions & 4 deletions cmd/pro/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (cmd *LoginCmd) addProviderByVersion(
if rv.LT(semver.Version{Major: 0, Minor: 6, Patch: 999}) &&
remoteVersion != versionpkg.DevVersion {
log.Debug("remote version < 0.7.0, installing proxy provider")
return cmd.addLoftProvider(ctx, devsyConfig, fullURL)
return cmd.addDevsyProvider(ctx, devsyConfig, fullURL)
}

_, err = workspace.AddProvider(ctx, devsyConfig, cmd.Provider, "pro")
Expand Down Expand Up @@ -375,12 +375,12 @@ func (cmd *LoginCmd) loginAndConfigure(
return nil
}

func (cmd *LoginCmd) addLoftProvider(
func (cmd *LoginCmd) addDevsyProvider(
ctx context.Context,
devsyConfig *config.Config,
url string,
) error {
// find out loft version
// find out devsy version
err := cmd.resolveProviderSource(url)
if err != nil {
return err
Expand Down Expand Up @@ -482,7 +482,7 @@ func performLogin(params loginParams) error {
return params.loader.LoginWithAccessKey(params.url, params.accessKey, true, true)
}
if params.skipBrowserLogin {
return fmt.Errorf("unable to login to loft host")
return fmt.Errorf("unable to login to devsy host")
}

return params.loader.Login(params.url, true)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pro/provider/list/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (cmd *WorkspacesCmd) Run(ctx context.Context) error {
)
}

filterByOwner := os.Getenv(config.EnvLoftFilterByOwner) == config.BoolTrue
filterByOwner := os.Getenv(config.EnvFilterByOwner) == config.BoolTrue
workspaces := []*managementv1.DevsyWorkspaceInstance{}
for _, p := range projectList.Items {
workspaces = append(
Expand Down
4 changes: 2 additions & 2 deletions cmd/pro/provider/watch/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd *WorkspacesCmd) Run(
cmd.Context = config.DefaultContext
}

projectName := os.Getenv(config.EnvLoftProject)
projectName := os.Getenv(config.EnvProject)
if projectName == "" {
return fmt.Errorf("project name not found")
}
Expand All @@ -100,7 +100,7 @@ func (cmd *WorkspacesCmd) Run(
workspaceInformer := factory.Management().V1().DevsyWorkspaceInstances()

self := baseClient.Self()
filterByOwner := os.Getenv(config.EnvLoftFilterByOwner) == config.BoolTrue
filterByOwner := os.Getenv(config.EnvFilterByOwner) == config.BoolTrue
instanceStore := newStore(workspaceInformer, self, cmd.Context, filterByOwner)

_, err = workspaceInformer.Informer().
Expand Down
78 changes: 39 additions & 39 deletions cmd/pro/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

storagev1 "github.com/devsy-org/api/pkg/apis/storage/v1"
"github.com/devsy-org/api/pkg/auth"
loftclientset "github.com/devsy-org/api/pkg/clientset/versioned"
devsyclientset "github.com/devsy-org/api/pkg/clientset/versioned"
proflags "github.com/devsy-org/devsy/cmd/pro/flags"
"github.com/devsy-org/devsy/pkg/config"
"github.com/devsy-org/devsy/pkg/log"
Expand All @@ -42,9 +42,9 @@ import (
)

const (
LoftRouterDomainSecret = "loft-router-domain" // #nosec G101
passwordChangedHint = "(has been changed)"
defaultUser = "admin"
DevsyRouterDomainSecret = "loft-router-domain" // #nosec G101
passwordChangedHint = "(has been changed)"
defaultUser = "admin"

ingressNginx = "ingress-nginx"
helmRepositoryConfig = "--repository-config=''"
Expand Down Expand Up @@ -364,14 +364,14 @@ func (cmd *StartCmd) success(ctx context.Context) error {
}

// wait until deployment is ready
loftPod, err := cmd.waitForDeployment(ctx)
devsyPod, err := cmd.waitForDeployment(ctx)
if err != nil {
return err
}

// check if installed locally
if isInstalledLocally(ctx, cmd.KubeClient, cmd.Namespace) {
return cmd.successLocalOrRouter(ctx, loftPod)
return cmd.successLocalOrRouter(ctx, devsyPod)
}

// get login link
Expand All @@ -392,15 +392,15 @@ func (cmd *StartCmd) success(ctx context.Context) error {
return cmd.successRemote(ctx, host)
}

func (cmd *StartCmd) successLocalOrRouter(ctx context.Context, loftPod *corev1.Pod) error {
// check if loft domain secret is there
func (cmd *StartCmd) successLocalOrRouter(ctx context.Context, devsyPod *corev1.Pod) error {
// check if devsy domain secret is there
if !cmd.NoTunnel {
loftRouterDomain, err := cmd.pingLoftRouter(ctx, loftPod)
devsyRouterDomain, err := cmd.pingDevsyRouter(ctx, devsyPod)
if err != nil {
log.Errorf("Error retrieving loft router domain: %v", err)
log.Errorf("Error retrieving devsy router domain: %v", err)
log.Info("Fallback to use port-forwarding")
} else if loftRouterDomain != "" {
return cmd.successLoftRouter(loftRouterDomain)
} else if devsyRouterDomain != "" {
return cmd.successDevsyRouter(devsyRouterDomain)
}
}

Expand Down Expand Up @@ -674,7 +674,7 @@ func checkCLITools(ctx context.Context, kubeContext string) error {
_, err := exec.LookPath("helm")
if err != nil {
return fmt.Errorf(
"seems like helm is not installed. Helm is required for the installation of loft. " +
"seems like helm is not installed. Helm is required for the installation of devsy. " +
"Visit https://helm.sh/docs/intro/install/ for install instructions",
)
}
Expand All @@ -687,7 +687,7 @@ func checkCLITools(ctx context.Context, kubeContext string) error {
_, err = exec.LookPath("kubectl")
if err != nil {
return fmt.Errorf(
"seems like kubectl is not installed. Kubectl is required for the installation of loft. " +
"seems like kubectl is not installed. Kubectl is required for the installation of devsy. " +
"Visit https://kubernetes.io/docs/tasks/tools/install-kubectl/ for install instructions",
)
}
Expand Down Expand Up @@ -843,9 +843,9 @@ func (cmd *StartCmd) ensureHostAndIngress(ctx context.Context) error {
}

func (cmd *StartCmd) waitForDeployment(ctx context.Context) (*corev1.Pod, error) {
// wait for loft pod to start
// wait for devsy pod to start
log.Info("waiting for Devsy Pro pod to be running")
loftPod, err := platform.WaitForPodReady(ctx, cmd.KubeClient, cmd.Namespace)
devsyPod, err := platform.WaitForPodReady(ctx, cmd.KubeClient, cmd.Namespace)
log.Infof("release Pod started")
if err != nil {
return nil, err
Expand All @@ -867,35 +867,35 @@ func (cmd *StartCmd) waitForDeployment(ctx context.Context) (*corev1.Pod, error)
cmd.Password = ""
}

return loftPod, nil
return devsyPod, nil
}

func (cmd *StartCmd) pingLoftRouter(ctx context.Context, loftPod *corev1.Pod) (string, error) {
loftRouterSecret, err := cmd.KubeClient.CoreV1().
Secrets(loftPod.Namespace).
Get(ctx, LoftRouterDomainSecret, metav1.GetOptions{})
func (cmd *StartCmd) pingDevsyRouter(ctx context.Context, devsyPod *corev1.Pod) (string, error) {
devsyRouterSecret, err := cmd.KubeClient.CoreV1().
Secrets(devsyPod.Namespace).
Get(ctx, DevsyRouterDomainSecret, metav1.GetOptions{})
if err != nil {
if kerrors.IsNotFound(err) {
return "", nil
}

return "", fmt.Errorf("find loft router domain secret: %w", err)
} else if loftRouterSecret.Data == nil || len(loftRouterSecret.Data["domain"]) == 0 {
return "", fmt.Errorf("find devsy router domain secret: %w", err)
} else if devsyRouterSecret.Data == nil || len(devsyRouterSecret.Data["domain"]) == 0 {
return "", nil
}

// get the domain from secret
loftRouterDomain := string(loftRouterSecret.Data["domain"])
devsyRouterDomain := string(devsyRouterSecret.Data["domain"])

// wait until loft is reachable at the given url
// wait until devsy is reachable at the given url
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
log.Infof("Waiting until Devsy Pro is reachable at https://%s", loftRouterDomain)
log.Infof("Waiting until Devsy Pro is reachable at https://%s", devsyRouterDomain)
err = wait.PollUntilContextTimeout(
ctx,
time.Second*3,
Expand All @@ -905,7 +905,7 @@ func (cmd *StartCmd) pingLoftRouter(ctx context.Context, loftPod *corev1.Pod) (s
req, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
"https://"+loftRouterDomain+"/version",
"https://"+devsyRouterDomain+"/version",
nil,
)
if err != nil {
Expand All @@ -924,10 +924,10 @@ func (cmd *StartCmd) pingLoftRouter(ctx context.Context, loftPod *corev1.Pod) (s
return "", err
}

return loftRouterDomain, nil
return devsyRouterDomain, nil
}

func (cmd *StartCmd) successLoftRouter(url string) error {
func (cmd *StartCmd) successDevsyRouter(url string) error {
if !cmd.NoLogin {
err := cmd.login(url)
if err != nil {
Expand Down Expand Up @@ -1030,7 +1030,7 @@ func (cmd *StartCmd) loginViaCLI(url string) error {
return err
}

// log into loft
// log into devsy
loader, err := client.NewClientFromPath(cmd.Config)
if err != nil {
return err
Expand Down Expand Up @@ -1103,10 +1103,10 @@ func getDefaultPassword(
kubeClient kubernetes.Interface,
namespace string,
) (string, error) {
loftNamespace, err := kubeClient.CoreV1().Namespaces().Get(ctx, namespace, metav1.GetOptions{})
devsyNamespace, err := kubeClient.CoreV1().Namespaces().Get(ctx, namespace, metav1.GetOptions{})
if err != nil {
if kerrors.IsNotFound(err) {
loftNamespace, err := kubeClient.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
devsyNamespace, err := kubeClient.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
Expand All @@ -1115,13 +1115,13 @@ func getDefaultPassword(
return "", err
}

return string(loftNamespace.UID), nil
return string(devsyNamespace.UID), nil
}

return "", err
}

return string(loftNamespace.UID), nil
return string(devsyNamespace.UID), nil
}

func isInstalledLocally(
Expand Down Expand Up @@ -1282,17 +1282,17 @@ func ensureAdminPassword(
restConfig *rest.Config,
password string,
) (bool, error) {
loftClient, err := loftclientset.NewForConfig(restConfig)
devsyClient, err := devsyclientset.NewForConfig(restConfig)
if err != nil {
return false, err
}

admin, err := loftClient.StorageV1().Users().Get(ctx, "admin", metav1.GetOptions{})
admin, err := devsyClient.StorageV1().Users().Get(ctx, "admin", metav1.GetOptions{})
switch {
case err != nil && !kerrors.IsNotFound(err):
return false, err
case admin == nil:
admin, err = loftClient.StorageV1().Users().Create(ctx, &storagev1.User{
admin, err = devsyClient.StorageV1().Users().Create(ctx, &storagev1.User{
ObjectMeta: metav1.ObjectMeta{
Name: "admin",
},
Expand Down Expand Up @@ -1419,7 +1419,7 @@ func isHostReachable(ctx context.Context, host string) (bool, error) {
// we disable http2 as Kubernetes has problems with this
transport.ForceAttemptHTTP2 = false
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
// wait until loft is reachable at the given url
// wait until devsy is reachable at the given url
client := &http.Client{Transport: transport}
url := "https://" + host + "/version"
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
Expand Down Expand Up @@ -1462,7 +1462,7 @@ func upgradeRelease(
chartName, chartRepo, kubeContext, namespace string,
extraArgs []string,
) error {
// now we install loft
// now we install devsy
args := []string{
"upgrade",
defaultReleaseName,
Expand Down
22 changes: 11 additions & 11 deletions cmd/pro/start_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (cmd *StartCmd) startDocker(ctx context.Context) error {
return err
}

// try to find loft container
containerID, err := cmd.findLoftContainer(ctx, name, true)
// try to find devsy container
containerID, err := cmd.findDevsyContainer(ctx, name, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (cmd *StartCmd) successDocker(ctx context.Context, containerID string) erro
}

// wait until Devsy is ready
host, err := cmd.waitForLoftDocker(ctx, containerID)
host, err := cmd.waitForDevsyDocker(ctx, containerID)
if err != nil {
return err
}
Expand All @@ -147,7 +147,7 @@ func (cmd *StartCmd) successDocker(ctx context.Context, containerID string) erro
func(ctx context.Context) (bool, error) {
containerDetails, err := cmd.inspectContainer(ctx, containerID)
if err != nil {
return false, fmt.Errorf("inspect loft container: %w", err)
return false, fmt.Errorf("inspect devsy container: %w", err)
} else if containerDetails.State.Status == devcconfig.ContainerStatusExited ||
containerDetails.State.Status == devcconfig.ContainerStatusDead {
logs, _ := cmd.logsContainer(ctx, containerID)
Expand Down Expand Up @@ -194,7 +194,7 @@ Thanks for using Devsy Pro!
)
}

func (cmd *StartCmd) waitForLoftDocker(ctx context.Context, containerID string) (string, error) {
func (cmd *StartCmd) waitForDevsyDocker(ctx context.Context, containerID string) (string, error) {
log.Info("Wait for Devsy Pro to become available")

// check for local port
Expand Down Expand Up @@ -223,7 +223,7 @@ func (cmd *StartCmd) waitForLoftDocker(ctx context.Context, containerID string)
time.Minute*10,
true,
func(ctx context.Context) (bool, error) {
url, err = cmd.findLoftRouter(ctx, containerID)
url, err = cmd.findDevsyRouter(ctx, containerID)
if err != nil {
return false, nil
}
Expand All @@ -232,13 +232,13 @@ func (cmd *StartCmd) waitForLoftDocker(ctx context.Context, containerID string)
},
)
if waitErr != nil {
return "", fmt.Errorf("error waiting for loft router domain: %w", waitErr)
return "", fmt.Errorf("error waiting for devsy router domain: %w", waitErr)
}

return url, nil
}

func (cmd *StartCmd) findLoftRouter(ctx context.Context, id string) (string, error) {
func (cmd *StartCmd) findDevsyRouter(ctx context.Context, id string) (string, error) {
out, err := cmd.buildDockerCmd(ctx, "exec", id, "cat", "/var/lib/loft/loft-domain.txt").Output()
if err != nil {
return "", WrapCommandError(out, err)
Expand All @@ -252,7 +252,7 @@ func (cmd *StartCmd) prepareDocker() error {
_, err := exec.LookPath("docker")
if err != nil {
return fmt.Errorf(
"seems like docker is not installed. Docker is required for the installation of loft. " +
"seems like docker is not installed. Docker is required for the installation of devsy. " +
"Visit https://docs.docker.com/engine/install/ for install instructions",
)
}
Expand Down Expand Up @@ -325,7 +325,7 @@ func (cmd *StartCmd) runInDocker(ctx context.Context, name string) (string, erro
return "", err
}

return cmd.findLoftContainer(ctx, name, false)
return cmd.findDevsyContainer(ctx, name, false)
}

func (cmd *StartCmd) logsContainer(ctx context.Context, id string) (string, error) {
Expand Down Expand Up @@ -366,7 +366,7 @@ func (cmd *StartCmd) removeContainer(ctx context.Context, id string) error {
return nil
}

func (cmd *StartCmd) findLoftContainer(
func (cmd *StartCmd) findDevsyContainer(
ctx context.Context,
name string,
onlyRunning bool,
Expand Down
Loading
Loading