diff --git a/api/swagger.yml b/api/swagger.yml index 8bbd763c01f..039303747f9 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -184,6 +184,9 @@ components: description: Unix Epoch in seconds default_branch: type: string + storage_id: + type: string + description: Unique identifier of the underlying data store storage_namespace: type: string description: Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/") @@ -264,6 +267,9 @@ components: name: type: string pattern: "^[a-z0-9][a-z0-9-]{2,62}$" + storage_id: + type: string + description: Unique identifier of the underlying data store storage_namespace: type: string description: 'Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/")' diff --git a/clients/java/api/openapi.yaml b/clients/java/api/openapi.yaml index 6e89ca447db..458f93d2741 100644 --- a/clients/java/api/openapi.yaml +++ b/clients/java/api/openapi.yaml @@ -7501,6 +7501,7 @@ components: Repository: example: read_only: true + storage_id: storage_id default_branch: default_branch id: id creation_date: 0 @@ -7514,6 +7515,9 @@ components: type: integer default_branch: type: string + storage_id: + description: Unique identifier of the underlying data store + type: string storage_namespace: description: Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/") type: string @@ -7566,11 +7570,13 @@ components: results: 0 results: - read_only: true + storage_id: storage_id default_branch: default_branch id: id creation_date: 0 storage_namespace: storage_namespace - read_only: true + storage_id: storage_id default_branch: default_branch id: id creation_date: 0 @@ -7619,6 +7625,7 @@ components: example: sample_data: true read_only: true + storage_id: storage_id name: name default_branch: main storage_namespace: s3://example-bucket/ @@ -7626,6 +7633,9 @@ components: name: pattern: "^[a-z0-9][a-z0-9-]{2,62}$" type: string + storage_id: + description: Unique identifier of the underlying data store + type: string storage_namespace: description: Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/") example: s3://example-bucket/ diff --git a/clients/java/docs/Repository.md b/clients/java/docs/Repository.md index e5e9808dbf6..eb00c5451e9 100644 --- a/clients/java/docs/Repository.md +++ b/clients/java/docs/Repository.md @@ -10,6 +10,7 @@ |**id** | **String** | | | |**creationDate** | **Long** | Unix Epoch in seconds | | |**defaultBranch** | **String** | | | +|**storageId** | **String** | Unique identifier of the underlying data store | [optional] | |**storageNamespace** | **String** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | | |**readOnly** | **Boolean** | Whether the repository is a read-only repository- not relevant for bare repositories | [optional] | diff --git a/clients/java/docs/RepositoryCreation.md b/clients/java/docs/RepositoryCreation.md index c44ad50dbf7..d104df63524 100644 --- a/clients/java/docs/RepositoryCreation.md +++ b/clients/java/docs/RepositoryCreation.md @@ -8,6 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**name** | **String** | | | +|**storageId** | **String** | Unique identifier of the underlying data store | [optional] | |**storageNamespace** | **String** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | | |**defaultBranch** | **String** | | [optional] | |**sampleData** | **Boolean** | | [optional] | diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/model/Repository.java b/clients/java/src/main/java/io/lakefs/clients/sdk/model/Repository.java index 4978119e72b..82f960d76c8 100644 --- a/clients/java/src/main/java/io/lakefs/clients/sdk/model/Repository.java +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/model/Repository.java @@ -64,6 +64,10 @@ public class Repository { @SerializedName(SERIALIZED_NAME_DEFAULT_BRANCH) private String defaultBranch; + public static final String SERIALIZED_NAME_STORAGE_ID = "storage_id"; + @SerializedName(SERIALIZED_NAME_STORAGE_ID) + private String storageId; + public static final String SERIALIZED_NAME_STORAGE_NAMESPACE = "storage_namespace"; @SerializedName(SERIALIZED_NAME_STORAGE_NAMESPACE) private String storageNamespace; @@ -138,6 +142,27 @@ public void setDefaultBranch(String defaultBranch) { } + public Repository storageId(String storageId) { + + this.storageId = storageId; + return this; + } + + /** + * Unique identifier of the underlying data store + * @return storageId + **/ + @javax.annotation.Nullable + public String getStorageId() { + return storageId; + } + + + public void setStorageId(String storageId) { + this.storageId = storageId; + } + + public Repository storageNamespace(String storageNamespace) { this.storageNamespace = storageNamespace; @@ -237,6 +262,7 @@ public boolean equals(Object o) { return Objects.equals(this.id, repository.id) && Objects.equals(this.creationDate, repository.creationDate) && Objects.equals(this.defaultBranch, repository.defaultBranch) && + Objects.equals(this.storageId, repository.storageId) && Objects.equals(this.storageNamespace, repository.storageNamespace) && Objects.equals(this.readOnly, repository.readOnly)&& Objects.equals(this.additionalProperties, repository.additionalProperties); @@ -244,7 +270,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, creationDate, defaultBranch, storageNamespace, readOnly, additionalProperties); + return Objects.hash(id, creationDate, defaultBranch, storageId, storageNamespace, readOnly, additionalProperties); } @Override @@ -254,6 +280,7 @@ public String toString() { sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n"); sb.append(" defaultBranch: ").append(toIndentedString(defaultBranch)).append("\n"); + sb.append(" storageId: ").append(toIndentedString(storageId)).append("\n"); sb.append(" storageNamespace: ").append(toIndentedString(storageNamespace)).append("\n"); sb.append(" readOnly: ").append(toIndentedString(readOnly)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); @@ -282,6 +309,7 @@ private String toIndentedString(Object o) { openapiFields.add("id"); openapiFields.add("creation_date"); openapiFields.add("default_branch"); + openapiFields.add("storage_id"); openapiFields.add("storage_namespace"); openapiFields.add("read_only"); @@ -319,6 +347,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("default_branch").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `default_branch` to be a primitive type in the JSON string but got `%s`", jsonObj.get("default_branch").toString())); } + if ((jsonObj.get("storage_id") != null && !jsonObj.get("storage_id").isJsonNull()) && !jsonObj.get("storage_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `storage_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("storage_id").toString())); + } if (!jsonObj.get("storage_namespace").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `storage_namespace` to be a primitive type in the JSON string but got `%s`", jsonObj.get("storage_namespace").toString())); } diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryCreation.java b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryCreation.java index fdbf5b1e8ec..dbfa5f29e41 100644 --- a/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryCreation.java +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryCreation.java @@ -56,6 +56,10 @@ public class RepositoryCreation { @SerializedName(SERIALIZED_NAME_NAME) private String name; + public static final String SERIALIZED_NAME_STORAGE_ID = "storage_id"; + @SerializedName(SERIALIZED_NAME_STORAGE_ID) + private String storageId; + public static final String SERIALIZED_NAME_STORAGE_NAMESPACE = "storage_namespace"; @SerializedName(SERIALIZED_NAME_STORAGE_NAMESPACE) private String storageNamespace; @@ -96,6 +100,27 @@ public void setName(String name) { } + public RepositoryCreation storageId(String storageId) { + + this.storageId = storageId; + return this; + } + + /** + * Unique identifier of the underlying data store + * @return storageId + **/ + @javax.annotation.Nullable + public String getStorageId() { + return storageId; + } + + + public void setStorageId(String storageId) { + this.storageId = storageId; + } + + public RepositoryCreation storageNamespace(String storageNamespace) { this.storageNamespace = storageNamespace; @@ -235,6 +260,7 @@ public boolean equals(Object o) { } RepositoryCreation repositoryCreation = (RepositoryCreation) o; return Objects.equals(this.name, repositoryCreation.name) && + Objects.equals(this.storageId, repositoryCreation.storageId) && Objects.equals(this.storageNamespace, repositoryCreation.storageNamespace) && Objects.equals(this.defaultBranch, repositoryCreation.defaultBranch) && Objects.equals(this.sampleData, repositoryCreation.sampleData) && @@ -244,7 +270,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(name, storageNamespace, defaultBranch, sampleData, readOnly, additionalProperties); + return Objects.hash(name, storageId, storageNamespace, defaultBranch, sampleData, readOnly, additionalProperties); } @Override @@ -252,6 +278,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RepositoryCreation {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" storageId: ").append(toIndentedString(storageId)).append("\n"); sb.append(" storageNamespace: ").append(toIndentedString(storageNamespace)).append("\n"); sb.append(" defaultBranch: ").append(toIndentedString(defaultBranch)).append("\n"); sb.append(" sampleData: ").append(toIndentedString(sampleData)).append("\n"); @@ -280,6 +307,7 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("name"); + openapiFields.add("storage_id"); openapiFields.add("storage_namespace"); openapiFields.add("default_branch"); openapiFields.add("sample_data"); @@ -314,6 +342,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } + if ((jsonObj.get("storage_id") != null && !jsonObj.get("storage_id").isJsonNull()) && !jsonObj.get("storage_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `storage_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("storage_id").toString())); + } if (!jsonObj.get("storage_namespace").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `storage_namespace` to be a primitive type in the JSON string but got `%s`", jsonObj.get("storage_namespace").toString())); } diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryCreationTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryCreationTest.java index 7fc4f4a7746..40baad5ebc4 100644 --- a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryCreationTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryCreationTest.java @@ -45,6 +45,14 @@ public void nameTest() { // TODO: test name } + /** + * Test the property 'storageId' + */ + @Test + public void storageIdTest() { + // TODO: test storageId + } + /** * Test the property 'storageNamespace' */ diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryTest.java index ba349e17a31..aebd28faca0 100644 --- a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryTest.java @@ -61,6 +61,14 @@ public void defaultBranchTest() { // TODO: test defaultBranch } + /** + * Test the property 'storageId' + */ + @Test + public void storageIdTest() { + // TODO: test storageId + } + /** * Test the property 'storageNamespace' */ diff --git a/clients/python/docs/Repository.md b/clients/python/docs/Repository.md index 9a26acf43dd..34c8b4b83ff 100644 --- a/clients/python/docs/Repository.md +++ b/clients/python/docs/Repository.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **id** | **str** | | **creation_date** | **int** | Unix Epoch in seconds | **default_branch** | **str** | | +**storage_id** | **str** | Unique identifier of the underlying data store | [optional] **storage_namespace** | **str** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | **read_only** | **bool** | Whether the repository is a read-only repository- not relevant for bare repositories | [optional] diff --git a/clients/python/docs/RepositoryCreation.md b/clients/python/docs/RepositoryCreation.md index f63db7b4a2d..dca25858a08 100644 --- a/clients/python/docs/RepositoryCreation.md +++ b/clients/python/docs/RepositoryCreation.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | +**storage_id** | **str** | Unique identifier of the underlying data store | [optional] **storage_namespace** | **str** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | **default_branch** | **str** | | [optional] **sample_data** | **bool** | | [optional] [default to False] diff --git a/clients/python/lakefs_sdk/models/repository.py b/clients/python/lakefs_sdk/models/repository.py index 44bfd179541..df34e6034ca 100644 --- a/clients/python/lakefs_sdk/models/repository.py +++ b/clients/python/lakefs_sdk/models/repository.py @@ -32,9 +32,10 @@ class Repository(BaseModel): id: StrictStr = Field(...) creation_date: StrictInt = Field(..., description="Unix Epoch in seconds") default_branch: StrictStr = Field(...) + storage_id: Optional[StrictStr] = Field(None, description="Unique identifier of the underlying data store") storage_namespace: StrictStr = Field(..., description="Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\")") read_only: Optional[StrictBool] = Field(None, description="Whether the repository is a read-only repository- not relevant for bare repositories") - __properties = ["id", "creation_date", "default_branch", "storage_namespace", "read_only"] + __properties = ["id", "creation_date", "default_branch", "storage_id", "storage_namespace", "read_only"] class Config: """Pydantic configuration""" @@ -75,6 +76,7 @@ def from_dict(cls, obj: dict) -> Repository: "id": obj.get("id"), "creation_date": obj.get("creation_date"), "default_branch": obj.get("default_branch"), + "storage_id": obj.get("storage_id"), "storage_namespace": obj.get("storage_namespace"), "read_only": obj.get("read_only") }) diff --git a/clients/python/lakefs_sdk/models/repository_creation.py b/clients/python/lakefs_sdk/models/repository_creation.py index c53ace2d59b..88452c5edfe 100644 --- a/clients/python/lakefs_sdk/models/repository_creation.py +++ b/clients/python/lakefs_sdk/models/repository_creation.py @@ -30,11 +30,12 @@ class RepositoryCreation(BaseModel): RepositoryCreation """ name: constr(strict=True) = Field(...) + storage_id: Optional[StrictStr] = Field(None, description="Unique identifier of the underlying data store") storage_namespace: constr(strict=True) = Field(..., description="Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\")") default_branch: Optional[StrictStr] = None sample_data: Optional[StrictBool] = False read_only: Optional[StrictBool] = False - __properties = ["name", "storage_namespace", "default_branch", "sample_data", "read_only"] + __properties = ["name", "storage_id", "storage_namespace", "default_branch", "sample_data", "read_only"] @validator('name') def name_validate_regular_expression(cls, value): @@ -87,6 +88,7 @@ def from_dict(cls, obj: dict) -> RepositoryCreation: _obj = RepositoryCreation.parse_obj({ "name": obj.get("name"), + "storage_id": obj.get("storage_id"), "storage_namespace": obj.get("storage_namespace"), "default_branch": obj.get("default_branch"), "sample_data": obj.get("sample_data") if obj.get("sample_data") is not None else False, diff --git a/clients/python/test/test_repository.py b/clients/python/test/test_repository.py index 7ba2d7937fa..34fc696a290 100644 --- a/clients/python/test/test_repository.py +++ b/clients/python/test/test_repository.py @@ -42,6 +42,7 @@ def make_instance(self, include_optional): id = '', creation_date = 56, default_branch = '', + storage_id = '', storage_namespace = '', read_only = True ) diff --git a/clients/python/test/test_repository_creation.py b/clients/python/test/test_repository_creation.py index 731d0d188f4..4d69f26d3be 100644 --- a/clients/python/test/test_repository_creation.py +++ b/clients/python/test/test_repository_creation.py @@ -40,6 +40,7 @@ def make_instance(self, include_optional): if include_optional : return RepositoryCreation( name = 'wr1c2v7s6djuy1zmeto', + storage_id = '', storage_namespace = 's3://example-bucket/', default_branch = 'main', sample_data = True, diff --git a/clients/python/test/test_repository_list.py b/clients/python/test/test_repository_list.py index 72beb45a0b5..6667a001ae7 100644 --- a/clients/python/test/test_repository_list.py +++ b/clients/python/test/test_repository_list.py @@ -49,6 +49,7 @@ def make_instance(self, include_optional): id = '', creation_date = 56, default_branch = '', + storage_id = '', storage_namespace = '', read_only = True, ) ] @@ -65,6 +66,7 @@ def make_instance(self, include_optional): id = '', creation_date = 56, default_branch = '', + storage_id = '', storage_namespace = '', read_only = True, ) ], diff --git a/clients/rust/docs/Repository.md b/clients/rust/docs/Repository.md index 66325f4be96..8ed0507d956 100644 --- a/clients/rust/docs/Repository.md +++ b/clients/rust/docs/Repository.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **id** | **String** | | **creation_date** | **i64** | Unix Epoch in seconds | **default_branch** | **String** | | +**storage_id** | Option<**String**> | Unique identifier of the underlying data store | [optional] **storage_namespace** | **String** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | **read_only** | Option<**bool**> | Whether the repository is a read-only repository- not relevant for bare repositories | [optional] diff --git a/clients/rust/docs/RepositoryCreation.md b/clients/rust/docs/RepositoryCreation.md index e046f41463c..feed234e0ed 100644 --- a/clients/rust/docs/RepositoryCreation.md +++ b/clients/rust/docs/RepositoryCreation.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **String** | | +**storage_id** | Option<**String**> | Unique identifier of the underlying data store | [optional] **storage_namespace** | **String** | Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") | **default_branch** | Option<**String**> | | [optional] **sample_data** | Option<**bool**> | | [optional][default to false] diff --git a/clients/rust/src/models/repository.rs b/clients/rust/src/models/repository.rs index 0c1eb05c539..c1917fe1b4e 100644 --- a/clients/rust/src/models/repository.rs +++ b/clients/rust/src/models/repository.rs @@ -19,6 +19,9 @@ pub struct Repository { pub creation_date: i64, #[serde(rename = "default_branch")] pub default_branch: String, + /// Unique identifier of the underlying data store + #[serde(rename = "storage_id", skip_serializing_if = "Option::is_none")] + pub storage_id: Option, /// Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") #[serde(rename = "storage_namespace")] pub storage_namespace: String, @@ -33,6 +36,7 @@ impl Repository { id, creation_date, default_branch, + storage_id: None, storage_namespace, read_only: None, } diff --git a/clients/rust/src/models/repository_creation.rs b/clients/rust/src/models/repository_creation.rs index fe5b8286445..43a0b4c1396 100644 --- a/clients/rust/src/models/repository_creation.rs +++ b/clients/rust/src/models/repository_creation.rs @@ -14,6 +14,9 @@ use crate::models; pub struct RepositoryCreation { #[serde(rename = "name")] pub name: String, + /// Unique identifier of the underlying data store + #[serde(rename = "storage_id", skip_serializing_if = "Option::is_none")] + pub storage_id: Option, /// Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\") #[serde(rename = "storage_namespace")] pub storage_namespace: String, @@ -29,6 +32,7 @@ impl RepositoryCreation { pub fn new(name: String, storage_namespace: String) -> RepositoryCreation { RepositoryCreation { name, + storage_id: None, storage_namespace, default_branch: None, sample_data: None, diff --git a/docs/assets/js/swagger.yml b/docs/assets/js/swagger.yml index 8bbd763c01f..039303747f9 100644 --- a/docs/assets/js/swagger.yml +++ b/docs/assets/js/swagger.yml @@ -184,6 +184,9 @@ components: description: Unix Epoch in seconds default_branch: type: string + storage_id: + type: string + description: Unique identifier of the underlying data store storage_namespace: type: string description: Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/") @@ -264,6 +267,9 @@ components: name: type: string pattern: "^[a-z0-9][a-z0-9-]{2,62}$" + storage_id: + type: string + description: Unique identifier of the underlying data store storage_namespace: type: string description: 'Filesystem URI to store the underlying data in (e.g. "s3://my-bucket/some/path/")' diff --git a/pkg/api/controller.go b/pkg/api/controller.go index 1b584999770..b4e7a9867da 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -1907,6 +1907,7 @@ func (c *Controller) ListRepositories(w http.ResponseWriter, r *http.Request, pa creationDate := repo.CreationDate.Unix() r := apigen.Repository{ Id: repo.Name, + StorageId: swag.String(repo.StorageID), StorageNamespace: repo.StorageNamespace, CreationDate: creationDate, DefaultBranch: repo.DefaultBranch, @@ -1976,6 +1977,8 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo defaultBranch = "main" } + storageID := swag.StringValue(body.StorageId) + if !swag.BoolValue(body.ReadOnly) { if err := c.ensureStorageNamespace(ctx, body.StorageNamespace); err != nil { var ( @@ -2010,7 +2013,7 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo if swag.BoolValue(params.Bare) { // create a bare repository. This is useful in conjunction with refs-restore to create a copy // of another repository by e.g. copying the _lakefs/ directory and restoring its refs - repo, err := c.Catalog.CreateBareRepository(ctx, body.Name, "", body.StorageNamespace, defaultBranch, swag.BoolValue(body.ReadOnly)) + repo, err := c.Catalog.CreateBareRepository(ctx, body.Name, storageID, body.StorageNamespace, defaultBranch, swag.BoolValue(body.ReadOnly)) if c.handleAPIError(ctx, w, r, err) { return } @@ -2018,13 +2021,14 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo CreationDate: repo.CreationDate.Unix(), DefaultBranch: repo.DefaultBranch, Id: repo.Name, + StorageId: swag.String(repo.StorageID), StorageNamespace: repo.StorageNamespace, } writeResponse(w, r, http.StatusCreated, response) return } - newRepo, err := c.Catalog.CreateRepository(ctx, body.Name, "", body.StorageNamespace, defaultBranch, swag.BoolValue(body.ReadOnly)) + newRepo, err := c.Catalog.CreateRepository(ctx, body.Name, storageID, body.StorageNamespace, defaultBranch, swag.BoolValue(body.ReadOnly)) if err != nil { c.handleAPIError(ctx, w, r, fmt.Errorf("error creating repository: %w", err)) return @@ -2055,6 +2059,7 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo CreationDate: newRepo.CreationDate.Unix(), DefaultBranch: newRepo.DefaultBranch, Id: newRepo.Name, + StorageId: swag.String(newRepo.StorageID), StorageNamespace: newRepo.StorageNamespace, ReadOnly: swag.Bool(newRepo.ReadOnly), } @@ -2164,6 +2169,7 @@ func (c *Controller) GetRepository(w http.ResponseWriter, r *http.Request, repos CreationDate: repo.CreationDate.Unix(), DefaultBranch: repo.DefaultBranch, Id: repo.Name, + StorageId: swag.String(repo.StorageID), StorageNamespace: repo.StorageNamespace, ReadOnly: swag.Bool(repo.ReadOnly), } diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 5a8a085f530..c7e1302f936 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -1015,6 +1015,7 @@ func TestController_CreateRepositoryHandler(t *testing.T) { resp, err := clt.CreateRepositoryWithResponse(ctx, &apigen.CreateRepositoryParams{}, apigen.CreateRepositoryJSONRequestBody{ DefaultBranch: apiutil.Ptr("main"), Name: repoName, + StorageId: swag.String(""), StorageNamespace: onBlock(deps, "foo-bucket-1"), }) verifyResponseOK(t, resp, err) @@ -1028,6 +1029,24 @@ func TestController_CreateRepositoryHandler(t *testing.T) { } }) + t.Run("create repo no StorageId success", func(t *testing.T) { + repoName := testUniqueRepoName() + resp, err := clt.CreateRepositoryWithResponse(ctx, &apigen.CreateRepositoryParams{}, apigen.CreateRepositoryJSONRequestBody{ + DefaultBranch: apiutil.Ptr("main"), + Name: repoName, + StorageNamespace: onBlock(deps, "foo-bucket-1-1"), + }) + verifyResponseOK(t, resp, err) + + response := resp.JSON201 + if response == nil { + t.Fatal("CreateRepository got bad response") + } + if response.Id != repoName { + t.Fatalf("CreateRepository id=%s, expected=%s", response.Id, repoName) + } + }) + t.Run("create bare repo success", func(t *testing.T) { repoName := testUniqueRepoName() bareRepo := true @@ -3612,6 +3631,7 @@ func TestController_ListRepositoryRuns(t *testing.T) { resp, err := clt.CreateRepositoryWithResponse(ctx, &apigen.CreateRepositoryParams{}, apigen.CreateRepositoryJSONRequestBody{ DefaultBranch: apiutil.Ptr("main"), Name: repo, + StorageId: swag.String(""), StorageNamespace: "mem://repo9", }) verifyResponseOK(t, resp, err)