Documentation
¶
Index ¶
- Constants
- Variables
- func CreateConfigFileDirIfNotExists() error
- func DebugViperConfig() (string, error)
- func GetAPIKey(ctx context.Context) (string, error)
- func GetBaseURL() string
- func GetConfigDir() (string, error)
- func GetEndpointURL(endpoint string) (string, error)
- func GetUserAgentHeader() string
- func ReadConfigFile(filePath string) error
- func RedactedReqInfo(req *http.Request) string
- func SaveURLToConfig(newURL string) error
- func SchemeHostOnly(longURL string) (string, error)
- func SetURLToConfig(newURL string) error
- func VerifyToken(ctx context.Context, datarobotEndpoint, token string) error
- func WithUserAgent(ctx context.Context, userAgent string) context.Context
- type ComponentDefaults
Constants ¶
const ( // ComponentDefaultsFileName is the name of the component defaults file // This follows copier's data_file convention ComponentDefaultsFileName = ".copier-answers-defaults.yaml" // LegacyComponentDefaultsFileName is the old name for backward compatibility LegacyComponentDefaultsFileName = "component-defaults.yaml" )
const ( DataRobotURL = "endpoint" DataRobotAPIKey = "token" )
const DRAPIURLSuffix = "/api/v2"
Variables ¶
var ErrInvalidURL = errors.New("Invalid URL.")
Functions ¶
func CreateConfigFileDirIfNotExists ¶
func CreateConfigFileDirIfNotExists() error
func DebugViperConfig ¶ added in v0.1.7
func GetBaseURL ¶
func GetBaseURL() string
func GetConfigDir ¶ added in v0.2.52
GetConfigDir returns the config directory, respecting XDG_CONFIG_HOME if set. Falls back to ~/.config/datarobot if XDG_CONFIG_HOME is not set.
func GetEndpointURL ¶
func GetUserAgentHeader ¶ added in v0.2.13
func GetUserAgentHeader() string
func ReadConfigFile ¶
func RedactedReqInfo ¶ added in v0.2.13
func SaveURLToConfig ¶
TODO: I believe we want to delete this function as there is SetURLToConfig function But it is used in cmd/templates/setup/model.go
func SchemeHostOnly ¶ added in v0.2.7
SchemeHostOnly takes a URL like: https://app.datarobot.com/api/v2 and just returns https://app.datarobot.com (no trailing slash)
func SetURLToConfig ¶
SetURLToConfig is a helper function that sets the DataRobot URL with the DRAPIURLSuffix in the config object. It is used by both cmd/auth/set-url and cmd/auth/login to ensure consistent URL formatting. It does NOT write to the config file, in order not to break drconfig.yaml file once URL is not valid or some issues with API key.
func VerifyToken ¶ added in v0.2.7
VerifyToken verifies if the datarobot endpoint + api key pair correspond to a valid pair.
Types ¶
type ComponentDefaults ¶ added in v0.2.26
ComponentDefaults holds default answers for copier templates The structure maps component repo URLs to their default answers This follows copier's data_file semantics but supports multiple repos
func LoadComponentDefaults ¶ added in v0.2.26
func LoadComponentDefaults(explicitPath string) (*ComponentDefaults, error)
LoadComponentDefaults reads the component defaults configuration file Priority order: 1. Explicitly provided path (if not empty) 2. .datarobot/.copier-answers-defaults.yaml in repo root 3. ~/.config/datarobot/.copier-answers-defaults.yaml 4. ~/.config/datarobot/component-defaults.yaml (legacy) Returns an empty config if no file exists
func (*ComponentDefaults) GetDefaultsForRepo ¶ added in v0.2.26
func (c *ComponentDefaults) GetDefaultsForRepo(repoURL string) map[string]interface{}
GetDefaultsForRepo returns the default answers for a specific repository URL Returns an empty map if no defaults are configured
func (*ComponentDefaults) MergeWithCLIData ¶ added in v0.2.26
func (c *ComponentDefaults) MergeWithCLIData(repoURL string, cliData map[string]interface{}) map[string]interface{}
MergeWithCLIData merges configured defaults with CLI-provided --data arguments CLI arguments take precedence over defaults