Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
feat: added support for k8s_version field (#204)
Browse files Browse the repository at this point in the history
* feat: added support for k8s_version field
docs: k8s_version field is not part of resource_options struct

Clients now generate the V1 or V1beta1 CRD based on Kubernetes server version.

PiperOrigin-RevId: 430496281

Source-Link: googleapis/googleapis@97cf70e

Source-Link: https://github.com/googleapis/googleapis-gen/commit/9e753429777968b43e5661c25ef38565b5e231bf
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWU3NTM0Mjk3Nzc5NjhiNDNlNTY2MWMyNWVmMzg1NjViNWUyMzFiZiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Clients now generate the V1 or V1beta1 CRD based on Kubernetes server version.

PiperOrigin-RevId: 430569173

Source-Link: googleapis/googleapis@3c17193

Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae784406e300bf1c56d50111338b9272fb0473b5
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU3ODQ0MDZlMzAwYmYxYzU2ZDUwMTExMzM4YjkyNzJmYjA0NzNiNSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

* feat: added support for k8s_version field
docs: k8s_version field is not part of resource_options struct
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Feb 25, 2022
1 parent dbcb8a4 commit c10f8a3
Show file tree
Hide file tree
Showing 39 changed files with 1,600 additions and 1,017 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*
* <pre>
* The GKE Hub MembershipService handles the registration of many Kubernetes
* clusters to Google Cloud, represented with the [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* clusters to Google Cloud, represented with the
* [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* GKE Hub is currently only available in the global region.
* **Membership management may be non-trivial:** it is recommended to use one
* of the Google-provided client libraries or tools where possible when working
Expand Down Expand Up @@ -476,7 +477,8 @@ public GkeHubMembershipServiceFutureStub newStub(
*
* <pre>
* The GKE Hub MembershipService handles the registration of many Kubernetes
* clusters to Google Cloud, represented with the [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* clusters to Google Cloud, represented with the
* [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* GKE Hub is currently only available in the global region.
* **Membership management may be non-trivial:** it is recommended to use one
* of the Google-provided client libraries or tools where possible when working
Expand Down Expand Up @@ -684,7 +686,8 @@ public final io.grpc.ServerServiceDefinition bindService() {
*
* <pre>
* The GKE Hub MembershipService handles the registration of many Kubernetes
* clusters to Google Cloud, represented with the [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* clusters to Google Cloud, represented with the
* [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* GKE Hub is currently only available in the global region.
* **Membership management may be non-trivial:** it is recommended to use one
* of the Google-provided client libraries or tools where possible when working
Expand Down Expand Up @@ -860,7 +863,8 @@ public void generateExclusivityManifest(
*
* <pre>
* The GKE Hub MembershipService handles the registration of many Kubernetes
* clusters to Google Cloud, represented with the [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* clusters to Google Cloud, represented with the
* [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* GKE Hub is currently only available in the global region.
* **Membership management may be non-trivial:** it is recommended to use one
* of the Google-provided client libraries or tools where possible when working
Expand Down Expand Up @@ -1009,7 +1013,8 @@ public com.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse validateExclu
*
* <pre>
* The GKE Hub MembershipService handles the registration of many Kubernetes
* clusters to Google Cloud, represented with the [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* clusters to Google Cloud, represented with the
* [Membership][google.cloud.gkehub.v1beta1.Membership] resource.
* GKE Hub is currently only available in the global region.
* **Membership management may be non-trivial:** it is recommended to use one
* of the Google-provided client libraries or tools where possible when working
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private ResourceOptions(com.google.protobuf.GeneratedMessageV3.Builder<?> builde

private ResourceOptions() {
connectVersion_ = "";
k8SVersion_ = "";
}

@java.lang.Override
Expand Down Expand Up @@ -82,6 +83,13 @@ private ResourceOptions(
v1Beta1Crd_ = input.readBool();
break;
}
case 26:
{
java.lang.String s = input.readStringRequireUtf8();

k8SVersion_ = s;
break;
}
default:
{
if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
Expand Down Expand Up @@ -190,6 +198,59 @@ public boolean getV1Beta1Crd() {
return v1Beta1Crd_;
}

public static final int K8S_VERSION_FIELD_NUMBER = 3;
private volatile java.lang.Object k8SVersion_;
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The k8sVersion.
*/
@java.lang.Override
public java.lang.String getK8SVersion() {
java.lang.Object ref = k8SVersion_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
k8SVersion_ = s;
return s;
}
}
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for k8sVersion.
*/
@java.lang.Override
public com.google.protobuf.ByteString getK8SVersionBytes() {
java.lang.Object ref = k8SVersion_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
k8SVersion_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}

private byte memoizedIsInitialized = -1;

@java.lang.Override
Expand All @@ -210,6 +271,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
if (v1Beta1Crd_ != false) {
output.writeBool(2, v1Beta1Crd_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(k8SVersion_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, k8SVersion_);
}
unknownFields.writeTo(output);
}

Expand All @@ -225,6 +289,9 @@ public int getSerializedSize() {
if (v1Beta1Crd_ != false) {
size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, v1Beta1Crd_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(k8SVersion_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, k8SVersion_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
Expand All @@ -243,6 +310,7 @@ public boolean equals(final java.lang.Object obj) {

if (!getConnectVersion().equals(other.getConnectVersion())) return false;
if (getV1Beta1Crd() != other.getV1Beta1Crd()) return false;
if (!getK8SVersion().equals(other.getK8SVersion())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
Expand All @@ -258,6 +326,8 @@ public int hashCode() {
hash = (53 * hash) + getConnectVersion().hashCode();
hash = (37 * hash) + V1BETA1_CRD_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getV1Beta1Crd());
hash = (37 * hash) + K8S_VERSION_FIELD_NUMBER;
hash = (53 * hash) + getK8SVersion().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
Expand Down Expand Up @@ -407,6 +477,8 @@ public Builder clear() {

v1Beta1Crd_ = false;

k8SVersion_ = "";

return this;
}

Expand Down Expand Up @@ -436,6 +508,7 @@ public com.google.cloud.gkehub.v1alpha2.ResourceOptions buildPartial() {
new com.google.cloud.gkehub.v1alpha2.ResourceOptions(this);
result.connectVersion_ = connectVersion_;
result.v1Beta1Crd_ = v1Beta1Crd_;
result.k8SVersion_ = k8SVersion_;
onBuilt();
return result;
}
Expand Down Expand Up @@ -493,6 +566,10 @@ public Builder mergeFrom(com.google.cloud.gkehub.v1alpha2.ResourceOptions other)
if (other.getV1Beta1Crd() != false) {
setV1Beta1Crd(other.getV1Beta1Crd());
}
if (!other.getK8SVersion().isEmpty()) {
k8SVersion_ = other.k8SVersion_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
Expand Down Expand Up @@ -699,6 +776,122 @@ public Builder clearV1Beta1Crd() {
return this;
}

private java.lang.Object k8SVersion_ = "";
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The k8sVersion.
*/
public java.lang.String getK8SVersion() {
java.lang.Object ref = k8SVersion_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
k8SVersion_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for k8sVersion.
*/
public com.google.protobuf.ByteString getK8SVersionBytes() {
java.lang.Object ref = k8SVersion_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
k8SVersion_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The k8sVersion to set.
* @return This builder for chaining.
*/
public Builder setK8SVersion(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}

k8SVersion_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearK8SVersion() {

k8SVersion_ = getDefaultInstance().getK8SVersion();
onChanged();
return this;
}
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for k8sVersion to set.
* @return This builder for chaining.
*/
public Builder setK8SVersionBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);

k8SVersion_ = value;
onChanged();
return this;
}

@java.lang.Override
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,33 @@ public interface ResourceOptionsOrBuilder
* @return The v1beta1Crd.
*/
boolean getV1Beta1Crd();

/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The k8sVersion.
*/
java.lang.String getK8SVersion();
/**
*
*
* <pre>
* Major version of the Kubernetes cluster. This is only used to determine
* which version to use for the CustomResourceDefinition resources,
* `apiextensions/v1beta1` or`apiextensions/v1`.
* </pre>
*
* <code>string k8s_version = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for k8sVersion.
*/
com.google.protobuf.ByteString getK8SVersionBytes();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Google LLC
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -305,6 +305,11 @@ message ResourceOptions {
// This option should be set for clusters with Kubernetes apiserver versions
// <1.16.
bool v1beta1_crd = 2 [(google.api.field_behavior) = OPTIONAL];

// Major version of the Kubernetes cluster. This is only used to determine
// which version to use for the CustomResourceDefinition resources,
// `apiextensions/v1beta1` or`apiextensions/v1`.
string k8s_version = 3 [(google.api.field_behavior) = OPTIONAL];
}

// GkeCluster contains information specific to GKE clusters.
Expand Down Expand Up @@ -562,7 +567,8 @@ message DeleteMembershipRequest {
message UpdateMembershipRequest {
// Required. The Membership resource name in the format
// `projects/*/locations/*/memberships/*`.
string name = 1 [(google.api.field_behavior) = REQUIRED];
string name = 1 [
(google.api.field_behavior) = REQUIRED];

// Required. Mask of fields to update.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
Expand All @@ -584,7 +590,8 @@ message UpdateMembershipRequest {
message GenerateConnectManifestRequest {
// Required. The Membership resource name the Agent will associate with, in the format
// `projects/*/locations/*/memberships/*`.
string name = 1 [(google.api.field_behavior) = REQUIRED];
string name = 1 [
(google.api.field_behavior) = REQUIRED];

// Optional. Namespace for GKE Connect agent resources. Defaults to `gke-connect`.
//
Expand Down
Loading

0 comments on commit c10f8a3

Please sign in to comment.