Skip to content

Commit

Permalink
[GKE Hub]: Add Fleet Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
sandmman committed Aug 18, 2023
1 parent 4904217 commit cb988be
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 1 deletion.
108 changes: 108 additions & 0 deletions mmv1/products/gkehub/Fleet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2023 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::Resource
name: 'Fleet'
base_url: "projects/{{project}}/locations/global/fleets"
create_url: "projects/{{project}}/locations/global/fleets"
update_url: "projects/{{project}}/locations/global/fleets/default"
self_link: "projects/{{project}}/locations/global/fleets/default"
update_verb: :PATCH
update_mask: true
description: |
Fleet contains information about a group of clusters.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Registering a Cluster to a Fleet':
'https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster#register_cluster'
api: 'https://cloud.google.com/anthos/multicluster-management/reference/rest/v1/projects.locations.fleets'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
kind: 'gkehub#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/errors'
message: 'message'
iam_policy: !ruby/object:Api::Resource::IamPolicy
method_name_separator: ':'
import_format:
[
'projects/{{project}}/locations/{{location}}/fleets/default',
]
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'gkehub_fleet_basic'
id_format: 'projects/{{project}}/locations/global/fleets/default'
import_format:
['projects/{{project}}/locations/global/fleets/default']
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
The unique identifier of the fleet.
- !ruby/object:Api::Type::String
name: 'displayName'
description: |
A user-assigned display name of the Fleet. When present, it must be between 4 to 30 characters.
Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point.
- !ruby/object:Api::Type::Time
name: "createTime"
description: |
The time the fleet was created, in RFC3339 text format.
output: true
- !ruby/object:Api::Type::Time
name: "updateTime"
description: |
The time the fleet was last updated, in RFC3339 text format.
output: true
- !ruby/object:Api::Type::Time
name: "deleteTime"
description: |
The time the fleet was deleted, in RFC3339 text format.
output: true
- !ruby/object:Api::Type::String
name: 'uid'
output: true
description: |
Google-generated UUID for this resource. This is unique across all
Fleet resources. If a Fleet resource is deleted and another
resource with the same name is created, it gets a different uid.
- !ruby/object:Api::Type::NestedObject
name: 'state'
description: The state of the fleet resource.
output: true
properties:
- !ruby/object:Api::Type::Enum
name: 'code'
description: Describes the state of a Fleet resource.
output: true
values:
- CODE_UNSPECIFIED
- CREATING
- READY
- DELETING
- UPDATING

2 changes: 1 addition & 1 deletion mmv1/products/gkehub/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ legacy_name: gke_hub
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://gkehub.googleapis.com/v1beta1/
base_url: https://gkehub.googleapis.com/v1beta/
- !ruby/object:Api::Product::Version
name: ga
base_url: https://gkehub.googleapis.com/v1/
Expand Down
3 changes: 3 additions & 0 deletions mmv1/templates/terraform/examples/gkehub_fleet_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "google_gkehub_fleet" "default" {
display_name = "my production fleet"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<% autogen_exception -%>
package gkehub_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
)

func TestAccGKEHubFleet_gkehubFleetBasicExample_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckGKEHubFleetDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccGKEHubFleet_basic(context),
},
{
ResourceName: "google_gke_hub_fleet.default",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGKEHubFleet_update(context),
},
{
ResourceName: "google_gke_hub_fleet.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccGKEHubFleet_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gke_hub_fleet" "default" {
display_name = "my production fleet"
}
`, context)
}

func testAccGKEHubFleet_update(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gke_hub_fleet" "default" {
display_name = "my staging fleet"
}
`, context)
}

0 comments on commit cb988be

Please sign in to comment.