Skip to content
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

Add support for Databricks Repos #771

Merged
merged 5 commits into from
Aug 13, 2021
Merged

Add support for Databricks Repos #771

merged 5 commits into from
Aug 13, 2021

Conversation

alexott
Copy link
Contributor

@alexott alexott commented Aug 11, 2021

This PR adds databricks_repo resource to manage Databricks Repos

@codecov
Copy link

codecov bot commented Aug 11, 2021

Codecov Report

Merging #771 (890e888) into master (ee73c4a) will increase coverage by 0.12%.
The diff coverage is 90.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #771      +/-   ##
==========================================
+ Coverage   83.42%   83.54%   +0.12%     
==========================================
  Files          91       92       +1     
  Lines        8227     8364     +137     
==========================================
+ Hits         6863     6988     +125     
- Misses        862      869       +7     
- Partials      502      507       +5     
Impacted Files Coverage Δ
qa/testing.go 69.02% <0.00%> (ø)
exporter/importables.go 74.82% <87.17%> (+0.84%) ⬆️
workspace/resource_repo.go 92.39% <92.39%> (ø)
access/resource_permissions.go 70.31% <100.00%> (+0.13%) ⬆️
common/http.go 85.46% <100.00%> (ø)
identity/data_current_user.go 93.93% <100.00%> (+1.08%) ⬆️
provider/provider.go 95.00% <100.00%> (+0.01%) ⬆️

@alexott alexott marked this pull request as draft August 12, 2021 05:49
@alexott alexott changed the title Add support for Databricks Repos [DRAFT] Add support for Databricks Repos Aug 12, 2021
@alexott alexott marked this pull request as ready for review August 12, 2021 07:40
this would be used when checkout the git repo into "custom" folder inside user's Repos location
@alexott alexott changed the title [DRAFT] Add support for Databricks Repos Add support for Databricks Repos Aug 12, 2021
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

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

Please adjust repos resource to reflect_resource

exporter/importables.go Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo.go Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo.go Outdated Show resolved Hide resolved
workspace/resource_repo_test.go Outdated Show resolved Hide resolved
workspace/resource_repo_test.go Show resolved Hide resolved
@alexott alexott requested a review from nfx August 12, 2021 11:06

func ResourceRepo() *schema.Resource {
s := common.StructToSchema(ReposInformation{}, func(s map[string]*schema.Schema) map[string]*schema.Schema {
s["url"].ForceNew = true
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder if we should add force_new to reflect_resource

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 thought about that, just didn't want to pollute the PR for specific functionality

}
// TODO: update may change ONE OF (url AND provider (optional)), (path), or (branch OR tag).
// for URL/provider force re-create as there are limits on what could be done for changing URL/provider
if path, ok := r["path"]; ok {
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 the code would be cleaner if this method accepts this struct

type updateRequest struct {
  Branch       string `json:"branch,omitempty"`
  Tag.            string `json:"tag,omitempty"`
}

because it's going to be easier to use common.DataToStructPointer & common.StructToData and there'll be less errors to handle.

and then the schema might be composed of calling StructToSchema twice?.. usage of reflection simplifies resource maintenance, because we have to deal just with structs...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addition of path, and necessity of handling it differently makes things harder - setting branch/tag here is different from Update method. Although maybe we’ll need th handle it later, when it’s implemented

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update of path-only will come in the near future, so it will be easier to change code with current approach

workspace/resource_repo.go Outdated Show resolved Hide resolved
return err
}
d.SetId(resp.RepoID())
branch := d.Get("branch").(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

technically, you can re-use the update method here, right?..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update logic is different here compared to Update method - I don't want to re-checkout branch if it's already checked out. Correct way would be if the Create API had the branch and tag parameters, but it's not implemented there - that's why two calls. On other side, I can specify branch parameter set to the default branch of repository, that's why we have branch != resp.Branch condition

@nfx nfx merged commit dfa5e81 into master Aug 13, 2021
@nfx nfx deleted the repos-support branch August 13, 2021 16:28
@nfx nfx mentioned this pull request Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants