Skip to content

Commit

Permalink
Added Artifact Registry product (GoogleCloudPlatform#3360)
Browse files Browse the repository at this point in the history
* Added artifact registry product

* Artifact Registry fixes

* Switched property from region -> location

Also fixed incorrect import error message

* Add artifact registry links to website

Co-authored-by: Chris Stephens <chrisst@google.com>
  • Loading branch information
2 people authored and Nathan Klish committed May 18, 2020
1 parent d3fb414 commit 3a0473a
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 2 deletions.
110 changes: 110 additions & 0 deletions products/artifactregistry/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Product
name: ArtifactRegistry
display_name: Artifact Registry
scopes:
- https://www.googleapis.com/auth/cloud-platform
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://artifactregistry.googleapis.com/v1beta1/
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Artifact Registry API
url: https://console.cloud.google.com/apis/library/artifactregistry.googleapis.com/
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
objects:
- !ruby/object:Api::Resource
name: 'Repository'
base_url: projects/{{project}}/locations/{{location}}/repositories
create_url: projects/{{project}}/locations/{{location}}/repositories?repository_id={{repository_id}}
min_version: beta
description: A repository for storing artifacts
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://cloud.google.com/artifact-registry/docs/overview'
api: 'https://cloud.google.com/artifact-registry/docs/reference/rest/'
iam_policy: !ruby/object:Api::Resource::IamPolicy
exclude: false
method_name_separator: ':'
parent_resource_attribute: 'repository'
import_format: ["projects/{{project}}/locations/{{location}}/repositories/{{repository}}", "{{repository}}"]
properties:
- !ruby/object:Api::Type::String
name: name
description: |-
The name of the repository, for example:
"projects/p1/locations/us-central1/repositories/repo1"
output: true
- !ruby/object:Api::Type::String
name: repository_id
description: |-
The last part of the repository name, for example:
"repo1"
required: true
input: true
url_param_only: true
- !ruby/object:Api::Type::String
name: 'location'
description: |
The name of the location this repository is located in.
required: true
input: true
url_param_only: true
- !ruby/object:Api::Type::Enum
name: format
description: |-
The format of packages that are stored in the repoitory.
values:
- :DOCKER
required: true
input: true
- !ruby/object:Api::Type::String
name: description
description: |-
The user-provided description of the repository.
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: |
Labels with user-defined metadata.
This field may contain up to 64 entries. Label keys and values may be no
longer than 63 characters. Label keys must begin with a lowercase letter
and may only contain lowercase letters, numeric characters, underscores,
and dashes.
- !ruby/object:Api::Type::Time
name: createTime
description: The time when the repository was created.
output: true
- !ruby/object:Api::Type::Time
name: updateTime
description: The time when the repository was last updated.
output: true
43 changes: 43 additions & 0 deletions products/artifactregistry/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2019 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Repository: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: projects/{{project}}/locations/{{location}}/repositories/{{repsitory_id}}
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "artifact_registry_repository_basic"
min_version: 'beta'
primary_resource_id: "my-repo"
vars:
repository_id: "my-repository"
description: "example docker repository"
- !ruby/object:Provider::Terraform::Examples
name: "artifact_registry_repository_iam"
min_version: 'beta'
primary_resource_id: "my-repo"
vars:
account_id: "my-account"
repository_id: "my-repository"
description: "example docker repository with iam"
properties:
location: !ruby/object:Overrides::Terraform::PropertyOverride
required: false
default_from_api: true
repository_id: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_expand: 'templates/terraform/custom_expand/shortname_to_url.go.erb'
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "google_artifact_registry_repository" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta

location = "us-central1"
repository_id = "<%= ctx[:vars]['repository_id'] %>"
description = "<%= ctx[:vars]['description'] %>"
format = "DOCKER"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "google_artifact_registry_repository" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta

location = "us-central1"
repository_id = "<%= ctx[:vars]['repository_id'] %>"
description = "<%= ctx[:vars]['description'] %>"
format = "DOCKER"
}

resource "google_service_account" "test-account" {
provider = google-beta

account_id = "<%= ctx[:vars]['account_id'] %>"
display_name = "Test Service Account"
}

resource "google_artifact_registry_repository_iam_member" "test-iam" {
provider = google-beta

location = google_artifact_registry_repository.<%= ctx[:primary_resource_id] %>.location
repository = google_artifact_registry_repository.<%= ctx[:primary_resource_id] %>.name
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.test-account.email}"
}
2 changes: 1 addition & 1 deletion third_party/terraform/utils/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func getImportIdQualifiers(idRegexes []string, d TerraformResourceData, config *
return result, nil
}
}
return nil, fmt.Errorf("Import id %q doesn't match any of the accepted formats: %v", d.Id(), idRegexes)
return nil, fmt.Errorf("Import id %q doesn't match any of the accepted formats: %v", id, idRegexes)
}

// Returns a set of default values that are contained in a regular expression
Expand Down
20 changes: 19 additions & 1 deletion third_party/terraform/website-compiled/google.erb
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,25 @@
</li>
</ul>
</li>

<% unless version == 'ga' -%>
<li>
<a href="#">Artifact Registry</a>
<ul class="nav">
<li>
<a href="/docs/providers/google/r/artifact_registry_repository.html">artifact_registry_repository</a>
</li>
<li>
<a href="/docs/providers/google/r/artifact_registry_repository_iam.html">google_artifact_registry_repository_iam_binding</a>
</li>
<li>
<a href="/docs/providers/google/r/artifact_registry_repository_iam.html">google_artifact_registry_repository_iam_member</a>
</li>
<li>
<a href="/docs/providers/google/r/artifact_registry_repository_iam.html">google_artifact_registry_repository_iam_policy</a>
</li>
</ul>
</li>
<% end -%>
<li>
<a href="#">BigQuery</a>
<ul class="nav">
Expand Down

0 comments on commit 3a0473a

Please sign in to comment.