vsphere/config.go
func (c *Config) LoadRestClient(ctx context.Context, u *url.URL) (*tags.RestClient, bool, error) {
	id, err := c.readRestSessionID()
	if err != nil {
		return nil, false, err
	}

	client := tags.NewClientWithSessionID(u, c.InsecureFlag, "", id)

	if id == "" {
		log.Println("[DEBUG] No cached REST session data found or persistence not enabled, new session necessary")
		return client, false, nil
	}

	if !client.Valid(ctx) {
		log.Println("[DEBUG] Cached REST client session data not valid, new session necessary")
		return client, false, nil
	}

	log.Println("[DEBUG] Cached REST client session loaded successfully")
	return client, true, nil
}
func (c *Config) LoadRestClient(ctx context.Context, u *url.URL) (*tags.RestClient, bool, error) {
	id, err := c.readRestSessionID()
	if err != nil {
		return nil, false, err
	}

	client := tags.NewClientWithSessionID(u, c.InsecureFlag, "", id)

	if id == "" {
		log.Println("[DEBUG] No cached REST session data found or persistence not enabled, new session necessary")
		return client, false, nil
	}

	if !client.Valid(ctx) {
		log.Println("[DEBUG] Cached REST client session data not valid, new session necessary")
		return client, false, nil
	}

	log.Println("[DEBUG] Cached REST client session loaded successfully")
	return client, true, nil
}
// LoadRestClient loads a saved vSphere REST API session from disk, previously
// saved by SaveRestClient, checking it for validity before returning it. If
// it's not valid, false is returned as the third return value, but the client
// can still be technically used for logging in by calling Login on the client.