github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/configuration/coreconfig/config_data.go (about)

     1  package coreconfig
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"code.cloudfoundry.org/cli/cf/models"
     7  )
     8  
     9  type AuthPromptType string
    10  
    11  const (
    12  	AuthPromptTypeText     AuthPromptType = "TEXT"
    13  	AuthPromptTypePassword AuthPromptType = "PASSWORD"
    14  )
    15  
    16  type AuthPrompt struct {
    17  	Type        AuthPromptType
    18  	DisplayName string
    19  }
    20  
    21  type Data struct {
    22  	ConfigVersion            int
    23  	Target                   string
    24  	APIVersion               string
    25  	AuthorizationEndpoint    string
    26  	DopplerEndPoint          string
    27  	UaaEndpoint              string
    28  	RoutingAPIEndpoint       string
    29  	AccessToken              string
    30  	UAAOAuthClient           string
    31  	UAAOAuthClientSecret     string
    32  	SSHOAuthClient           string
    33  	RefreshToken             string
    34  	OrganizationFields       models.OrganizationFields
    35  	SpaceFields              models.SpaceFields
    36  	SSLDisabled              bool
    37  	AsyncTimeout             uint
    38  	Trace                    string
    39  	ColorEnabled             string
    40  	Locale                   string
    41  	PluginRepos              []models.PluginRepo
    42  	MinCLIVersion            string
    43  	MinRecommendedCLIVersion string
    44  }
    45  
    46  func NewData() *Data {
    47  	data := new(Data)
    48  
    49  	data.UAAOAuthClient = "cf"
    50  	data.UAAOAuthClientSecret = ""
    51  
    52  	return data
    53  }
    54  
    55  func (d *Data) JSONMarshalV3() ([]byte, error) {
    56  	d.ConfigVersion = 3
    57  	return json.MarshalIndent(d, "", "  ")
    58  }
    59  
    60  func (d *Data) JSONUnmarshalV3(input []byte) error {
    61  	err := json.Unmarshal(input, d)
    62  	if err != nil {
    63  		return err
    64  	}
    65  
    66  	if d.ConfigVersion != 3 {
    67  		*d = Data{}
    68  		return nil
    69  	}
    70  
    71  	return nil
    72  }