-
Notifications
You must be signed in to change notification settings - Fork 71
feat: support v2 sync protocol #4634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
157de85
c8cfd88
9161674
b504e1d
7ee235a
7dbdb17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ defmodule Lightning.VersionControl do | |
| alias Ecto.Multi | ||
| alias Lightning.Accounts.User | ||
| alias Lightning.Extensions.UsageLimiting | ||
| alias Lightning.Projects.Project | ||
| alias Lightning.Repo | ||
| alias Lightning.VersionControl.Audit | ||
| alias Lightning.VersionControl.Events | ||
|
|
@@ -572,8 +573,15 @@ defmodule Lightning.VersionControl do | |
|
|
||
| defp maybe_create_config_blob(tesla_client, repo_connection) do | ||
| if is_nil(repo_connection.config_path) do | ||
| content = | ||
| if repo_connection.use_yaml_config do | ||
| openfn_yaml(repo_connection) | ||
| else | ||
| config_json(repo_connection) | ||
| end | ||
|
|
||
| GithubClient.create_blob(tesla_client, repo_connection.repo, %{ | ||
| content: config_json(repo_connection) | ||
| content: content | ||
| }) | ||
| else | ||
| {:ok, nil} | ||
|
|
@@ -625,6 +633,33 @@ defmodule Lightning.VersionControl do | |
| ) | ||
| end | ||
|
|
||
| defp openfn_yaml(repo_connection) do | ||
| project = Repo.get!(Project, repo_connection.project_id) | ||
|
|
||
| inserted_at = DateTime.to_iso8601(project.inserted_at) | ||
| updated_at = DateTime.to_iso8601(project.updated_at) | ||
|
|
||
| """ | ||
| project: | ||
| uuid: #{project.id} | ||
| endpoint: #{LightningWeb.Endpoint.url()} | ||
| alias: #{project.env} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh - interesting one. The alias should be the project name if this is a sandbox, or otherwise I don't expect a lot of syncs to be set up with sandboxes. Maybe we should just not set an alias for now? Let users set it up later if they want
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the first pull will cause a lot of this metadata to be updated. Maybe its' best to just set the uuid and endpoint and let the CLI own the rest? |
||
| inserted_at: #{inserted_at} | ||
| updated_at: #{updated_at} | ||
| id: #{project.name} | ||
| name: #{project.name} | ||
| workspace: | ||
| credentials: credentials.yaml | ||
| dirs: | ||
| projects: .projects | ||
| workflows: workflows | ||
| formats: | ||
| openfn: yaml | ||
| project: yaml | ||
| workflow: yaml | ||
| """ | ||
| end | ||
|
|
||
| defp pull_yml_target_path do | ||
| ".github/workflows/openfn-pull.yml" | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| defmodule Lightning.Repo.Migrations.UseSyncV2 do | ||
| use Ecto.Migration | ||
|
|
||
| def change do | ||
| alter table(:project_repo_connections) do | ||
| add :use_yaml_config, :boolean, null: false, default: false | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to
sync_version, wherefalseis1andtrueis2