func recreateSessionToken(configFile string, cdsctx internal.CDSContext, contextName string) (*internal.CDSContext, error) {
	req := sdk.AuthConsumerSigninRequest{
		"token": cdsctx.Token,
	}
	client := cdsclient.New(cdsclient.Config{
		Host:                  cdsctx.Host,
		Verbose:               os.Getenv("CDS_VERBOSE") == "true" || cdsctx.Verbose,
		InsecureSkipVerifyTLS: os.Getenv("CDS_INSECURE") == "true" || cdsctx.InsecureSkipVerifyTLS,
	})
	res, err := client.AuthConsumerSignin(sdk.ConsumerBuiltin, req)
	if err != nil {
		return nil, cli.WrapError(err, "cannot signin")
	}
	if res.Token == "" || res.User == nil {
		return nil, cli.NewError("invalid username or token returned by sign in token")
	}
	cdsctx.Session = res.Token
	// resave session token
	if res.Token == cdsctx.Session {
		return &cdsctx, nil
	}

	fi, err := os.OpenFile(configFile, os.O_RDONLY, 0600)
	if err != nil {
		return nil, cli.WrapError(err, "Error while opening file %s", configFile)
	}
	wdata := &bytes.Buffer{}
	if err := internal.StoreContext(fi, wdata, cdsctx); err != nil {
		fi.Close() // nolint
		return nil, err
	}

	if err := fi.Close(); err != nil {
		return nil, cli.WrapError(err, "Error while closing file %s", configFile)
	}
	if err := writeConfigFile(configFile, wdata); err != nil {
		return nil, err
	}

	return &cdsctx, nil
}
// regenerate a session token from a singin token if needed
regenerate a session token from a singin token if needed
// regenerate a session token from a singin token if needed
func recreateSessionToken(configFile string, cdsctx internal.CDSContext, contextName string) (*internal.CDSContext, error) {
	req := sdk.AuthConsumerSigninRequest{
		"token": cdsctx.Token,
	}
	client := cdsclient.New(cdsclient.Config{
		Host:                  cdsctx.Host,
		Verbose:               os.Getenv("CDS_VERBOSE") == "true" || cdsctx.Verbose,
		InsecureSkipVerifyTLS: os.Getenv("CDS_INSECURE") == "true" || cdsctx.InsecureSkipVerifyTLS,
	})
	res, err := client.AuthConsumerSignin(sdk.ConsumerBuiltin, req)
	if err != nil {
		return nil, cli.WrapError(err, "cannot signin")
	}
	if res.Token == "" || res.User == nil {
		return nil, cli.NewError("invalid username or token returned by sign in token")
	}
	cdsctx.Session = res.Token
	if res.Token == cdsctx.Session {
		return &cdsctx, nil
	}
	fi, err := os.OpenFile(configFile, os.O_RDONLY, 0600)
	if err != nil {
		return nil, cli.WrapError(err, "Error while opening file %s", configFile)
	}
	wdata := &bytes.Buffer{}
	if err := internal.StoreContext(fi, wdata, cdsctx); err != nil {
		fi.Close() 
		return nil, err
	}
	if err := fi.Close(); err != nil {
		return nil, cli.WrapError(err, "Error while closing file %s", configFile)
	}
	if err := writeConfigFile(configFile, wdata); err != nil {
		return nil, err
	}
	return &cdsctx, nil
}
func recreateSessionToken ( configFile string , cdsctx internal . CDSContext , contextName string ) ( * internal . CDSContext , error ) { req := sdk . AuthConsumerSigninRequest { " " : cdsctx . Token , } client := cdsclient . New ( cdsclient . Config { Host : cdsctx . Host , Verbose : os . Getenv ( " " ) == " " || cdsctx . Verbose , InsecureSkipVerifyTLS : os . Getenv ( " " ) == " " || cdsctx . InsecureSkipVerifyTLS , } ) res , err := client . AuthConsumerSignin ( sdk . ConsumerBuiltin , req ) if err != nil { return nil , cli . WrapError ( err , " " ) } if res . Token == " " || res . User == nil { return nil , cli . NewError ( " " ) } cdsctx . Session = res . Token if res . Token == cdsctx . Session { return & cdsctx , nil } fi , err := os . OpenFile ( configFile , os . O_RDONLY , 0600 ) if err != nil { return nil , cli . WrapError ( err , " " , configFile ) } wdata := & bytes . Buffer { } if err := internal . StoreContext ( fi , wdata , cdsctx ) ; err != nil { fi . Close ( ) return nil , err } if err := fi . Close ( ) ; err != nil { return nil , cli . WrapError ( err , " " , configFile ) } if err := writeConfigFile ( configFile , wdata ) ; err != nil { return nil , err } return & cdsctx , nil }
regenerate a session token from a singin token if needed
regenerate a session token from a singin token if needed
// resave session token // nolint