Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

oneclickexport: add code host configs export functionality #39855

Merged
merged 2 commits into from
Aug 4, 2022

Conversation

sashaostrikov
Copy link
Contributor

@sashaostrikov sashaostrikov commented Aug 3, 2022

One thing: current design of how ExportRequest is composed and processed (very ugly and straightforward ATM) will be changed when new Processor types are added.

I'll resolve merge conflicts after parent PR is merged.
✅Conflicts resolved✅

Depends on https://github.com/sourcegraph/sourcegraph/pull/39813

Closes https://github.com/sourcegraph/sourcegraph/issues/39618

Test plan

Separate test case for code host config export is added. Cumulative test for complete export of everything currently supported is added.

Copy link
Contributor

@varsanojidan varsanojidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

return s.Type
}

type CodeHostConfigProcessor struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to split these processor implementation types into different files? If we add just a few more, it might start to get cluttered here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do it when it starts to become cluttered. Too many files too early on does the opposite right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to separate the files by type (config export, db query export, etc) when there is more code, as Indra mentioned

func (c CodeHostConfigProcessor) Process(ctx context.Context, _ *ConfigRequest, dir string) {
externalServices, err := c.db.ExternalServices().List(ctx, database.ExternalServicesListOptions{})
if err != nil {
c.logger.Error("Error during getting external services", log.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error getting external services

c.logger.Error("Error during marshalling the code host config", log.Error(err))
}

err = ioutil.WriteFile(dir+"/code-host-config.txt", configBytes, 0644)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment on the other PR, is there a reason for the .txt over .json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to .json

err = ioutil.WriteFile(dir+"/code-host-config.txt", configBytes, 0644)

if err != nil {
c.logger.Error("Error during site config export", log.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error during code host config export

Copy link
Contributor

@indradhanush indradhanush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks in the right direction! 👍

Holding on to the LGTM for when the preceding PR is merged.

Comment on lines +21 to +22
const (
wantSiteConfig = `{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not sure why I can't see the suggest changes button in this PR)

Nit: I see only a single const here. Maybe we can declare it directly const wantSiteConfig = ... instead of const ()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're added in following PR :)

return s.Type
}

type CodeHostConfigProcessor struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do it when it starts to become cluttered. Too many files too early on does the opposite right now.

Base automatically changed from ao/one-click-export-core to main August 4, 2022 09:59
@sashaostrikov sashaostrikov force-pushed the ao/one-click-export-code-host-config branch from 10af0b9 to 3a82fc8 Compare August 4, 2022 10:10
@sashaostrikov sashaostrikov merged commit a2272ef into main Aug 4, 2022
@sashaostrikov sashaostrikov deleted the ao/one-click-export-code-host-config branch August 4, 2022 10:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement code host config import processor
3 participants