-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Added Artifact Registry product #3360
Changes from 1 commit
24d3315
474d549
3a443e0
aeace1e
362d241
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# 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/{{region}}/repositories | ||
create_url: projects/{{project}}/locations/{{region}}/repositories?repository_id={{name}} | ||
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: ':' | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: name | ||
description: |- | ||
The name of the repository, for example: | ||
"projects/p1/locations/us-central1/repositories/repo1" | ||
ardagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: true | ||
input: true | ||
- !ruby/object:Api::Type::String | ||
name: 'region' | ||
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. We are moving to using 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. Changing region->location breaks the autogenerated iam code. I tried changing around the settings but it always gives the following error: Error: Import id "" doesn't match any of the accepted formats: [projects/(?P[^/]+)/locations/(?P[^/]+)/repositories/(?P[^/]+) (?P[^/]+)/(?P[^/]+)/(?P[^/]+) (?P[^/]+)/(?P[^/]+)] 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. You can update the IAM import format to use location as well. See https://github.com/GoogleCloudPlatform/magic-modules/blob/master/products/cloudrun/api.yaml#L241-L245 as an example. 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. Fixed, thanks! Was going in a completely wrong direction because of the empty string in the error message. Fixed that too. |
||
description: | | ||
The name of the region 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: | ||
- :FORMAT_UNSPECIFIED | ||
ardagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- :DOCKER | ||
ardagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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/{{region}}/repositories/{{name}} | ||
autogen_async: true | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
parent_resource_attribute: 'repository' | ||
method_name_separator: ':' | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "artifact_registry_repository_basic" | ||
min_version: 'beta' | ||
primary_resource_id: "my-repo" | ||
vars: | ||
repository_name: "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_name: "my-repository" | ||
description: "example docker repository with iam" | ||
ardagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
properties: | ||
region: !ruby/object:Overrides::Terraform::PropertyOverride | ||
ignore_read: true | ||
ardagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: false | ||
default_from_api: true | ||
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,7 @@ | ||
resource "google_artifact_registry_repository" "<%= ctx[:primary_resource_id] %>" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['repository_name'] %>" | ||
description = "<%= ctx[:vars]['description'] %>" | ||
format = "DOCKER" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
resource "google_artifact_registry_repository" "<%= ctx[:primary_resource_id] %>" { | ||
provider = google-beta | ||
|
||
name = "<%= ctx[:vars]['repository_name'] %>" | ||
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 | ||
|
||
repository = google_artifact_registry_repository.<%= ctx[:primary_resource_id] %>.name | ||
role = "roles/artifactregistry.reader" | ||
member = "serviceAccount:${google_service_account.test-account.email}" | ||
} |
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.
What happens when we upgrade to v1? Do we have multiple version of this, or just change this string?
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.
If there are multiple APIs we try to keep multiple
versions
specified here. That will generate terraform-provider-google-beta which will call into the beta API and terraform-provider-google which will call the v1 endpoints. In the future if fields are added to the beta API that haven't made it to v1 we can support those.