github.com/defang-io/defang/src@v0.0.0-20240505002154-bdf411911834/pkg/cli/logout.go (about)

     1  package cli
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/bufbuild/connect-go"
     7  	"github.com/defang-io/defang/src/pkg/cli/client"
     8  	"github.com/defang-io/defang/src/pkg/term"
     9  )
    10  
    11  func Logout(ctx context.Context, client client.Client) error {
    12  	term.Debug(" - Logging out")
    13  	err := client.RevokeToken(ctx)
    14  	// Ignore unauthenticated errors, since we're logging out anyway
    15  	if connect.CodeOf(err) != connect.CodeUnauthenticated {
    16  		return err
    17  	}
    18  	// TODO: remove the cached token file
    19  	// tokenFile := getTokenFile(fabric)
    20  	// if err := os.Remove(tokenFile); err != nil {
    21  	// 	return err
    22  	// }
    23  	return nil
    24  }