func()

in internal/core/component.go [538:561]


func (c *Component) GetAccessTokens() (tokens map[string]string, err error) {
	// If access.yaml is found in same directory of component.yaml, see if c.Source is in the map and use the value as accessToken
	accessYamlPath := path.Join(c.PhysicalPath, "access.yaml")
	if err = UnmarshalFile(accessYamlPath, yaml.Unmarshal, &tokens); os.IsNotExist(err) {
		// If the file is not found, return an empty map with no error
		return map[string]string{}, nil
	} else if err != nil {
		logger.Error(emoji.Sprintf(":no_entry_sign: Error unmarshalling access.yaml in '%s'", accessYamlPath))
		return nil, err
	}

	// Attempt to load env variables listed in access.yaml
	for repo, envVar := range tokens {
		token := os.Getenv(envVar)
		if token == "" {
			// Give warning that failed to load env var; but continue and attempt clone
			msg := fmt.Sprintf("Component '%s' attempted to load environment variable '%s'; but is either not set or an empty string. Components with source '%s' may fail to install", c.Name, envVar, repo)
			logger.Warn(emoji.Sprintf(":no_entry_sign: %s", msg))
		} else {
			tokens[repo] = token
		}
	}
	return tokens, err
}