(server string, importerType string)
| 69 | } |
| 70 | |
| 71 | func newImporterHost(server string, importerType string) (*importer.Host, error) { |
| 72 | cl := newClient(server) |
| 73 | signer, err := cl.Signer() |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | // TODO(mpl): technically not true, but works for now. |
| 78 | baseURL, err := cl.BlobRoot() |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | |
| 83 | var clientID, clientSecret string |
| 84 | |
| 85 | if importer.All()[importerType].Properties().NeedsAPIKey { |
| 86 | clientID, clientSecret, err = getCredentials(cl, importerType) |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | hc := importer.HostConfig{ |
| 93 | BaseURL: baseURL, |
| 94 | Prefix: "/importer/", // TODO(mpl): do not hardcode this prefix |
| 95 | Target: cl, |
| 96 | BlobSource: cl, |
| 97 | Signer: signer, |
| 98 | Search: cl, |
| 99 | ClientId: map[string]string{ |
| 100 | importerType: clientID, |
| 101 | }, |
| 102 | ClientSecret: map[string]string{ |
| 103 | importerType: clientSecret, |
| 104 | }, |
| 105 | } |
| 106 | |
| 107 | return importer.NewHost(hc) |
| 108 | } |
| 109 | |
| 110 | // getCredentials returns the OAuth clientID and clientSecret found in the |
| 111 | // importer node of the given importerType. |
no test coverage detected