MCPcopy
hub / github.com/perkeep/perkeep / newImporterHost

Function newImporterHost

cmd/pk-devimport/devimport.go:71–108  ·  view source on GitHub ↗
(server string, importerType string)

Source from the content-addressed store, hash-verified

69}
70
71func 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.

Callers 1

mainFunction · 0.85

Calls 7

AllFunction · 0.92
NewHostFunction · 0.92
getCredentialsFunction · 0.85
BlobRootMethod · 0.80
newClientFunction · 0.70
PropertiesMethod · 0.65
SignerMethod · 0.45

Tested by

no test coverage detected