-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix okteto endpoints
namespace detection from okteto.yml
#4186
Changes from 7 commits
a4e7a04
bcf3330
3a313a3
f771f39
f512832
04d2425
e0b7d6b
231827a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ import ( | |
"strings" | ||
|
||
contextCMD "github.com/okteto/okteto/cmd/context" | ||
"github.com/okteto/okteto/cmd/utils" | ||
"github.com/okteto/okteto/pkg/devenvironment" | ||
"github.com/okteto/okteto/pkg/endpoints" | ||
oktetoErrors "github.com/okteto/okteto/pkg/errors" | ||
|
@@ -32,6 +31,7 @@ import ( | |
"github.com/okteto/okteto/pkg/log/io" | ||
"github.com/okteto/okteto/pkg/model" | ||
"github.com/okteto/okteto/pkg/okteto" | ||
"github.com/spf13/afero" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
|
@@ -83,6 +83,7 @@ func NewEndpointGetter(k8sLogger *io.K8sLogger) (EndpointGetter, error) { | |
// Endpoints deploys the okteto manifest | ||
func Endpoints(ctx context.Context, k8sLogger *io.K8sLogger) *cobra.Command { | ||
options := &EndpointsOptions{} | ||
fs := afero.NewOsFs() | ||
cmd := &cobra.Command{ | ||
Use: "endpoints", | ||
Short: "Show endpoints for an environment", | ||
|
@@ -93,32 +94,20 @@ func Endpoints(ctx context.Context, k8sLogger *io.K8sLogger) *cobra.Command { | |
return err | ||
} | ||
options.ManifestPath = model.GetManifestPathFromWorkdir(options.ManifestPath, workdir) | ||
} | ||
|
||
ctxResource, err := utils.LoadManifestContext(options.ManifestPath) | ||
if err != nil { | ||
if oktetoErrors.IsNotExist(err) { | ||
ctxResource = &model.ContextResource{} | ||
// check whether the manifest file provided by -f exists or not | ||
if _, err := fs.Stat(options.ManifestPath); err != nil { | ||
return oktetoErrors.UserError{ | ||
E: fmt.Errorf("the okteto manifest file '%s' does not exist", options.ManifestPath), | ||
Hint: "Check the path to the okteto manifest file", | ||
} | ||
} | ||
} | ||
|
||
if err := ctxResource.UpdateNamespace(options.Namespace); err != nil { | ||
return err | ||
} | ||
|
||
if err := ctxResource.UpdateContext(options.K8sContext); err != nil { | ||
return err | ||
} | ||
|
||
ctxOptions := &contextCMD.Options{ | ||
Context: ctxResource.Context, | ||
Namespace: ctxResource.Namespace, | ||
} | ||
if options.Output == "" { | ||
ctxOptions.Show = true | ||
} | ||
if err := contextCMD.NewContextCommand().Run(ctx, ctxOptions); err != nil { | ||
return err | ||
// Loads, updates and uses the context from path. If not found, it creates and uses a new context | ||
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, contextCMD.Options{Show: options.Output == ""}); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why for the endpoints command the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
or
In those scenarios we cannot output the plaintext header or it would break those scenarios. For Worth mentioning that for "plaintext" in most commands of the CLI we use empty string. So by default an empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For I see it working fine but I think this is confusing for the user. If I execute |
||
if err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.Options{Namespace: options.Namespace, Show: false}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
eg, err := NewEndpointGetter(k8sLogger) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same logic used in
okteto deploy