vsphere/config.go
func (c *Config) SavedRestSessionOrNew(u *url.URL) (*tags.RestClient, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()

	client, valid, err := c.LoadRestClient(ctx, u)
	if err != nil {
		return nil, fmt.Errorf("error trying to load vSphere REST session from disk: %s", err)
	}
	if !valid {
		log.Printf("[DEBUG] Creating new CIS REST API session on endpoint %s", c.VSphereServer)
		if err := client.Login(ctx); err != nil {
			return nil, fmt.Errorf("Error connecting to CIS REST endpoint: %s", err)
		}
		log.Println("[DEBUG] CIS REST API session creation successful")
	}
	return client, nil
}
func (c *Config) SavedRestSessionOrNew(u *url.URL) (*tags.RestClient, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()

	client, valid, err := c.LoadRestClient(ctx, u)
	if err != nil {
		return nil, fmt.Errorf("error trying to load vSphere REST session from disk: %s", err)
	}
	if !valid {
		log.Printf("[DEBUG] Creating new CIS REST API session on endpoint %s", c.VSphereServer)
		if err := client.Login(ctx); err != nil {
			return nil, fmt.Errorf("Error connecting to CIS REST endpoint: %s", err)
		}
		log.Println("[DEBUG] CIS REST API session creation successful")
	}
	return client, nil
}
// SavedRestSessionOrNew either loads a saved REST session from disk, or creates
// a new one.