-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a4e7a04
fix(endpoints): detect namespace from manifest and check for manifest…
andreafalzetti bcf3330
update error msg
andreafalzetti 3a313a3
fix linter
andreafalzetti f771f39
fix: endpoints output
andreafalzetti f512832
revert unecessary change
andreafalzetti 04d2425
fix: header
andreafalzetti e0b7d6b
change default options not pointer
andreafalzetti 231827a
fix: handle case when namespace is provided in both places
andreafalzetti File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,22 @@ 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 | ||
// false for 'json' and 'md' to avoid breaking their syntax | ||
showCtxHeader := options.Output == "" | ||
// Loads, updates and uses the context from path. If not found, it creates and uses a new context | ||
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. This is the same logic used in |
||
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, contextCMD.Options{Show: showCtxHeader}); err != nil { | ||
if err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.Options{Namespace: options.Namespace, Show: showCtxHeader}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
eg, err := NewEndpointGetter(k8sLogger) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👏 Thanks for the comment clarifying the case