Skip to content

Commit

Permalink
fix(endpoints): check if manifest exists
Browse files Browse the repository at this point in the history
  • Loading branch information
andreafalzetti committed Feb 20, 2024
1 parent 907e45e commit 5ded92b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/deploy/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/spf13/afero"
"os"
"sort"
"strings"

contextCMD "github.com/okteto/okteto/cmd/context"
"github.com/okteto/okteto/pkg/devenvironment"
"github.com/okteto/okteto/pkg/endpoints"
oktetoErrors "github.com/okteto/okteto/pkg/errors"
"github.com/okteto/okteto/pkg/format"
"github.com/okteto/okteto/pkg/k8s/ingresses"
oktetoLog "github.com/okteto/okteto/pkg/log"
Expand Down Expand Up @@ -82,6 +82,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",
Expand All @@ -92,13 +93,14 @@ func Endpoints(ctx context.Context, k8sLogger *io.K8sLogger) *cobra.Command {
return err
}
options.ManifestPath = model.GetManifestPathFromWorkdir(options.ManifestPath, workdir)
// check whether the manifest file provided by -f exists or not
if _, err := fs.Stat(options.ManifestPath); err != nil {
return fmt.Errorf("%s file doesn't exist", options.ManifestPath)
}
}

// 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); err != nil {
if err.Error() == fmt.Errorf(oktetoErrors.ErrNotLogged, okteto.CloudURL).Error() {
return err
}
if err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.Options{Namespace: options.Namespace}); err != nil {
return err
}
Expand Down

0 comments on commit 5ded92b

Please sign in to comment.