From 3d7a4648b47f654a3bee434a09bd34d5075a6aad Mon Sep 17 00:00:00 2001 From: Jason Vigil Date: Tue, 12 Nov 2024 21:06:05 +0000 Subject: [PATCH 1/2] fix: Update WorkstationCluster reference to new format --- .../v1alpha1/cluster_reference.go | 184 ++++++++++++++++++ .../workstations/v1beta1/cluster_reference.go | 184 ++++++++++++++++++ 2 files changed, 368 insertions(+) create mode 100644 apis/workstations/v1alpha1/cluster_reference.go create mode 100644 apis/workstations/v1beta1/cluster_reference.go diff --git a/apis/workstations/v1alpha1/cluster_reference.go b/apis/workstations/v1alpha1/cluster_reference.go new file mode 100644 index 0000000000..6e88abe01b --- /dev/null +++ b/apis/workstations/v1alpha1/cluster_reference.go @@ -0,0 +1,184 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1alpha1 + +import ( + "context" + "fmt" + "strings" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &WorkstationClusterRef{} + +// WorkstationClusterRef defines the resource reference to WorkstationCluster, which "External" field +// holds the GCP identifier for the KRM object. +type WorkstationClusterRef struct { + // A reference to an externally managed WorkstationCluster resource. + // Should be in the format "projects//locations//workstationClusters/". + External string `json:"external,omitempty"` + + // The name of a WorkstationCluster resource. + Name string `json:"name,omitempty"` + + // The namespace of a WorkstationCluster resource. + Namespace string `json:"namespace,omitempty"` +} + +// NormalizedExternal provision the "External" value for other resource that depends on WorkstationCluster. +// If the "External" is given in the other resource's spec.WorkstationClusterRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual WorkstationCluster object from the cluster. +func (r *WorkstationClusterRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", WorkstationClusterGVK.Kind) + } + // From given External + if r.External != "" { + if _, _, err := parseWorkstationClusterExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(WorkstationClusterGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", WorkstationClusterGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} + +// New builds a WorkstationClusterRef from the Config Connector WorkstationCluster object. +func NewWorkstationClusterRef(ctx context.Context, reader client.Reader, obj *WorkstationCluster) (*WorkstationClusterRef, error) { + id := &WorkstationClusterRef{} + + // Get Parent + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + if err != nil { + return nil, err + } + projectID := projectRef.ProjectID + if projectID == "" { + return nil, fmt.Errorf("cannot resolve project") + } + location := obj.Spec.Location + if location == "" { + return nil, fmt.Errorf("cannot resolve location") + } + + // Get desired ID + resourceID := valueOf(obj.Spec.ResourceID) + if resourceID == "" { + resourceID = obj.GetName() + } + if resourceID == "" { + return nil, fmt.Errorf("cannot resolve resource ID") + } + + // Use approved External + externalRef := valueOf(obj.Status.ExternalRef) + if externalRef == "" { + parent := &WorkstationClusterParent{ProjectID: projectID, Location: location} + id.External = asWorkstationClusterExternal(parent, resourceID) + return id, nil + } + + // Validate desired with actual + actualParent, actualResourceID, err := parseWorkstationClusterExternal(externalRef) + if err != nil { + return nil, err + } + if actualParent.ProjectID != projectID { + return nil, fmt.Errorf("spec.projectRef changed, expect %s, got %s", actualParent.ProjectID, projectID) + } + if actualParent.Location != location { + return nil, fmt.Errorf("spec.location changed, expect %s, got %s", actualParent.Location, location) + } + if actualResourceID != resourceID { + return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s", + resourceID, actualResourceID) + } + id.External = externalRef + return id, nil +} + +func (r *WorkstationClusterRef) Parent() (*WorkstationClusterParent, error) { + if r.External != "" { + parent, _, err := parseWorkstationClusterExternal(r.External) + if err != nil { + return nil, err + } + return parent, nil + } + return nil, fmt.Errorf("WorkstationClusterRef not initialized from `NewWorkstationClusterRef` or `NormalizedExternal`") +} + +type WorkstationClusterParent struct { + ProjectID string + Location string +} + +func (p *WorkstationClusterParent) String() string { + return "projects/" + p.ProjectID + "/locations/" + p.Location +} + +func asWorkstationClusterExternal(parent *WorkstationClusterParent, resourceID string) (external string) { + return parent.String() + "/workstationConfigs/" + resourceID +} + +func parseWorkstationClusterExternal(external string) (parent *WorkstationClusterParent, resourceID string, err error) { + external = strings.TrimPrefix(external, "/") + tokens := strings.Split(external, "/") + if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "workstationClusters" { + return nil, "", fmt.Errorf("format of WorkstationCluster external=%q was not known (use projects//locations//workstationClusters/)", external) + } + parent = &WorkstationClusterParent{ + ProjectID: tokens[1], + Location: tokens[3], + } + resourceID = tokens[5] + return parent, resourceID, nil +} + +func valueOf[T any](t *T) T { + var zeroVal T + if t == nil { + return zeroVal + } + return *t +} diff --git a/apis/workstations/v1beta1/cluster_reference.go b/apis/workstations/v1beta1/cluster_reference.go new file mode 100644 index 0000000000..06c49aeaa5 --- /dev/null +++ b/apis/workstations/v1beta1/cluster_reference.go @@ -0,0 +1,184 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1beta1 + +import ( + "context" + "fmt" + "strings" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &WorkstationClusterRef{} + +// WorkstationClusterRef defines the resource reference to WorkstationCluster, which "External" field +// holds the GCP identifier for the KRM object. +type WorkstationClusterRef struct { + // A reference to an externally managed WorkstationCluster resource. + // Should be in the format "projects//locations//workstationClusters/". + External string `json:"external,omitempty"` + + // The name of a WorkstationCluster resource. + Name string `json:"name,omitempty"` + + // The namespace of a WorkstationCluster resource. + Namespace string `json:"namespace,omitempty"` +} + +// NormalizedExternal provision the "External" value for other resource that depends on WorkstationCluster. +// If the "External" is given in the other resource's spec.WorkstationClusterRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual WorkstationCluster object from the cluster. +func (r *WorkstationClusterRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", WorkstationClusterGVK.Kind) + } + // From given External + if r.External != "" { + if _, _, err := parseWorkstationClusterExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(WorkstationClusterGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", WorkstationClusterGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} + +// New builds a WorkstationClusterRef from the Config Connector WorkstationCluster object. +func NewWorkstationClusterRef(ctx context.Context, reader client.Reader, obj *WorkstationCluster) (*WorkstationClusterRef, error) { + id := &WorkstationClusterRef{} + + // Get Parent + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + if err != nil { + return nil, err + } + projectID := projectRef.ProjectID + if projectID == "" { + return nil, fmt.Errorf("cannot resolve project") + } + location := obj.Spec.Location + if location == "" { + return nil, fmt.Errorf("cannot resolve location") + } + + // Get desired ID + resourceID := valueOf(obj.Spec.ResourceID) + if resourceID == "" { + resourceID = obj.GetName() + } + if resourceID == "" { + return nil, fmt.Errorf("cannot resolve resource ID") + } + + // Use approved External + externalRef := valueOf(obj.Status.ExternalRef) + if externalRef == "" { + parent := &WorkstationClusterParent{ProjectID: projectID, Location: location} + id.External = asWorkstationClusterExternal(parent, resourceID) + return id, nil + } + + // Validate desired with actual + actualParent, actualResourceID, err := parseWorkstationClusterExternal(externalRef) + if err != nil { + return nil, err + } + if actualParent.ProjectID != projectID { + return nil, fmt.Errorf("spec.projectRef changed, expect %s, got %s", actualParent.ProjectID, projectID) + } + if actualParent.Location != location { + return nil, fmt.Errorf("spec.location changed, expect %s, got %s", actualParent.Location, location) + } + if actualResourceID != resourceID { + return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s", + resourceID, actualResourceID) + } + id.External = externalRef + return id, nil +} + +func (r *WorkstationClusterRef) Parent() (*WorkstationClusterParent, error) { + if r.External != "" { + parent, _, err := parseWorkstationClusterExternal(r.External) + if err != nil { + return nil, err + } + return parent, nil + } + return nil, fmt.Errorf("WorkstationClusterRef not initialized from `NewWorkstationClusterRef` or `NormalizedExternal`") +} + +type WorkstationClusterParent struct { + ProjectID string + Location string +} + +func (p *WorkstationClusterParent) String() string { + return "projects/" + p.ProjectID + "/locations/" + p.Location +} + +func asWorkstationClusterExternal(parent *WorkstationClusterParent, resourceID string) (external string) { + return parent.String() + "/workstationConfigs/" + resourceID +} + +func parseWorkstationClusterExternal(external string) (parent *WorkstationClusterParent, resourceID string, err error) { + external = strings.TrimPrefix(external, "/") + tokens := strings.Split(external, "/") + if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "workstationClusters" { + return nil, "", fmt.Errorf("format of WorkstationCluster external=%q was not known (use projects//locations//workstationClusters/)", external) + } + parent = &WorkstationClusterParent{ + ProjectID: tokens[1], + Location: tokens[3], + } + resourceID = tokens[5] + return parent, resourceID, nil +} + +func valueOf[T any](t *T) T { + var zeroVal T + if t == nil { + return zeroVal + } + return *t +} From 3b09d9cc3c8ba3112f43626d0b4c711d0303cd9c Mon Sep 17 00:00:00 2001 From: Jason Vigil Date: Mon, 30 Sep 2024 17:07:18 +0000 Subject: [PATCH 2/2] feat: Add types for WorkstationConfig --- apis/workstations/v1alpha1/cluster_types.go | 35 +- .../workstations/v1alpha1/config_reference.go | 193 +++++ apis/workstations/v1alpha1/config_types.go | 465 +++++++++++ apis/workstations/v1alpha1/shared_types.go | 44 ++ apis/workstations/v1alpha1/types.generated.go | 371 +++++++++ .../v1alpha1/zz_generated.deepcopy.go | 726 ++++++++++++++++-- ...ationcluster_types.go => cluster_types.go} | 35 +- apis/workstations/v1beta1/shared_types.go | 44 ++ .../v1beta1/zz_generated.deepcopy.go | 146 ++-- ...rs.workstations.cnrm.cloud.google.com.yaml | 8 +- ...gs.workstations.cnrm.cloud.google.com.yaml | 684 +++++++++++++++++ .../apis/workstations/v1alpha1/doc.go | 38 + .../apis/workstations/v1alpha1/register.go | 63 ++ .../v1alpha1/workstationconfig_types.go | 487 ++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 686 +++++++++++++++++ .../v1beta1/workstationcluster_types.go | 4 +- .../client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../typed/workstations/v1alpha1/doc.go | 23 + .../typed/workstations/v1alpha1/fake/doc.go | 23 + .../v1alpha1/fake/fake_workstationconfig.go | 144 ++++ .../v1alpha1/fake/fake_workstations_client.go | 43 ++ .../v1alpha1/generated_expansion.go | 24 + .../v1alpha1/workstationconfig.go | 198 +++++ .../v1alpha1/workstations_client.go | 110 +++ .../workstationcluster_mappings.go | 24 +- pkg/gvks/supportedgvks/gvks_generated.go | 10 + .../workstations/workstationcluster.md | 4 +- 30 files changed, 4456 insertions(+), 200 deletions(-) create mode 100644 apis/workstations/v1alpha1/config_reference.go create mode 100644 apis/workstations/v1alpha1/config_types.go create mode 100644 apis/workstations/v1alpha1/shared_types.go rename apis/workstations/v1beta1/{workstationcluster_types.go => cluster_types.go} (89%) create mode 100644 apis/workstations/v1beta1/shared_types.go create mode 100644 config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationconfigs.workstations.cnrm.cloud.google.com.yaml create mode 100644 pkg/clients/generated/apis/workstations/v1alpha1/doc.go create mode 100644 pkg/clients/generated/apis/workstations/v1alpha1/register.go create mode 100644 pkg/clients/generated/apis/workstations/v1alpha1/workstationconfig_types.go create mode 100644 pkg/clients/generated/apis/workstations/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/doc.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/doc.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstationconfig.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstations_client.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/generated_expansion.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstationconfig.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstations_client.go diff --git a/apis/workstations/v1alpha1/cluster_types.go b/apis/workstations/v1alpha1/cluster_types.go index 48e96be0b4..5666536904 100644 --- a/apis/workstations/v1alpha1/cluster_types.go +++ b/apis/workstations/v1alpha1/cluster_types.go @@ -45,13 +45,13 @@ type WorkstationClusterSpec struct { DisplayName *string `json:"displayName,omitempty"` // Optional. Client-specified annotations. - Annotations []WorkstationClusterAnnotation `json:"annotations,omitempty"` + Annotations []WorkstationAnnotation `json:"annotations,omitempty"` // Optional. // [Labels](https://cloud.google.com/workstations/docs/label-resources) that // are applied to the workstation cluster and that are also propagated to the // underlying Compute Engine resources. - Labels []WorkstationClusterLabel `json:"labels,omitempty"` + Labels []WorkstationLabel `json:"labels,omitempty"` // Immutable. Reference to the Compute Engine network in which instances associated // with this workstation cluster will be created. @@ -68,22 +68,6 @@ type WorkstationClusterSpec struct { PrivateClusterConfig *WorkstationCluster_PrivateClusterConfig `json:"privateClusterConfig,omitempty"` } -type WorkstationClusterAnnotation struct { - // Key for the annotation. - Key string `json:"key,omitempty"` - - // Value for the annotation. - Value string `json:"value,omitempty"` -} - -type WorkstationClusterLabel struct { - // Key for the annotation. - Key string `json:"key,omitempty"` - - // Value for the annotation. - Value string `json:"value,omitempty"` -} - // +kcc:proto=google.cloud.workstations.v1.WorkstationCluster.PrivateClusterConfig type WorkstationCluster_PrivateClusterConfig struct { // Immutable. Whether Workstations endpoint is private. @@ -164,20 +148,7 @@ type WorkstationClusterObservedState struct { // Output only. Status conditions describing the workstation cluster's current // state. - GCPConditions []WorkstationClusterGCPCondition `json:"gcpConditions,omitempty"` -} - -// +kcc:proto=google.rpc.Status -type WorkstationClusterGCPCondition struct { - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. - Code *int32 `json:"code,omitempty"` - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. - Message *string `json:"message,omitempty"` + GCPConditions []WorkstationServiceGCPCondition `json:"gcpConditions,omitempty"` } // +genclient diff --git a/apis/workstations/v1alpha1/config_reference.go b/apis/workstations/v1alpha1/config_reference.go new file mode 100644 index 0000000000..0f8116a632 --- /dev/null +++ b/apis/workstations/v1alpha1/config_reference.go @@ -0,0 +1,193 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1alpha1 + +import ( + "context" + "fmt" + "strings" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &WorkstationConfigRef{} + +// WorkstationConfigRef defines the resource reference to WorkstationConfig, which "External" field +// holds the GCP identifier for the KRM object. +type WorkstationConfigRef struct { + // A reference to an externally managed WorkstationConfig resource. + // Should be in the format "projects//locations//workstationClusters//workstationConfigs/". + External string `json:"external,omitempty"` + + // The name of a WorkstationConfig resource. + Name string `json:"name,omitempty"` + + // The namespace of a WorkstationConfig resource. + Namespace string `json:"namespace,omitempty"` +} + +// NormalizedExternal provision the "External" value for other resource that depends on WorkstationConfig. +// If the "External" is given in the other resource's spec.WorkstationConfigRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual WorkstationConfig object from the cluster. +func (r *WorkstationConfigRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", WorkstationConfigGVK.Kind) + } + // From given External + if r.External != "" { + if _, _, err := parseWorkstationConfigExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(WorkstationConfigGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", WorkstationConfigGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} + +// New builds a WorkstationConfigRef from the Config Connector WorkstationConfig object. +func NewWorkstationConfigRef(ctx context.Context, reader client.Reader, obj *WorkstationConfig) (*WorkstationConfigRef, error) { + id := &WorkstationConfigRef{} + + // Get Parent + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + if err != nil { + return nil, err + } + projectID := projectRef.ProjectID + if projectID == "" { + return nil, fmt.Errorf("cannot resolve project") + } + location := obj.Spec.Location + if location == "" { + return nil, fmt.Errorf("cannot resolve location") + } + clusterRef := obj.Spec.Parent + if clusterRef == nil { + return nil, fmt.Errorf("no parent cluster") + } + clusterExternal, err := clusterRef.NormalizedExternal(ctx, reader, obj.Namespace) + if err != nil { + return nil, fmt.Errorf("cannot resolve cluster: %w", err) + } + _, clusterID, err := parseWorkstationClusterExternal(clusterExternal) + if err != nil { + return nil, fmt.Errorf("cannot parse external cluster: %w", err) + } + + // Get desired ID + resourceID := valueOf(obj.Spec.ResourceID) + if resourceID == "" { + resourceID = obj.GetName() + } + if resourceID == "" { + return nil, fmt.Errorf("cannot resolve resource ID") + } + + // Use approved External + externalRef := valueOf(obj.Status.ExternalRef) + if externalRef == "" { + parent := &WorkstationConfigParent{ProjectID: projectID, Location: location, Cluster: clusterID} + id.External = asWorkstationConfigExternal(parent, resourceID) + return id, nil + } + + // Validate desired with actual + actualParent, actualResourceID, err := parseWorkstationConfigExternal(externalRef) + if err != nil { + return nil, err + } + if actualParent.ProjectID != projectID { + return nil, fmt.Errorf("spec.projectRef changed, expect %s, got %s", actualParent.ProjectID, projectID) + } + if actualParent.Location != location { + return nil, fmt.Errorf("spec.location changed, expect %s, got %s", actualParent.Location, location) + } + if actualParent.Cluster != clusterID { + return nil, fmt.Errorf("spec.parentRef changed, expect %s, got %s", actualParent.Cluster, clusterID) + } + if actualResourceID != resourceID { + return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s", + resourceID, actualResourceID) + } + id.External = externalRef + return id, nil +} + +func (r *WorkstationConfigRef) Parent() (*WorkstationConfigParent, error) { + if r.External != "" { + parent, _, err := parseWorkstationConfigExternal(r.External) + if err != nil { + return nil, err + } + return parent, nil + } + return nil, fmt.Errorf("WorkstationConfigRef not initialized from `NewWorkstationConfigRef` or `NormalizedExternal`") +} + +type WorkstationConfigParent struct { + ProjectID string + Location string + Cluster string +} + +func (p *WorkstationConfigParent) String() string { + return "projects/" + p.ProjectID + "/locations/" + p.Location + "/workstationClusters/" + p.Cluster +} + +func asWorkstationConfigExternal(parent *WorkstationConfigParent, resourceID string) (external string) { + return parent.String() + "/workstationConfigs/" + resourceID +} + +func parseWorkstationConfigExternal(external string) (parent *WorkstationConfigParent, resourceID string, err error) { + external = strings.TrimPrefix(external, "/") + tokens := strings.Split(external, "/") + if len(tokens) != 8 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "workstationClusters" || tokens[6] != "workstationConfigs" { + return nil, "", fmt.Errorf("format of WorkstationConfig external=%q was not known (use projects//locations//workstationClusters//workstationConfigs/)", external) + } + parent = &WorkstationConfigParent{ + ProjectID: tokens[1], + Location: tokens[3], + Cluster: tokens[5], + } + resourceID = tokens[7] + return parent, resourceID, nil +} diff --git a/apis/workstations/v1alpha1/config_types.go b/apis/workstations/v1alpha1/config_types.go new file mode 100644 index 0000000000..51180c9a72 --- /dev/null +++ b/apis/workstations/v1alpha1/config_types.go @@ -0,0 +1,465 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1alpha1 + +import ( + refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var WorkstationConfigGVK = GroupVersion.WithKind("WorkstationConfig") + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host +type WorkstationConfig_Host struct { + // Specifies a Compute Engine instance as the host. + GceInstance *WorkstationConfig_Host_GceInstance `json:"gceInstance,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance +type WorkstationConfig_Host_GceInstance struct { + // Optional. The type of machine to use for VM instances—for example, + // `"e2-standard-4"`. For more information about machine types that + // Cloud Workstations supports, see the list of + // [available machine + // types](https://cloud.google.com/workstations/docs/available-machine-types). + MachineType *string `json:"machineType,omitempty"` + + // Optional. A reference to the service account for Cloud + // Workstations VMs created with this configuration. When specified, be + // sure that the service account has `logginglogEntries.create` permission + // on the project so it can write logs out to Cloud Logging. If using a + // custom container image, the service account must have permissions to + // pull the specified image. + // + // If you as the administrator want to be able to `ssh` into the + // underlying VM, you need to set this value to a service account + // for which you have the `iam.serviceAccounts.actAs` permission. + // Conversely, if you don't want anyone to be able to `ssh` into the + // underlying VM, use a service account where no one has that + // permission. + // + // If not set, VMs run with a service account provided by the + // Cloud Workstations service, and the image must be publicly + // accessible. + ServiceAccountRef *refs.IAMServiceAccountRef `json:"serviceAccountRef,omitempty"` + + // Optional. Scopes to grant to the + // [service_account][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.service_account]. + // Various scopes are automatically added based on feature usage. When + // specified, users of workstations under this configuration must have + // `iam.serviceAccounts.actAs` on the service account. + ServiceAccountScopes []string `json:"serviceAccountScopes,omitempty"` + + // Optional. Network tags to add to the Compute Engine VMs backing the + // workstations. This option applies + // [network + // tags](https://cloud.google.com/vpc/docs/add-remove-network-tags) to VMs + // created with this configuration. These network tags enable the creation + // of [firewall + // rules](https://cloud.google.com/workstations/docs/configure-firewall-rules). + Tags []string `json:"tags,omitempty"` + + // Optional. The number of VMs that the system should keep idle so that + // new workstations can be started quickly for new users. Defaults to `0` + // in the API. + PoolSize *int32 `json:"poolSize,omitempty"` + + // Optional. When set to true, disables public IP addresses for VMs. If + // you disable public IP addresses, you must set up Private Google Access + // or Cloud NAT on your network. If you use Private Google Access and you + // use `private.googleapis.com` or `restricted.googleapis.com` for + // Container Registry and Artifact Registry, make sure that you set + // up DNS records for domains `*.gcr.io` and `*.pkg.dev`. + // Defaults to false (VMs have public IP addresses). + DisablePublicIPAddresses *bool `json:"disablePublicIPAddresses,omitempty"` + + // Optional. Whether to enable nested virtualization on Cloud Workstations + // VMs created under this workstation configuration. + // + // Nested virtualization lets you run virtual machine (VM) instances + // inside your workstation. Before enabling nested virtualization, + // consider the following important considerations. Cloud Workstations + // instances are subject to the [same restrictions as Compute Engine + // instances](https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions): + // + // * **Organization policy**: projects, folders, or + // organizations may be restricted from creating nested VMs if the + // **Disable VM nested virtualization** constraint is enforced in + // the organization policy. For more information, see the + // Compute Engine section, + // [Checking whether nested virtualization is + // allowed](https://cloud.google.com/compute/docs/instances/nested-virtualization/managing-constraint#checking_whether_nested_virtualization_is_allowed). + // * **Performance**: nested VMs might experience a 10% or greater + // decrease in performance for workloads that are CPU-bound and + // possibly greater than a 10% decrease for workloads that are + // input/output bound. + // * **Machine Type**: nested virtualization can only be enabled on + // workstation configurations that specify a + // [machine_type][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.machine_type] + // in the N1 or N2 machine series. + // * **GPUs**: nested virtualization may not be enabled on workstation + // configurations with accelerators. + // * **Operating System**: Because + // [Container-Optimized + // OS](https://cloud.google.com/compute/docs/images/os-details#container-optimized_os_cos) + // does not support nested virtualization, when nested virtualization is + // enabled, the underlying Compute Engine VM instances boot from an + // [Ubuntu + // LTS](https://cloud.google.com/compute/docs/images/os-details#ubuntu_lts) + // image. + EnableNestedVirtualization *bool `json:"enableNestedVirtualization,omitempty"` + + // Optional. A set of Compute Engine Shielded instance options. + ShieldedInstanceConfig *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig `json:"shieldedInstanceConfig,omitempty"` + + // Optional. A set of Compute Engine Confidential VM instance options. + ConfidentialInstanceConfig *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig `json:"confidentialInstanceConfig,omitempty"` + + // Optional. The size of the boot disk for the VM in gigabytes (GB). + // The minimum boot disk size is `30` GB. Defaults to `50` GB. + BootDiskSizeGB *int32 `json:"bootDiskSizeGB,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.GceShieldedInstanceConfig +type WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig struct { + // Optional. Whether the instance has Secure Boot enabled. + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + + // Optional. Whether the instance has the vTPM enabled. + EnableVTPM *bool `json:"enableVTPM,omitempty"` + + // Optional. Whether the instance has integrity monitoring enabled. + EnableIntegrityMonitoring *bool `json:"enableIntegrityMonitoring,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.GceConfidentialInstanceConfig +type WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig struct { + // Optional. Whether the instance has confidential compute enabled. + EnableConfidentialCompute *bool `json:"enableConfidentialCompute,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory +type WorkstationConfig_PersistentDirectory struct { + // A PersistentDirectory backed by a Compute Engine persistent disk. + GcePD *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk `json:"gcePD,omitempty"` + + // Optional. Location of this directory in the running workstation. + MountPath *string `json:"mountPath,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk +type WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk struct { + // Optional. The GB capacity of a persistent home directory for each + // workstation created with this configuration. Must be empty if + // [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + // is set. + // + // Valid values are `10`, `50`, `100`, `200`, `500`, or `1000`. + // Defaults to `200`. If less than `200` GB, the + // [disk_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.disk_type] + // must be + // `"pd-balanced"` or `"pd-ssd"`. + SizeGB *int32 `json:"sizeGB,omitempty"` + + // Optional. Type of file system that the disk should be formatted with. + // The workstation image must support this file system type. Must be empty + // if + // [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + // is set. Defaults to `"ext4"`. + FSType *string `json:"fsType,omitempty"` + + // Optional. The [type of the persistent + // disk](https://cloud.google.com/compute/docs/disks#disk-types) for the + // home directory. Defaults to `"pd-standard"`. + DiskType *string `json:"diskType,omitempty"` + + // Optional. Name of the snapshot to use as the source for the disk. If + // set, + // [size_gb][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.size_gb] + // and + // [fs_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.fs_type] + // must be empty. + SourceSnapshot *string `json:"sourceSnapshot,omitempty"` + + // Optional. Whether the persistent disk should be deleted when the + // workstation is deleted. Valid values are `DELETE` and `RETAIN`. + // Defaults to `DELETE`. + ReclaimPolicy *string `json:"reclaimPolicy,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Container +type WorkstationConfig_Container struct { + // Optional. A Docker container image that defines a custom environment. + // + // Cloud Workstations provides a number of + // [preconfigured + // images](https://cloud.google.com/workstations/docs/preconfigured-base-images), + // but you can create your own + // [custom container + // images](https://cloud.google.com/workstations/docs/custom-container-images). + // If using a private image, the `host.gceInstance.serviceAccount` field + // must be specified in the workstation configuration and must have + // permission to pull the specified image. Otherwise, the image must be + // publicly accessible. + Image *string `json:"image,omitempty"` + + // Optional. If set, overrides the default ENTRYPOINT specified by the + // image. + Command []string `json:"command,omitempty"` + + // Optional. Arguments passed to the entrypoint. + Args []string `json:"args,omitempty"` + + // Optional. Environment variables passed to the container's entrypoint. + Env []WorkstationConfig_Container_EnvVar `json:"env,omitempty"` + + // Optional. If set, overrides the default DIR specified by the image. + WorkingDir *string `json:"workingDir,omitempty"` + + // Optional. If set, overrides the USER specified in the image with the + // given uid. + RunAsUser *int32 `json:"runAsUser,omitempty"` +} + +type WorkstationConfig_Container_EnvVar struct { + // Name is the name of the environment variable. + Name string `json:"name,omitempty"` + + // Value is the value of the environment variable. + Value string `json:"value,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.CustomerEncryptionKey +type WorkstationConfig_CustomerEncryptionKey struct { + // Immutable. A reference to the Google Cloud KMS encryption key. For example, + // `"projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"`. + // The key must be in the same region as the workstation configuration. + KmsCryptoKeyRef *refs.KMSCryptoKeyRef `json:"kmsCryptoKeyRef,omitempty"` + + // Immutable. A reference to a service account to use with the specified + // KMS key. We recommend that you use a separate service account + // and follow KMS best practices. For more information, see + // [Separation of + // duties](https://cloud.google.com/kms/docs/separation-of-duties) and + // `gcloud kms keys add-iam-policy-binding` + // [`--member`](https://cloud.google.com/sdk/gcloud/reference/kms/keys/add-iam-policy-binding#--member). + ServiceAccountRef *refs.IAMServiceAccountRef `json:"serviceAccountRef,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.ReadinessCheck +type WorkstationConfig_ReadinessCheck struct { + // Optional. Path to which the request should be sent. + Path *string `json:"path,omitempty"` + + // Optional. Port to which the request should be sent. + Port *int32 `json:"port,omitempty"` +} + +// WorkstationConfigSpec defines the desired state of WorkstationConfig +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig +type WorkstationConfigSpec struct { + // Immutable. The Project that this resource belongs to. + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" + ProjectRef *refs.ProjectRef `json:"projectRef"` + + // The location of the WorkstationConfig. + Location string `json:"location,omitempty"` + + // Parent is a reference to the parent WorkstationCluster for this WorkstationConfig. + Parent *WorkstationClusterRef `json:"parentRef"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" + // Immutable. + // The WorkstationConfig name. If not given, the metadata.name will be used. + ResourceID *string `json:"resourceID,omitempty"` + + // Optional. Human-readable name for this workstation configuration. + DisplayName *string `json:"displayName,omitempty"` + + // Optional. Client-specified annotations. + Annotations []WorkstationAnnotation `json:"annotations,omitempty"` + + // Optional. + // [Labels](https://cloud.google.com/workstations/docs/label-resources) that + // are applied to the workstation configuration and that are also propagated + // to the underlying Compute Engine resources. + Labels []WorkstationLabel `json:"labels,omitempty"` + + // Optional. Number of seconds to wait before automatically stopping a + // workstation after it last received user traffic. + // + // A value of `"0s"` indicates that Cloud Workstations VMs created with this + // configuration should never time out due to idleness. + // Provide + // [duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration) + // terminated by `s` for seconds—for example, `"7200s"` (2 hours). + // The default is `"1200s"` (20 minutes). + IdleTimeout *string `json:"idleTimeout,omitempty"` + + // Optional. Number of seconds that a workstation can run until it is + // automatically shut down. We recommend that workstations be shut down daily + // to reduce costs and so that security updates can be applied upon restart. + // The + // [idle_timeout][google.cloud.workstations.v1.WorkstationConfig.idle_timeout] + // and + // [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + // fields are independent of each other. Note that the + // [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + // field shuts down VMs after the specified time, regardless of whether or not + // the VMs are idle. + // + // Provide duration terminated by `s` for seconds—for example, `"54000s"` + // (15 hours). Defaults to `"43200s"` (12 hours). A value of `"0s"` indicates + // that workstations using this configuration should never time out. If + // [encryption_key][google.cloud.workstations.v1.WorkstationConfig.encryption_key] + // is set, it must be greater than `"0s"` and less than + // `"86400s"` (24 hours). + // + // Warning: A value of `"0s"` indicates that Cloud Workstations VMs created + // with this configuration have no maximum running time. This is strongly + // discouraged because you incur costs and will not pick up security updates. + RunningTimeout *string `json:"runningTimeout,omitempty"` + + // Optional. Runtime host for the workstation. + Host *WorkstationConfig_Host `json:"host,omitempty"` + + // Optional. Directories to persist across workstation sessions. + PersistentDirectories []WorkstationConfig_PersistentDirectory `json:"persistentDirectories,omitempty"` + + // Optional. Container that runs upon startup for each workstation using this + // workstation configuration. + Container *WorkstationConfig_Container `json:"container,omitempty"` + + // Immutable. Encrypts resources of this workstation configuration using a + // customer-managed encryption key (CMEK). + // + // If specified, the boot disk of the Compute Engine instance and the + // persistent disk are encrypted using this encryption key. If + // this field is not set, the disks are encrypted using a generated + // key. Customer-managed encryption keys do not protect disk metadata. + // + // If the customer-managed encryption key is rotated, when the workstation + // instance is stopped, the system attempts to recreate the + // persistent disk with the new version of the key. Be sure to keep + // older versions of the key until the persistent disk is recreated. + // Otherwise, data on the persistent disk might be lost. + // + // If the encryption key is revoked, the workstation session automatically + // stops within 7 hours. + // + // Immutable after the workstation configuration is created. + EncryptionKey *WorkstationConfig_CustomerEncryptionKey `json:"encryptionKey,omitempty"` + + // Optional. Readiness checks to perform when starting a workstation using + // this workstation configuration. Mark a workstation as running only after + // all specified readiness checks return 200 status codes. + ReadinessChecks []WorkstationConfig_ReadinessCheck `json:"readinessChecks,omitempty"` + + // Optional. Immutable. Specifies the zones used to replicate the VM and disk + // resources within the region. If set, exactly two zones within the + // workstation cluster's region must be specified—for example, + // `['us-central1-a', 'us-central1-f']`. If this field is empty, two default + // zones within the region are used. + // + // Immutable after the workstation configuration is created. + ReplicaZones []string `json:"replicaZones,omitempty"` +} + +// WorkstationConfigStatus defines the config connector machine state of WorkstationConfig +type WorkstationConfigStatus struct { + /* Conditions represent the latest available observations of the + object's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + + // ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + + // A unique specifier for the WorkstationConfig resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + // ObservedState is the state of the resource as most recently observed in GCP. + ObservedState *WorkstationConfigObservedState `json:"observedState,omitempty"` +} + +// WorkstationConfigObservedState is the state of the WorkstationConfig resource as most recently observed in GCP. +type WorkstationConfigObservedState struct { + // Output only. A system-assigned unique identifier for this workstation + // configuration. + UID *string `json:"uid,omitempty"` + + // Output only. Time when this workstation configuration was created. + CreateTime *string `json:"createTime,omitempty"` + + // Output only. Time when this workstation configuration was most recently + // updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // Output only. Time when this workstation configuration was soft-deleted. + DeleteTime *string `json:"deleteTime,omitempty"` + + // Optional. Checksum computed by the server. May be sent on update and delete + // requests to make sure that the client has an up-to-date value before + // proceeding. + Etag *string `json:"etag,omitempty"` + + // Output only. Whether this resource is degraded, in which case it may + // require user action to restore full functionality. See also the + // [conditions][google.cloud.workstations.v1.WorkstationConfig.conditions] + // field. + Degraded *bool `json:"degraded,omitempty"` + + // Output only. Status conditions describing the current resource state. + GCPConditions []WorkstationServiceGCPCondition `json:"gcpConditions,omitempty"` + + // Output only. Number of instances currently available in the pool for + // faster workstation startup. + PooledInstances *int32 `json:"pooledInstances,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpworkstationconfig;gcpworkstationconfigs +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true" +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" + +// WorkstationConfig is the Schema for the WorkstationConfig API +// +k8s:openapi-gen=true +type WorkstationConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec WorkstationConfigSpec `json:"spec,omitempty"` + Status WorkstationConfigStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// WorkstationConfigList contains a list of WorkstationConfig +type WorkstationConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []WorkstationConfig `json:"items"` +} + +func init() { + SchemeBuilder.Register(&WorkstationConfig{}, &WorkstationConfigList{}) +} diff --git a/apis/workstations/v1alpha1/shared_types.go b/apis/workstations/v1alpha1/shared_types.go new file mode 100644 index 0000000000..41cfe3d16d --- /dev/null +++ b/apis/workstations/v1alpha1/shared_types.go @@ -0,0 +1,44 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1alpha1 + +type WorkstationAnnotation struct { + // Key for the annotation. + Key string `json:"key,omitempty"` + + // Value for the annotation. + Value string `json:"value,omitempty"` +} + +type WorkstationLabel struct { + // Key for the label. + Key string `json:"key,omitempty"` + + // Value for the label. + Value string `json:"value,omitempty"` +} + +// +kcc:proto=google.rpc.Status +type WorkstationServiceGCPCondition struct { + // The status code, which should be an enum value of + // [google.rpc.Code][google.rpc.Code]. + Code *int32 `json:"code,omitempty"` + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized + // by the client. + Message *string `json:"message,omitempty"` +} diff --git a/apis/workstations/v1alpha1/types.generated.go b/apis/workstations/v1alpha1/types.generated.go index d018ae0c58..e5add0428f 100644 --- a/apis/workstations/v1alpha1/types.generated.go +++ b/apis/workstations/v1alpha1/types.generated.go @@ -108,6 +108,377 @@ type WorkstationCluster_PrivateClusterConfig struct { AllowedProjects []string `json:"allowedProjects,omitempty"` } +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig +type WorkstationConfig struct { + // Full name of this workstation configuration. + Name *string `json:"name,omitempty"` + + // Optional. Human-readable name for this workstation configuration. + DisplayName *string `json:"displayName,omitempty"` + + // Output only. A system-assigned unique identifier for this workstation + // configuration. + Uid *string `json:"uid,omitempty"` + + // Output only. Indicates whether this workstation configuration is currently + // being updated to match its intended state. + Reconciling *bool `json:"reconciling,omitempty"` + + // Optional. Client-specified annotations. + Annotations map[string]string `json:"annotations,omitempty"` + + // Optional. + // [Labels](https://cloud.google.com/workstations/docs/label-resources) that + // are applied to the workstation configuration and that are also propagated + // to the underlying Compute Engine resources. + Labels map[string]string `json:"labels,omitempty"` + + // Output only. Time when this workstation configuration was created. + CreateTime *string `json:"createTime,omitempty"` + + // Output only. Time when this workstation configuration was most recently + // updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // Output only. Time when this workstation configuration was soft-deleted. + DeleteTime *string `json:"deleteTime,omitempty"` + + // Optional. Checksum computed by the server. May be sent on update and delete + // requests to make sure that the client has an up-to-date value before + // proceeding. + Etag *string `json:"etag,omitempty"` + + // Optional. Number of seconds to wait before automatically stopping a + // workstation after it last received user traffic. + // + // A value of `"0s"` indicates that Cloud Workstations VMs created with this + // configuration should never time out due to idleness. + // Provide + // [duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration) + // terminated by `s` for seconds—for example, `"7200s"` (2 hours). + // The default is `"1200s"` (20 minutes). + IdleTimeout *string `json:"idleTimeout,omitempty"` + + // Optional. Number of seconds that a workstation can run until it is + // automatically shut down. We recommend that workstations be shut down daily + // to reduce costs and so that security updates can be applied upon restart. + // The + // [idle_timeout][google.cloud.workstations.v1.WorkstationConfig.idle_timeout] + // and + // [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + // fields are independent of each other. Note that the + // [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + // field shuts down VMs after the specified time, regardless of whether or not + // the VMs are idle. + // + // Provide duration terminated by `s` for seconds—for example, `"54000s"` + // (15 hours). Defaults to `"43200s"` (12 hours). A value of `"0s"` indicates + // that workstations using this configuration should never time out. If + // [encryption_key][google.cloud.workstations.v1.WorkstationConfig.encryption_key] + // is set, it must be greater than `"0s"` and less than + // `"86400s"` (24 hours). + // + // Warning: A value of `"0s"` indicates that Cloud Workstations VMs created + // with this configuration have no maximum running time. This is strongly + // discouraged because you incur costs and will not pick up security updates. + RunningTimeout *string `json:"runningTimeout,omitempty"` + + // Optional. Runtime host for the workstation. + Host *WorkstationConfig_Host `json:"host,omitempty"` + + // Optional. Directories to persist across workstation sessions. + PersistentDirectories []WorkstationConfig_PersistentDirectory `json:"persistentDirectories,omitempty"` + + // Optional. Container that runs upon startup for each workstation using this + // workstation configuration. + Container *WorkstationConfig_Container `json:"container,omitempty"` + + // Immutable. Encrypts resources of this workstation configuration using a + // customer-managed encryption key (CMEK). + // + // If specified, the boot disk of the Compute Engine instance and the + // persistent disk are encrypted using this encryption key. If + // this field is not set, the disks are encrypted using a generated + // key. Customer-managed encryption keys do not protect disk metadata. + // + // If the customer-managed encryption key is rotated, when the workstation + // instance is stopped, the system attempts to recreate the + // persistent disk with the new version of the key. Be sure to keep + // older versions of the key until the persistent disk is recreated. + // Otherwise, data on the persistent disk might be lost. + // + // If the encryption key is revoked, the workstation session automatically + // stops within 7 hours. + // + // Immutable after the workstation configuration is created. + EncryptionKey *WorkstationConfig_CustomerEncryptionKey `json:"encryptionKey,omitempty"` + + // Optional. Readiness checks to perform when starting a workstation using + // this workstation configuration. Mark a workstation as running only after + // all specified readiness checks return 200 status codes. + ReadinessChecks []WorkstationConfig_ReadinessCheck `json:"readinessChecks,omitempty"` + + // Optional. Immutable. Specifies the zones used to replicate the VM and disk + // resources within the region. If set, exactly two zones within the + // workstation cluster's region must be specified—for example, + // `['us-central1-a', 'us-central1-f']`. If this field is empty, two default + // zones within the region are used. + // + // Immutable after the workstation configuration is created. + ReplicaZones []string `json:"replicaZones,omitempty"` + + // Output only. Whether this resource is degraded, in which case it may + // require user action to restore full functionality. See also the + // [conditions][google.cloud.workstations.v1.WorkstationConfig.conditions] + // field. + Degraded *bool `json:"degraded,omitempty"` + + // Output only. Status conditions describing the current resource state. + Conditions []Status `json:"conditions,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Container +type WorkstationConfig_Container struct { + // Optional. A Docker container image that defines a custom environment. + // + // Cloud Workstations provides a number of + // [preconfigured + // images](https://cloud.google.com/workstations/docs/preconfigured-base-images), + // but you can create your own + // [custom container + // images](https://cloud.google.com/workstations/docs/custom-container-images). + // If using a private image, the `host.gceInstance.serviceAccount` field + // must be specified in the workstation configuration and must have + // permission to pull the specified image. Otherwise, the image must be + // publicly accessible. + Image *string `json:"image,omitempty"` + + // Optional. If set, overrides the default ENTRYPOINT specified by the + // image. + Command []string `json:"command,omitempty"` + + // Optional. Arguments passed to the entrypoint. + Args []string `json:"args,omitempty"` + + // Optional. Environment variables passed to the container's entrypoint. + Env map[string]string `json:"env,omitempty"` + + // Optional. If set, overrides the default DIR specified by the image. + WorkingDir *string `json:"workingDir,omitempty"` + + // Optional. If set, overrides the USER specified in the image with the + // given uid. + RunAsUser *int32 `json:"runAsUser,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.CustomerEncryptionKey +type WorkstationConfig_CustomerEncryptionKey struct { + // Immutable. The name of the Google Cloud KMS encryption key. For example, + // `"projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"`. + // The key must be in the same region as the workstation configuration. + KmsKey *string `json:"kmsKey,omitempty"` + + // Immutable. The service account to use with the specified + // KMS key. We recommend that you use a separate service account + // and follow KMS best practices. For more information, see + // [Separation of + // duties](https://cloud.google.com/kms/docs/separation-of-duties) and + // `gcloud kms keys add-iam-policy-binding` + // [`--member`](https://cloud.google.com/sdk/gcloud/reference/kms/keys/add-iam-policy-binding#--member). + KmsKeyServiceAccount *string `json:"kmsKeyServiceAccount,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host +type WorkstationConfig_Host struct { + // Specifies a Compute Engine instance as the host. + GceInstance *WorkstationConfig_Host_GceInstance `json:"gceInstance,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance +type WorkstationConfig_Host_GceInstance struct { + // Optional. The type of machine to use for VM instances—for example, + // `"e2-standard-4"`. For more information about machine types that + // Cloud Workstations supports, see the list of + // [available machine + // types](https://cloud.google.com/workstations/docs/available-machine-types). + MachineType *string `json:"machineType,omitempty"` + + // Optional. The email address of the service account for Cloud + // Workstations VMs created with this configuration. When specified, be + // sure that the service account has `logginglogEntries.create` permission + // on the project so it can write logs out to Cloud Logging. If using a + // custom container image, the service account must have permissions to + // pull the specified image. + // + // If you as the administrator want to be able to `ssh` into the + // underlying VM, you need to set this value to a service account + // for which you have the `iam.serviceAccounts.actAs` permission. + // Conversely, if you don't want anyone to be able to `ssh` into the + // underlying VM, use a service account where no one has that + // permission. + // + // If not set, VMs run with a service account provided by the + // Cloud Workstations service, and the image must be publicly + // accessible. + ServiceAccount *string `json:"serviceAccount,omitempty"` + + // Optional. Scopes to grant to the + // [service_account][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.service_account]. + // Various scopes are automatically added based on feature usage. When + // specified, users of workstations under this configuration must have + // `iam.serviceAccounts.actAs` on the service account. + ServiceAccountScopes []string `json:"serviceAccountScopes,omitempty"` + + // Optional. Network tags to add to the Compute Engine VMs backing the + // workstations. This option applies + // [network + // tags](https://cloud.google.com/vpc/docs/add-remove-network-tags) to VMs + // created with this configuration. These network tags enable the creation + // of [firewall + // rules](https://cloud.google.com/workstations/docs/configure-firewall-rules). + Tags []string `json:"tags,omitempty"` + + // Optional. The number of VMs that the system should keep idle so that + // new workstations can be started quickly for new users. Defaults to `0` + // in the API. + PoolSize *int32 `json:"poolSize,omitempty"` + + // Output only. Number of instances currently available in the pool for + // faster workstation startup. + PooledInstances *int32 `json:"pooledInstances,omitempty"` + + // Optional. When set to true, disables public IP addresses for VMs. If + // you disable public IP addresses, you must set up Private Google Access + // or Cloud NAT on your network. If you use Private Google Access and you + // use `private.googleapis.com` or `restricted.googleapis.com` for + // Container Registry and Artifact Registry, make sure that you set + // up DNS records for domains `*.gcr.io` and `*.pkg.dev`. + // Defaults to false (VMs have public IP addresses). + DisablePublicIpAddresses *bool `json:"disablePublicIpAddresses,omitempty"` + + // Optional. Whether to enable nested virtualization on Cloud Workstations + // VMs created under this workstation configuration. + // + // Nested virtualization lets you run virtual machine (VM) instances + // inside your workstation. Before enabling nested virtualization, + // consider the following important considerations. Cloud Workstations + // instances are subject to the [same restrictions as Compute Engine + // instances](https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions): + // + // * **Organization policy**: projects, folders, or + // organizations may be restricted from creating nested VMs if the + // **Disable VM nested virtualization** constraint is enforced in + // the organization policy. For more information, see the + // Compute Engine section, + // [Checking whether nested virtualization is + // allowed](https://cloud.google.com/compute/docs/instances/nested-virtualization/managing-constraint#checking_whether_nested_virtualization_is_allowed). + // * **Performance**: nested VMs might experience a 10% or greater + // decrease in performance for workloads that are CPU-bound and + // possibly greater than a 10% decrease for workloads that are + // input/output bound. + // * **Machine Type**: nested virtualization can only be enabled on + // workstation configurations that specify a + // [machine_type][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.machine_type] + // in the N1 or N2 machine series. + // * **GPUs**: nested virtualization may not be enabled on workstation + // configurations with accelerators. + // * **Operating System**: Because + // [Container-Optimized + // OS](https://cloud.google.com/compute/docs/images/os-details#container-optimized_os_cos) + // does not support nested virtualization, when nested virtualization is + // enabled, the underlying Compute Engine VM instances boot from an + // [Ubuntu + // LTS](https://cloud.google.com/compute/docs/images/os-details#ubuntu_lts) + // image. + EnableNestedVirtualization *bool `json:"enableNestedVirtualization,omitempty"` + + // Optional. A set of Compute Engine Shielded instance options. + ShieldedInstanceConfig *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig `json:"shieldedInstanceConfig,omitempty"` + + // Optional. A set of Compute Engine Confidential VM instance options. + ConfidentialInstanceConfig *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig `json:"confidentialInstanceConfig,omitempty"` + + // Optional. The size of the boot disk for the VM in gigabytes (GB). + // The minimum boot disk size is `30` GB. Defaults to `50` GB. + BootDiskSizeGb *int32 `json:"bootDiskSizeGb,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.GceConfidentialInstanceConfig +type WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig struct { + // Optional. Whether the instance has confidential compute enabled. + EnableConfidentialCompute *bool `json:"enableConfidentialCompute,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.GceShieldedInstanceConfig +type WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig struct { + // Optional. Whether the instance has Secure Boot enabled. + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + + // Optional. Whether the instance has the vTPM enabled. + EnableVtpm *bool `json:"enableVtpm,omitempty"` + + // Optional. Whether the instance has integrity monitoring enabled. + EnableIntegrityMonitoring *bool `json:"enableIntegrityMonitoring,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory +type WorkstationConfig_PersistentDirectory struct { + // A PersistentDirectory backed by a Compute Engine persistent disk. + GcePd *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk `json:"gcePd,omitempty"` + + // Optional. Location of this directory in the running workstation. + MountPath *string `json:"mountPath,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk +type WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk struct { + // Optional. The GB capacity of a persistent home directory for each + // workstation created with this configuration. Must be empty if + // [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + // is set. + // + // Valid values are `10`, `50`, `100`, `200`, `500`, or `1000`. + // Defaults to `200`. If less than `200` GB, the + // [disk_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.disk_type] + // must be + // `"pd-balanced"` or `"pd-ssd"`. + SizeGb *int32 `json:"sizeGb,omitempty"` + + // Optional. Type of file system that the disk should be formatted with. + // The workstation image must support this file system type. Must be empty + // if + // [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + // is set. Defaults to `"ext4"`. + FsType *string `json:"fsType,omitempty"` + + // Optional. The [type of the persistent + // disk](https://cloud.google.com/compute/docs/disks#disk-types) for the + // home directory. Defaults to `"pd-standard"`. + DiskType *string `json:"diskType,omitempty"` + + // Optional. Name of the snapshot to use as the source for the disk. If + // set, + // [size_gb][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.size_gb] + // and + // [fs_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.fs_type] + // must be empty. + SourceSnapshot *string `json:"sourceSnapshot,omitempty"` + + // Optional. Whether the persistent disk should be deleted when the + // workstation is deleted. Valid values are `DELETE` and `RETAIN`. + // Defaults to `DELETE`. + ReclaimPolicy *string `json:"reclaimPolicy,omitempty"` +} + +// +kcc:proto=google.cloud.workstations.v1.WorkstationConfig.ReadinessCheck +type WorkstationConfig_ReadinessCheck struct { + // Optional. Path to which the request should be sent. + Path *string `json:"path,omitempty"` + + // Optional. Port to which the request should be sent. + Port *int32 `json:"port,omitempty"` +} + // +kcc:proto=google.protobuf.Any type Any struct { // A URL/resource name that uniquely identifies the type of the serialized diff --git a/apis/workstations/v1alpha1/zz_generated.deepcopy.go b/apis/workstations/v1alpha1/zz_generated.deepcopy.go index abbd1a4f43..1256825573 100644 --- a/apis/workstations/v1alpha1/zz_generated.deepcopy.go +++ b/apis/workstations/v1alpha1/zz_generated.deepcopy.go @@ -24,6 +24,21 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationAnnotation) DeepCopyInto(out *WorkstationAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationAnnotation. +func (in *WorkstationAnnotation) DeepCopy() *WorkstationAnnotation { + if in == nil { + return nil + } + out := new(WorkstationAnnotation) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationCluster) DeepCopyInto(out *WorkstationCluster) { *out = *in @@ -51,61 +66,6 @@ func (in *WorkstationCluster) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterAnnotation) DeepCopyInto(out *WorkstationClusterAnnotation) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterAnnotation. -func (in *WorkstationClusterAnnotation) DeepCopy() *WorkstationClusterAnnotation { - if in == nil { - return nil - } - out := new(WorkstationClusterAnnotation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterGCPCondition) DeepCopyInto(out *WorkstationClusterGCPCondition) { - *out = *in - if in.Code != nil { - in, out := &in.Code, &out.Code - *out = new(int32) - **out = **in - } - if in.Message != nil { - in, out := &in.Message, &out.Message - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterGCPCondition. -func (in *WorkstationClusterGCPCondition) DeepCopy() *WorkstationClusterGCPCondition { - if in == nil { - return nil - } - out := new(WorkstationClusterGCPCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterLabel) DeepCopyInto(out *WorkstationClusterLabel) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterLabel. -func (in *WorkstationClusterLabel) DeepCopy() *WorkstationClusterLabel { - if in == nil { - return nil - } - out := new(WorkstationClusterLabel) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationClusterList) DeepCopyInto(out *WorkstationClusterList) { *out = *in @@ -193,7 +153,7 @@ func (in *WorkstationClusterObservedState) DeepCopyInto(out *WorkstationClusterO } if in.GCPConditions != nil { in, out := &in.GCPConditions, &out.GCPConditions - *out = make([]WorkstationClusterGCPCondition, len(*in)) + *out = make([]WorkstationServiceGCPCondition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -210,6 +170,36 @@ func (in *WorkstationClusterObservedState) DeepCopy() *WorkstationClusterObserve return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationClusterParent) DeepCopyInto(out *WorkstationClusterParent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterParent. +func (in *WorkstationClusterParent) DeepCopy() *WorkstationClusterParent { + if in == nil { + return nil + } + out := new(WorkstationClusterParent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationClusterRef) DeepCopyInto(out *WorkstationClusterRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterRef. +func (in *WorkstationClusterRef) DeepCopy() *WorkstationClusterRef { + if in == nil { + return nil + } + out := new(WorkstationClusterRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationClusterSpec) DeepCopyInto(out *WorkstationClusterSpec) { *out = *in @@ -226,12 +216,12 @@ func (in *WorkstationClusterSpec) DeepCopyInto(out *WorkstationClusterSpec) { } if in.Annotations != nil { in, out := &in.Annotations, &out.Annotations - *out = make([]WorkstationClusterAnnotation, len(*in)) + *out = make([]WorkstationAnnotation, len(*in)) copy(*out, *in) } if in.Labels != nil { in, out := &in.Labels, &out.Labels - *out = make([]WorkstationClusterLabel, len(*in)) + *out = make([]WorkstationLabel, len(*in)) copy(*out, *in) } out.NetworkRef = in.NetworkRef @@ -312,3 +302,623 @@ func (in *WorkstationCluster_PrivateClusterConfig) DeepCopy() *WorkstationCluste in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig) DeepCopyInto(out *WorkstationConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig. +func (in *WorkstationConfig) DeepCopy() *WorkstationConfig { + if in == nil { + return nil + } + out := new(WorkstationConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WorkstationConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigList) DeepCopyInto(out *WorkstationConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]WorkstationConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigList. +func (in *WorkstationConfigList) DeepCopy() *WorkstationConfigList { + if in == nil { + return nil + } + out := new(WorkstationConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WorkstationConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigObservedState) DeepCopyInto(out *WorkstationConfigObservedState) { + *out = *in + if in.UID != nil { + in, out := &in.UID, &out.UID + *out = new(string) + **out = **in + } + if in.CreateTime != nil { + in, out := &in.CreateTime, &out.CreateTime + *out = new(string) + **out = **in + } + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = new(string) + **out = **in + } + if in.DeleteTime != nil { + in, out := &in.DeleteTime, &out.DeleteTime + *out = new(string) + **out = **in + } + if in.Etag != nil { + in, out := &in.Etag, &out.Etag + *out = new(string) + **out = **in + } + if in.Degraded != nil { + in, out := &in.Degraded, &out.Degraded + *out = new(bool) + **out = **in + } + if in.GCPConditions != nil { + in, out := &in.GCPConditions, &out.GCPConditions + *out = make([]WorkstationServiceGCPCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PooledInstances != nil { + in, out := &in.PooledInstances, &out.PooledInstances + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigObservedState. +func (in *WorkstationConfigObservedState) DeepCopy() *WorkstationConfigObservedState { + if in == nil { + return nil + } + out := new(WorkstationConfigObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigParent) DeepCopyInto(out *WorkstationConfigParent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigParent. +func (in *WorkstationConfigParent) DeepCopy() *WorkstationConfigParent { + if in == nil { + return nil + } + out := new(WorkstationConfigParent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigRef) DeepCopyInto(out *WorkstationConfigRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigRef. +func (in *WorkstationConfigRef) DeepCopy() *WorkstationConfigRef { + if in == nil { + return nil + } + out := new(WorkstationConfigRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigSpec) DeepCopyInto(out *WorkstationConfigSpec) { + *out = *in + if in.ProjectRef != nil { + in, out := &in.ProjectRef, &out.ProjectRef + *out = new(v1beta1.ProjectRef) + **out = **in + } + if in.Parent != nil { + in, out := &in.Parent, &out.Parent + *out = new(WorkstationClusterRef) + **out = **in + } + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.DisplayName != nil { + in, out := &in.DisplayName, &out.DisplayName + *out = new(string) + **out = **in + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make([]WorkstationAnnotation, len(*in)) + copy(*out, *in) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make([]WorkstationLabel, len(*in)) + copy(*out, *in) + } + if in.IdleTimeout != nil { + in, out := &in.IdleTimeout, &out.IdleTimeout + *out = new(string) + **out = **in + } + if in.RunningTimeout != nil { + in, out := &in.RunningTimeout, &out.RunningTimeout + *out = new(string) + **out = **in + } + if in.Host != nil { + in, out := &in.Host, &out.Host + *out = new(WorkstationConfig_Host) + (*in).DeepCopyInto(*out) + } + if in.PersistentDirectories != nil { + in, out := &in.PersistentDirectories, &out.PersistentDirectories + *out = make([]WorkstationConfig_PersistentDirectory, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(WorkstationConfig_Container) + (*in).DeepCopyInto(*out) + } + if in.EncryptionKey != nil { + in, out := &in.EncryptionKey, &out.EncryptionKey + *out = new(WorkstationConfig_CustomerEncryptionKey) + (*in).DeepCopyInto(*out) + } + if in.ReadinessChecks != nil { + in, out := &in.ReadinessChecks, &out.ReadinessChecks + *out = make([]WorkstationConfig_ReadinessCheck, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ReplicaZones != nil { + in, out := &in.ReplicaZones, &out.ReplicaZones + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigSpec. +func (in *WorkstationConfigSpec) DeepCopy() *WorkstationConfigSpec { + if in == nil { + return nil + } + out := new(WorkstationConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigStatus) DeepCopyInto(out *WorkstationConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]k8sv1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + if in.ExternalRef != nil { + in, out := &in.ExternalRef, &out.ExternalRef + *out = new(string) + **out = **in + } + if in.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(WorkstationConfigObservedState) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigStatus. +func (in *WorkstationConfigStatus) DeepCopy() *WorkstationConfigStatus { + if in == nil { + return nil + } + out := new(WorkstationConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Container) DeepCopyInto(out *WorkstationConfig_Container) { + *out = *in + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.Command != nil { + in, out := &in.Command, &out.Command + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]WorkstationConfig_Container_EnvVar, len(*in)) + copy(*out, *in) + } + if in.WorkingDir != nil { + in, out := &in.WorkingDir, &out.WorkingDir + *out = new(string) + **out = **in + } + if in.RunAsUser != nil { + in, out := &in.RunAsUser, &out.RunAsUser + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Container. +func (in *WorkstationConfig_Container) DeepCopy() *WorkstationConfig_Container { + if in == nil { + return nil + } + out := new(WorkstationConfig_Container) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Container_EnvVar) DeepCopyInto(out *WorkstationConfig_Container_EnvVar) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Container_EnvVar. +func (in *WorkstationConfig_Container_EnvVar) DeepCopy() *WorkstationConfig_Container_EnvVar { + if in == nil { + return nil + } + out := new(WorkstationConfig_Container_EnvVar) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_CustomerEncryptionKey) DeepCopyInto(out *WorkstationConfig_CustomerEncryptionKey) { + *out = *in + if in.KmsCryptoKeyRef != nil { + in, out := &in.KmsCryptoKeyRef, &out.KmsCryptoKeyRef + *out = new(v1beta1.KMSCryptoKeyRef) + **out = **in + } + if in.ServiceAccountRef != nil { + in, out := &in.ServiceAccountRef, &out.ServiceAccountRef + *out = new(v1beta1.IAMServiceAccountRef) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_CustomerEncryptionKey. +func (in *WorkstationConfig_CustomerEncryptionKey) DeepCopy() *WorkstationConfig_CustomerEncryptionKey { + if in == nil { + return nil + } + out := new(WorkstationConfig_CustomerEncryptionKey) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Host) DeepCopyInto(out *WorkstationConfig_Host) { + *out = *in + if in.GceInstance != nil { + in, out := &in.GceInstance, &out.GceInstance + *out = new(WorkstationConfig_Host_GceInstance) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Host. +func (in *WorkstationConfig_Host) DeepCopy() *WorkstationConfig_Host { + if in == nil { + return nil + } + out := new(WorkstationConfig_Host) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Host_GceInstance) DeepCopyInto(out *WorkstationConfig_Host_GceInstance) { + *out = *in + if in.MachineType != nil { + in, out := &in.MachineType, &out.MachineType + *out = new(string) + **out = **in + } + if in.ServiceAccountRef != nil { + in, out := &in.ServiceAccountRef, &out.ServiceAccountRef + *out = new(v1beta1.IAMServiceAccountRef) + **out = **in + } + if in.ServiceAccountScopes != nil { + in, out := &in.ServiceAccountScopes, &out.ServiceAccountScopes + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PoolSize != nil { + in, out := &in.PoolSize, &out.PoolSize + *out = new(int32) + **out = **in + } + if in.DisablePublicIPAddresses != nil { + in, out := &in.DisablePublicIPAddresses, &out.DisablePublicIPAddresses + *out = new(bool) + **out = **in + } + if in.EnableNestedVirtualization != nil { + in, out := &in.EnableNestedVirtualization, &out.EnableNestedVirtualization + *out = new(bool) + **out = **in + } + if in.ShieldedInstanceConfig != nil { + in, out := &in.ShieldedInstanceConfig, &out.ShieldedInstanceConfig + *out = new(WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig) + (*in).DeepCopyInto(*out) + } + if in.ConfidentialInstanceConfig != nil { + in, out := &in.ConfidentialInstanceConfig, &out.ConfidentialInstanceConfig + *out = new(WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig) + (*in).DeepCopyInto(*out) + } + if in.BootDiskSizeGB != nil { + in, out := &in.BootDiskSizeGB, &out.BootDiskSizeGB + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Host_GceInstance. +func (in *WorkstationConfig_Host_GceInstance) DeepCopy() *WorkstationConfig_Host_GceInstance { + if in == nil { + return nil + } + out := new(WorkstationConfig_Host_GceInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig) DeepCopyInto(out *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig) { + *out = *in + if in.EnableConfidentialCompute != nil { + in, out := &in.EnableConfidentialCompute, &out.EnableConfidentialCompute + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig. +func (in *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig) DeepCopy() *WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig { + if in == nil { + return nil + } + out := new(WorkstationConfig_Host_GceInstance_GceConfidentialInstanceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig) DeepCopyInto(out *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig) { + *out = *in + if in.EnableSecureBoot != nil { + in, out := &in.EnableSecureBoot, &out.EnableSecureBoot + *out = new(bool) + **out = **in + } + if in.EnableVTPM != nil { + in, out := &in.EnableVTPM, &out.EnableVTPM + *out = new(bool) + **out = **in + } + if in.EnableIntegrityMonitoring != nil { + in, out := &in.EnableIntegrityMonitoring, &out.EnableIntegrityMonitoring + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig. +func (in *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig) DeepCopy() *WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig { + if in == nil { + return nil + } + out := new(WorkstationConfig_Host_GceInstance_GceShieldedInstanceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_PersistentDirectory) DeepCopyInto(out *WorkstationConfig_PersistentDirectory) { + *out = *in + if in.GcePD != nil { + in, out := &in.GcePD, &out.GcePD + *out = new(WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk) + (*in).DeepCopyInto(*out) + } + if in.MountPath != nil { + in, out := &in.MountPath, &out.MountPath + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_PersistentDirectory. +func (in *WorkstationConfig_PersistentDirectory) DeepCopy() *WorkstationConfig_PersistentDirectory { + if in == nil { + return nil + } + out := new(WorkstationConfig_PersistentDirectory) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk) DeepCopyInto(out *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk) { + *out = *in + if in.SizeGB != nil { + in, out := &in.SizeGB, &out.SizeGB + *out = new(int32) + **out = **in + } + if in.FSType != nil { + in, out := &in.FSType, &out.FSType + *out = new(string) + **out = **in + } + if in.DiskType != nil { + in, out := &in.DiskType, &out.DiskType + *out = new(string) + **out = **in + } + if in.SourceSnapshot != nil { + in, out := &in.SourceSnapshot, &out.SourceSnapshot + *out = new(string) + **out = **in + } + if in.ReclaimPolicy != nil { + in, out := &in.ReclaimPolicy, &out.ReclaimPolicy + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk. +func (in *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk) DeepCopy() *WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk { + if in == nil { + return nil + } + out := new(WorkstationConfig_PersistentDirectory_GceRegionalPersistentDisk) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig_ReadinessCheck) DeepCopyInto(out *WorkstationConfig_ReadinessCheck) { + *out = *in + if in.Path != nil { + in, out := &in.Path, &out.Path + *out = new(string) + **out = **in + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig_ReadinessCheck. +func (in *WorkstationConfig_ReadinessCheck) DeepCopy() *WorkstationConfig_ReadinessCheck { + if in == nil { + return nil + } + out := new(WorkstationConfig_ReadinessCheck) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationLabel) DeepCopyInto(out *WorkstationLabel) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationLabel. +func (in *WorkstationLabel) DeepCopy() *WorkstationLabel { + if in == nil { + return nil + } + out := new(WorkstationLabel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationServiceGCPCondition) DeepCopyInto(out *WorkstationServiceGCPCondition) { + *out = *in + if in.Code != nil { + in, out := &in.Code, &out.Code + *out = new(int32) + **out = **in + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationServiceGCPCondition. +func (in *WorkstationServiceGCPCondition) DeepCopy() *WorkstationServiceGCPCondition { + if in == nil { + return nil + } + out := new(WorkstationServiceGCPCondition) + in.DeepCopyInto(out) + return out +} diff --git a/apis/workstations/v1beta1/workstationcluster_types.go b/apis/workstations/v1beta1/cluster_types.go similarity index 89% rename from apis/workstations/v1beta1/workstationcluster_types.go rename to apis/workstations/v1beta1/cluster_types.go index a14d73a9a2..1c12eb8ee3 100644 --- a/apis/workstations/v1beta1/workstationcluster_types.go +++ b/apis/workstations/v1beta1/cluster_types.go @@ -45,13 +45,13 @@ type WorkstationClusterSpec struct { DisplayName *string `json:"displayName,omitempty"` // Optional. Client-specified annotations. - Annotations []WorkstationClusterAnnotation `json:"annotations,omitempty"` + Annotations []WorkstationAnnotation `json:"annotations,omitempty"` // Optional. // [Labels](https://cloud.google.com/workstations/docs/label-resources) that // are applied to the workstation cluster and that are also propagated to the // underlying Compute Engine resources. - Labels []WorkstationClusterLabel `json:"labels,omitempty"` + Labels []WorkstationLabel `json:"labels,omitempty"` // Immutable. Reference to the Compute Engine network in which instances associated // with this workstation cluster will be created. @@ -68,22 +68,6 @@ type WorkstationClusterSpec struct { PrivateClusterConfig *WorkstationCluster_PrivateClusterConfig `json:"privateClusterConfig,omitempty"` } -type WorkstationClusterAnnotation struct { - // Key for the annotation. - Key string `json:"key,omitempty"` - - // Value for the annotation. - Value string `json:"value,omitempty"` -} - -type WorkstationClusterLabel struct { - // Key for the annotation. - Key string `json:"key,omitempty"` - - // Value for the annotation. - Value string `json:"value,omitempty"` -} - // +kcc:proto=google.cloud.workstations.v1.WorkstationCluster.PrivateClusterConfig type WorkstationCluster_PrivateClusterConfig struct { // Immutable. Whether Workstations endpoint is private. @@ -164,20 +148,7 @@ type WorkstationClusterObservedState struct { // Output only. Status conditions describing the workstation cluster's current // state. - GCPConditions []WorkstationClusterGCPCondition `json:"gcpConditions,omitempty"` -} - -// +kcc:proto=google.rpc.Status -type WorkstationClusterGCPCondition struct { - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. - Code *int32 `json:"code,omitempty"` - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. - Message *string `json:"message,omitempty"` + GCPConditions []WorkstationServiceGCPCondition `json:"gcpConditions,omitempty"` } // +genclient diff --git a/apis/workstations/v1beta1/shared_types.go b/apis/workstations/v1beta1/shared_types.go new file mode 100644 index 0000000000..d67dad82c8 --- /dev/null +++ b/apis/workstations/v1beta1/shared_types.go @@ -0,0 +1,44 @@ +// Copyright 2024 Google LLC +// +// 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. + +package v1beta1 + +type WorkstationAnnotation struct { + // Key for the annotation. + Key string `json:"key,omitempty"` + + // Value for the annotation. + Value string `json:"value,omitempty"` +} + +type WorkstationLabel struct { + // Key for the label. + Key string `json:"key,omitempty"` + + // Value for the label. + Value string `json:"value,omitempty"` +} + +// +kcc:proto=google.rpc.Status +type WorkstationServiceGCPCondition struct { + // The status code, which should be an enum value of + // [google.rpc.Code][google.rpc.Code]. + Code *int32 `json:"code,omitempty"` + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized + // by the client. + Message *string `json:"message,omitempty"` +} diff --git a/apis/workstations/v1beta1/zz_generated.deepcopy.go b/apis/workstations/v1beta1/zz_generated.deepcopy.go index 3e4ab1982b..59f72797fe 100644 --- a/apis/workstations/v1beta1/zz_generated.deepcopy.go +++ b/apis/workstations/v1beta1/zz_generated.deepcopy.go @@ -24,6 +24,21 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationAnnotation) DeepCopyInto(out *WorkstationAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationAnnotation. +func (in *WorkstationAnnotation) DeepCopy() *WorkstationAnnotation { + if in == nil { + return nil + } + out := new(WorkstationAnnotation) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationCluster) DeepCopyInto(out *WorkstationCluster) { *out = *in @@ -51,61 +66,6 @@ func (in *WorkstationCluster) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterAnnotation) DeepCopyInto(out *WorkstationClusterAnnotation) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterAnnotation. -func (in *WorkstationClusterAnnotation) DeepCopy() *WorkstationClusterAnnotation { - if in == nil { - return nil - } - out := new(WorkstationClusterAnnotation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterGCPCondition) DeepCopyInto(out *WorkstationClusterGCPCondition) { - *out = *in - if in.Code != nil { - in, out := &in.Code, &out.Code - *out = new(int32) - **out = **in - } - if in.Message != nil { - in, out := &in.Message, &out.Message - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterGCPCondition. -func (in *WorkstationClusterGCPCondition) DeepCopy() *WorkstationClusterGCPCondition { - if in == nil { - return nil - } - out := new(WorkstationClusterGCPCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkstationClusterLabel) DeepCopyInto(out *WorkstationClusterLabel) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterLabel. -func (in *WorkstationClusterLabel) DeepCopy() *WorkstationClusterLabel { - if in == nil { - return nil - } - out := new(WorkstationClusterLabel) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationClusterList) DeepCopyInto(out *WorkstationClusterList) { *out = *in @@ -193,7 +153,7 @@ func (in *WorkstationClusterObservedState) DeepCopyInto(out *WorkstationClusterO } if in.GCPConditions != nil { in, out := &in.GCPConditions, &out.GCPConditions - *out = make([]WorkstationClusterGCPCondition, len(*in)) + *out = make([]WorkstationServiceGCPCondition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -210,6 +170,36 @@ func (in *WorkstationClusterObservedState) DeepCopy() *WorkstationClusterObserve return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationClusterParent) DeepCopyInto(out *WorkstationClusterParent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterParent. +func (in *WorkstationClusterParent) DeepCopy() *WorkstationClusterParent { + if in == nil { + return nil + } + out := new(WorkstationClusterParent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationClusterRef) DeepCopyInto(out *WorkstationClusterRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationClusterRef. +func (in *WorkstationClusterRef) DeepCopy() *WorkstationClusterRef { + if in == nil { + return nil + } + out := new(WorkstationClusterRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkstationClusterSpec) DeepCopyInto(out *WorkstationClusterSpec) { *out = *in @@ -226,12 +216,12 @@ func (in *WorkstationClusterSpec) DeepCopyInto(out *WorkstationClusterSpec) { } if in.Annotations != nil { in, out := &in.Annotations, &out.Annotations - *out = make([]WorkstationClusterAnnotation, len(*in)) + *out = make([]WorkstationAnnotation, len(*in)) copy(*out, *in) } if in.Labels != nil { in, out := &in.Labels, &out.Labels - *out = make([]WorkstationClusterLabel, len(*in)) + *out = make([]WorkstationLabel, len(*in)) copy(*out, *in) } out.NetworkRef = in.NetworkRef @@ -312,3 +302,43 @@ func (in *WorkstationCluster_PrivateClusterConfig) DeepCopy() *WorkstationCluste in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationLabel) DeepCopyInto(out *WorkstationLabel) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationLabel. +func (in *WorkstationLabel) DeepCopy() *WorkstationLabel { + if in == nil { + return nil + } + out := new(WorkstationLabel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationServiceGCPCondition) DeepCopyInto(out *WorkstationServiceGCPCondition) { + *out = *in + if in.Code != nil { + in, out := &in.Code, &out.Code + *out = new(int32) + **out = **in + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationServiceGCPCondition. +func (in *WorkstationServiceGCPCondition) DeepCopy() *WorkstationServiceGCPCondition { + if in == nil { + return nil + } + out := new(WorkstationServiceGCPCondition) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationclusters.workstations.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationclusters.workstations.cnrm.cloud.google.com.yaml index 552e95981a..1d1fc91c02 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationclusters.workstations.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationclusters.workstations.cnrm.cloud.google.com.yaml @@ -78,10 +78,10 @@ spec: items: properties: key: - description: Key for the annotation. + description: Key for the label. type: string value: - description: Value for the annotation. + description: Value for the label. type: string type: object type: array @@ -424,10 +424,10 @@ spec: items: properties: key: - description: Key for the annotation. + description: Key for the label. type: string value: - description: Value for the annotation. + description: Value for the label. type: string type: object type: array diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationconfigs.workstations.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationconfigs.workstations.cnrm.cloud.google.com.yaml new file mode 100644 index 0000000000..5e4896a60a --- /dev/null +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_workstationconfigs.workstations.cnrm.cloud.google.com.yaml @@ -0,0 +1,684 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cnrm.cloud.google.com/version: 0.0.0-dev + creationTimestamp: null + labels: + cnrm.cloud.google.com/managed-by-kcc: "true" + cnrm.cloud.google.com/system: "true" + name: workstationconfigs.workstations.cnrm.cloud.google.com +spec: + group: workstations.cnrm.cloud.google.com + names: + categories: + - gcp + kind: WorkstationConfig + listKind: WorkstationConfigList + plural: workstationconfigs + shortNames: + - gcpworkstationconfig + - gcpworkstationconfigs + singular: workstationconfig + preserveUnknownFields: false + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: When 'True', the most recent reconcile of the resource succeeded + jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + - description: The reason for the value in 'Ready' + jsonPath: .status.conditions[?(@.type=='Ready')].reason + name: Status + type: string + - description: The last transition time for the value in 'Status' + jsonPath: .status.conditions[?(@.type=='Ready')].lastTransitionTime + name: Status Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: WorkstationConfig is the Schema for the WorkstationConfig API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: WorkstationConfigSpec defines the desired state of WorkstationConfig + properties: + annotations: + description: Optional. Client-specified annotations. + items: + properties: + key: + description: Key for the annotation. + type: string + value: + description: Value for the annotation. + type: string + type: object + type: array + container: + description: Optional. Container that runs upon startup for each workstation + using this workstation configuration. + properties: + args: + description: Optional. Arguments passed to the entrypoint. + items: + type: string + type: array + command: + description: Optional. If set, overrides the default ENTRYPOINT + specified by the image. + items: + type: string + type: array + env: + description: Optional. Environment variables passed to the container's + entrypoint. + items: + properties: + name: + description: Name is the name of the environment variable. + type: string + value: + description: Value is the value of the environment variable. + type: string + type: object + type: array + image: + description: |- + Optional. A Docker container image that defines a custom environment. + + Cloud Workstations provides a number of + [preconfigured + images](https://cloud.google.com/workstations/docs/preconfigured-base-images), + but you can create your own + [custom container + images](https://cloud.google.com/workstations/docs/custom-container-images). + If using a private image, the `host.gceInstance.serviceAccount` field + must be specified in the workstation configuration and must have + permission to pull the specified image. Otherwise, the image must be + publicly accessible. + type: string + runAsUser: + description: Optional. If set, overrides the USER specified in + the image with the given uid. + format: int32 + type: integer + workingDir: + description: Optional. If set, overrides the default DIR specified + by the image. + type: string + type: object + displayName: + description: Optional. Human-readable name for this workstation configuration. + type: string + encryptionKey: + description: |- + Immutable. Encrypts resources of this workstation configuration using a + customer-managed encryption key (CMEK). + + If specified, the boot disk of the Compute Engine instance and the + persistent disk are encrypted using this encryption key. If + this field is not set, the disks are encrypted using a generated + key. Customer-managed encryption keys do not protect disk metadata. + + If the customer-managed encryption key is rotated, when the workstation + instance is stopped, the system attempts to recreate the + persistent disk with the new version of the key. Be sure to keep + older versions of the key until the persistent disk is recreated. + Otherwise, data on the persistent disk might be lost. + + If the encryption key is revoked, the workstation session automatically + stops within 7 hours. + + Immutable after the workstation configuration is created. + properties: + kmsCryptoKeyRef: + description: Immutable. A reference to the Google Cloud KMS encryption + key. For example, `"projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"`. + The key must be in the same region as the workstation configuration. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: A reference to an externally managed KMSCryptoKey. + Should be in the format `projects/[kms_project_id]/locations/[region]/keyRings/[key_ring_id]/cryptoKeys/[key]`. + type: string + name: + description: The `name` of a `KMSCryptoKey` resource. + type: string + namespace: + description: The `namespace` of a `KMSCryptoKey` resource. + type: string + type: object + serviceAccountRef: + description: Immutable. A reference to a service account to use + with the specified KMS key. We recommend that you use a separate + service account and follow KMS best practices. For more information, + see [Separation of duties](https://cloud.google.com/kms/docs/separation-of-duties) + and `gcloud kms keys add-iam-policy-binding` [`--member`](https://cloud.google.com/sdk/gcloud/reference/kms/keys/add-iam-policy-binding#--member). + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The `email` field of an `IAMServiceAccount` resource. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + type: object + type: object + host: + description: Optional. Runtime host for the workstation. + properties: + gceInstance: + description: Specifies a Compute Engine instance as the host. + properties: + bootDiskSizeGB: + description: Optional. The size of the boot disk for the VM + in gigabytes (GB). The minimum boot disk size is `30` GB. + Defaults to `50` GB. + format: int32 + type: integer + confidentialInstanceConfig: + description: Optional. A set of Compute Engine Confidential + VM instance options. + properties: + enableConfidentialCompute: + description: Optional. Whether the instance has confidential + compute enabled. + type: boolean + type: object + disablePublicIPAddresses: + description: Optional. When set to true, disables public IP + addresses for VMs. If you disable public IP addresses, you + must set up Private Google Access or Cloud NAT on your network. + If you use Private Google Access and you use `private.googleapis.com` + or `restricted.googleapis.com` for Container Registry and + Artifact Registry, make sure that you set up DNS records + for domains `*.gcr.io` and `*.pkg.dev`. Defaults to false + (VMs have public IP addresses). + type: boolean + enableNestedVirtualization: + description: |- + Optional. Whether to enable nested virtualization on Cloud Workstations + VMs created under this workstation configuration. + + Nested virtualization lets you run virtual machine (VM) instances + inside your workstation. Before enabling nested virtualization, + consider the following important considerations. Cloud Workstations + instances are subject to the [same restrictions as Compute Engine + instances](https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions): + + * **Organization policy**: projects, folders, or + organizations may be restricted from creating nested VMs if the + **Disable VM nested virtualization** constraint is enforced in + the organization policy. For more information, see the + Compute Engine section, + [Checking whether nested virtualization is + allowed](https://cloud.google.com/compute/docs/instances/nested-virtualization/managing-constraint#checking_whether_nested_virtualization_is_allowed). + * **Performance**: nested VMs might experience a 10% or greater + decrease in performance for workloads that are CPU-bound and + possibly greater than a 10% decrease for workloads that are + input/output bound. + * **Machine Type**: nested virtualization can only be enabled on + workstation configurations that specify a + [machine_type][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.machine_type] + in the N1 or N2 machine series. + * **GPUs**: nested virtualization may not be enabled on workstation + configurations with accelerators. + * **Operating System**: Because + [Container-Optimized + OS](https://cloud.google.com/compute/docs/images/os-details#container-optimized_os_cos) + does not support nested virtualization, when nested virtualization is + enabled, the underlying Compute Engine VM instances boot from an + [Ubuntu + LTS](https://cloud.google.com/compute/docs/images/os-details#ubuntu_lts) + image. + type: boolean + machineType: + description: Optional. The type of machine to use for VM instances—for + example, `"e2-standard-4"`. For more information about machine + types that Cloud Workstations supports, see the list of + [available machine types](https://cloud.google.com/workstations/docs/available-machine-types). + type: string + poolSize: + description: Optional. The number of VMs that the system should + keep idle so that new workstations can be started quickly + for new users. Defaults to `0` in the API. + format: int32 + type: integer + serviceAccountRef: + description: |- + Optional. A reference to the service account for Cloud + Workstations VMs created with this configuration. When specified, be + sure that the service account has `logginglogEntries.create` permission + on the project so it can write logs out to Cloud Logging. If using a + custom container image, the service account must have permissions to + pull the specified image. + + If you as the administrator want to be able to `ssh` into the + underlying VM, you need to set this value to a service account + for which you have the `iam.serviceAccounts.actAs` permission. + Conversely, if you don't want anyone to be able to `ssh` into the + underlying VM, use a service account where no one has that + permission. + + If not set, VMs run with a service account provided by the + Cloud Workstations service, and the image must be publicly + accessible. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The `email` field of an `IAMServiceAccount` + resource. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + type: object + serviceAccountScopes: + description: Optional. Scopes to grant to the [service_account][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.service_account]. + Various scopes are automatically added based on feature + usage. When specified, users of workstations under this + configuration must have `iam.serviceAccounts.actAs` on the + service account. + items: + type: string + type: array + shieldedInstanceConfig: + description: Optional. A set of Compute Engine Shielded instance + options. + properties: + enableIntegrityMonitoring: + description: Optional. Whether the instance has integrity + monitoring enabled. + type: boolean + enableSecureBoot: + description: Optional. Whether the instance has Secure + Boot enabled. + type: boolean + enableVTPM: + description: Optional. Whether the instance has the vTPM + enabled. + type: boolean + type: object + tags: + description: Optional. Network tags to add to the Compute + Engine VMs backing the workstations. This option applies + [network tags](https://cloud.google.com/vpc/docs/add-remove-network-tags) + to VMs created with this configuration. These network tags + enable the creation of [firewall rules](https://cloud.google.com/workstations/docs/configure-firewall-rules). + items: + type: string + type: array + type: object + type: object + idleTimeout: + description: |- + Optional. Number of seconds to wait before automatically stopping a + workstation after it last received user traffic. + + A value of `"0s"` indicates that Cloud Workstations VMs created with this + configuration should never time out due to idleness. + Provide + [duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration) + terminated by `s` for seconds—for example, `"7200s"` (2 hours). + The default is `"1200s"` (20 minutes). + type: string + labels: + description: Optional. [Labels](https://cloud.google.com/workstations/docs/label-resources) + that are applied to the workstation configuration and that are also + propagated to the underlying Compute Engine resources. + items: + properties: + key: + description: Key for the label. + type: string + value: + description: Value for the label. + type: string + type: object + type: array + location: + description: The location of the WorkstationConfig. + type: string + parentRef: + description: Parent is a reference to the parent WorkstationCluster + for this WorkstationConfig. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: A reference to an externally managed WorkstationCluster + resource. Should be in the format "projects//locations//workstationClusters/". + type: string + name: + description: The name of a WorkstationCluster resource. + type: string + namespace: + description: The namespace of a WorkstationCluster resource. + type: string + type: object + persistentDirectories: + description: Optional. Directories to persist across workstation sessions. + items: + properties: + gcePD: + description: A PersistentDirectory backed by a Compute Engine + persistent disk. + properties: + diskType: + description: Optional. The [type of the persistent disk](https://cloud.google.com/compute/docs/disks#disk-types) + for the home directory. Defaults to `"pd-standard"`. + type: string + fsType: + description: Optional. Type of file system that the disk + should be formatted with. The workstation image must support + this file system type. Must be empty if [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + is set. Defaults to `"ext4"`. + type: string + reclaimPolicy: + description: Optional. Whether the persistent disk should + be deleted when the workstation is deleted. Valid values + are `DELETE` and `RETAIN`. Defaults to `DELETE`. + type: string + sizeGB: + description: |- + Optional. The GB capacity of a persistent home directory for each + workstation created with this configuration. Must be empty if + [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + is set. + + Valid values are `10`, `50`, `100`, `200`, `500`, or `1000`. + Defaults to `200`. If less than `200` GB, the + [disk_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.disk_type] + must be + `"pd-balanced"` or `"pd-ssd"`. + format: int32 + type: integer + sourceSnapshot: + description: Optional. Name of the snapshot to use as the + source for the disk. If set, [size_gb][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.size_gb] + and [fs_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.fs_type] + must be empty. + type: string + type: object + mountPath: + description: Optional. Location of this directory in the running + workstation. + type: string + type: object + type: array + projectRef: + description: Immutable. The Project that this resource belongs to. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The `projectID` field of a project, when not managed + by Config Connector. + type: string + kind: + description: The kind of the Project resource; optional but must + be `Project` if provided. + type: string + name: + description: The `name` field of a `Project` resource. + type: string + namespace: + description: The `namespace` field of a `Project` resource. + type: string + type: object + x-kubernetes-validations: + - message: ResourceID field is immutable + rule: self == oldSelf + readinessChecks: + description: Optional. Readiness checks to perform when starting a + workstation using this workstation configuration. Mark a workstation + as running only after all specified readiness checks return 200 + status codes. + items: + properties: + path: + description: Optional. Path to which the request should be sent. + type: string + port: + description: Optional. Port to which the request should be sent. + format: int32 + type: integer + type: object + type: array + replicaZones: + description: |- + Optional. Immutable. Specifies the zones used to replicate the VM and disk + resources within the region. If set, exactly two zones within the + workstation cluster's region must be specified—for example, + `['us-central1-a', 'us-central1-f']`. If this field is empty, two default + zones within the region are used. + + Immutable after the workstation configuration is created. + items: + type: string + type: array + resourceID: + description: Immutable. The WorkstationConfig name. If not given, + the metadata.name will be used. + type: string + x-kubernetes-validations: + - message: ResourceID field is immutable + rule: self == oldSelf + runningTimeout: + description: |- + Optional. Number of seconds that a workstation can run until it is + automatically shut down. We recommend that workstations be shut down daily + to reduce costs and so that security updates can be applied upon restart. + The + [idle_timeout][google.cloud.workstations.v1.WorkstationConfig.idle_timeout] + and + [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + fields are independent of each other. Note that the + [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + field shuts down VMs after the specified time, regardless of whether or not + the VMs are idle. + + Provide duration terminated by `s` for seconds—for example, `"54000s"` + (15 hours). Defaults to `"43200s"` (12 hours). A value of `"0s"` indicates + that workstations using this configuration should never time out. If + [encryption_key][google.cloud.workstations.v1.WorkstationConfig.encryption_key] + is set, it must be greater than `"0s"` and less than + `"86400s"` (24 hours). + + Warning: A value of `"0s"` indicates that Cloud Workstations VMs created + with this configuration have no maximum running time. This is strongly + discouraged because you incur costs and will not pick up security updates. + type: string + required: + - parentRef + - projectRef + type: object + status: + description: WorkstationConfigStatus defines the config connector machine + state of WorkstationConfig + properties: + conditions: + description: Conditions represent the latest available observations + of the object's current state. + items: + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + type: string + message: + description: Human-readable message indicating details about + last transition. + type: string + reason: + description: Unique, one-word, CamelCase reason for the condition's + last transition. + type: string + status: + description: Status is the status of the condition. Can be True, + False, Unknown. + type: string + type: + description: Type is the type of the condition. + type: string + type: object + type: array + externalRef: + description: A unique specifier for the WorkstationConfig resource + in GCP. + type: string + observedGeneration: + description: ObservedGeneration is the generation of the resource + that was most recently observed by the Config Connector controller. + If this is equal to metadata.generation, then that means that the + current reported status reflects the most recent desired state of + the resource. + format: int64 + type: integer + observedState: + description: ObservedState is the state of the resource as most recently + observed in GCP. + properties: + createTime: + description: Output only. Time when this workstation configuration + was created. + type: string + degraded: + description: Output only. Whether this resource is degraded, in + which case it may require user action to restore full functionality. + See also the [conditions][google.cloud.workstations.v1.WorkstationConfig.conditions] + field. + type: boolean + deleteTime: + description: Output only. Time when this workstation configuration + was soft-deleted. + type: string + etag: + description: Optional. Checksum computed by the server. May be + sent on update and delete requests to make sure that the client + has an up-to-date value before proceeding. + type: string + gcpConditions: + description: Output only. Status conditions describing the current + resource state. + items: + properties: + code: + description: The status code, which should be an enum value + of [google.rpc.Code][google.rpc.Code]. + format: int32 + type: integer + message: + description: A developer-facing error message, which should + be in English. Any user-facing error message should be + localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] + field, or localized by the client. + type: string + type: object + type: array + pooledInstances: + description: Output only. Number of instances currently available + in the pool for faster workstation startup. + format: int32 + type: integer + uid: + description: Output only. A system-assigned unique identifier + for this workstation configuration. + type: string + updateTime: + description: Output only. Time when this workstation configuration + was most recently updated. + type: string + type: object + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/pkg/clients/generated/apis/workstations/v1alpha1/doc.go b/pkg/clients/generated/apis/workstations/v1alpha1/doc.go new file mode 100644 index 0000000000..50ff66e39d --- /dev/null +++ b/pkg/clients/generated/apis/workstations/v1alpha1/doc.go @@ -0,0 +1,38 @@ +// Copyright 2020 Google LLC +// +// 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. + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Config Connector and manual +// changes will be clobbered when the file is regenerated. +// +// ---------------------------------------------------------------------------- + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Package v1alpha1 contains API Schema definitions for the workstations v1alpha1 API group. +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/pkg/apis/workstations +// +k8s:defaulter-gen=TypeMeta +// +groupName=workstations.cnrm.cloud.google.com + +package v1alpha1 diff --git a/pkg/clients/generated/apis/workstations/v1alpha1/register.go b/pkg/clients/generated/apis/workstations/v1alpha1/register.go new file mode 100644 index 0000000000..3833c3bbc6 --- /dev/null +++ b/pkg/clients/generated/apis/workstations/v1alpha1/register.go @@ -0,0 +1,63 @@ +// Copyright 2020 Google LLC +// +// 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. + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Config Connector and manual +// changes will be clobbered when the file is regenerated. +// +// ---------------------------------------------------------------------------- + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Package v1alpha1 contains API Schema definitions for the workstations v1alpha1 API group. +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/pkg/apis/workstations +// +k8s:defaulter-gen=TypeMeta +// +groupName=workstations.cnrm.cloud.google.com +package v1alpha1 + +import ( + "reflect" + + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // SchemeGroupVersion is the group version used to register these objects. + SchemeGroupVersion = schema.GroupVersion{Group: "workstations.cnrm.cloud.google.com", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} + + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + WorkstationConfigGVK = schema.GroupVersionKind{ + Group: SchemeGroupVersion.Group, + Version: SchemeGroupVersion.Version, + Kind: reflect.TypeOf(WorkstationConfig{}).Name(), + } + + workstationsAPIVersion = SchemeGroupVersion.String() +) diff --git a/pkg/clients/generated/apis/workstations/v1alpha1/workstationconfig_types.go b/pkg/clients/generated/apis/workstations/v1alpha1/workstationconfig_types.go new file mode 100644 index 0000000000..d9cf7c865d --- /dev/null +++ b/pkg/clients/generated/apis/workstations/v1alpha1/workstationconfig_types.go @@ -0,0 +1,487 @@ +// Copyright 2020 Google LLC +// +// 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. + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Config Connector and manual +// changes will be clobbered when the file is regenerated. +// +// ---------------------------------------------------------------------------- + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +package v1alpha1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type WorkstationconfigAnnotations struct { + /* Key for the annotation. */ + // +optional + Key *string `json:"key,omitempty"` + + /* Value for the annotation. */ + // +optional + Value *string `json:"value,omitempty"` +} + +type WorkstationconfigConfidentialInstanceConfig struct { + /* Optional. Whether the instance has confidential compute enabled. */ + // +optional + EnableConfidentialCompute *bool `json:"enableConfidentialCompute,omitempty"` +} + +type WorkstationconfigContainer struct { + /* Optional. Arguments passed to the entrypoint. */ + // +optional + Args []string `json:"args,omitempty"` + + /* Optional. If set, overrides the default ENTRYPOINT specified by the image. */ + // +optional + Command []string `json:"command,omitempty"` + + /* Optional. Environment variables passed to the container's entrypoint. */ + // +optional + Env []WorkstationconfigEnv `json:"env,omitempty"` + + /* Optional. A Docker container image that defines a custom environment. + + Cloud Workstations provides a number of + [preconfigured + images](https://cloud.google.com/workstations/docs/preconfigured-base-images), + but you can create your own + [custom container + images](https://cloud.google.com/workstations/docs/custom-container-images). + If using a private image, the `host.gceInstance.serviceAccount` field + must be specified in the workstation configuration and must have + permission to pull the specified image. Otherwise, the image must be + publicly accessible. */ + // +optional + Image *string `json:"image,omitempty"` + + /* Optional. If set, overrides the USER specified in the image with the given uid. */ + // +optional + RunAsUser *int32 `json:"runAsUser,omitempty"` + + /* Optional. If set, overrides the default DIR specified by the image. */ + // +optional + WorkingDir *string `json:"workingDir,omitempty"` +} + +type WorkstationconfigEncryptionKey struct { + /* Immutable. A reference to the Google Cloud KMS encryption key. For example, `"projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"`. The key must be in the same region as the workstation configuration. */ + // +optional + KmsCryptoKeyRef *v1alpha1.ResourceRef `json:"kmsCryptoKeyRef,omitempty"` + + /* Immutable. A reference to a service account to use with the specified KMS key. We recommend that you use a separate service account and follow KMS best practices. For more information, see [Separation of duties](https://cloud.google.com/kms/docs/separation-of-duties) and `gcloud kms keys add-iam-policy-binding` [`--member`](https://cloud.google.com/sdk/gcloud/reference/kms/keys/add-iam-policy-binding#--member). */ + // +optional + ServiceAccountRef *v1alpha1.ResourceRef `json:"serviceAccountRef,omitempty"` +} + +type WorkstationconfigEnv struct { + /* Name is the name of the environment variable. */ + // +optional + Name *string `json:"name,omitempty"` + + /* Value is the value of the environment variable. */ + // +optional + Value *string `json:"value,omitempty"` +} + +type WorkstationconfigGceInstance struct { + /* Optional. The size of the boot disk for the VM in gigabytes (GB). The minimum boot disk size is `30` GB. Defaults to `50` GB. */ + // +optional + BootDiskSizeGB *int32 `json:"bootDiskSizeGB,omitempty"` + + /* Optional. A set of Compute Engine Confidential VM instance options. */ + // +optional + ConfidentialInstanceConfig *WorkstationconfigConfidentialInstanceConfig `json:"confidentialInstanceConfig,omitempty"` + + /* Optional. When set to true, disables public IP addresses for VMs. If you disable public IP addresses, you must set up Private Google Access or Cloud NAT on your network. If you use Private Google Access and you use `private.googleapis.com` or `restricted.googleapis.com` for Container Registry and Artifact Registry, make sure that you set up DNS records for domains `*.gcr.io` and `*.pkg.dev`. Defaults to false (VMs have public IP addresses). */ + // +optional + DisablePublicIPAddresses *bool `json:"disablePublicIPAddresses,omitempty"` + + /* Optional. Whether to enable nested virtualization on Cloud Workstations + VMs created under this workstation configuration. + + Nested virtualization lets you run virtual machine (VM) instances + inside your workstation. Before enabling nested virtualization, + consider the following important considerations. Cloud Workstations + instances are subject to the [same restrictions as Compute Engine + instances](https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions): + + * **Organization policy**: projects, folders, or + organizations may be restricted from creating nested VMs if the + **Disable VM nested virtualization** constraint is enforced in + the organization policy. For more information, see the + Compute Engine section, + [Checking whether nested virtualization is + allowed](https://cloud.google.com/compute/docs/instances/nested-virtualization/managing-constraint#checking_whether_nested_virtualization_is_allowed). + * **Performance**: nested VMs might experience a 10% or greater + decrease in performance for workloads that are CPU-bound and + possibly greater than a 10% decrease for workloads that are + input/output bound. + * **Machine Type**: nested virtualization can only be enabled on + workstation configurations that specify a + [machine_type][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.machine_type] + in the N1 or N2 machine series. + * **GPUs**: nested virtualization may not be enabled on workstation + configurations with accelerators. + * **Operating System**: Because + [Container-Optimized + OS](https://cloud.google.com/compute/docs/images/os-details#container-optimized_os_cos) + does not support nested virtualization, when nested virtualization is + enabled, the underlying Compute Engine VM instances boot from an + [Ubuntu + LTS](https://cloud.google.com/compute/docs/images/os-details#ubuntu_lts) + image. */ + // +optional + EnableNestedVirtualization *bool `json:"enableNestedVirtualization,omitempty"` + + /* Optional. The type of machine to use for VM instances—for example, `"e2-standard-4"`. For more information about machine types that Cloud Workstations supports, see the list of [available machine types](https://cloud.google.com/workstations/docs/available-machine-types). */ + // +optional + MachineType *string `json:"machineType,omitempty"` + + /* Optional. The number of VMs that the system should keep idle so that new workstations can be started quickly for new users. Defaults to `0` in the API. */ + // +optional + PoolSize *int32 `json:"poolSize,omitempty"` + + /* Optional. A reference to the service account for Cloud + Workstations VMs created with this configuration. When specified, be + sure that the service account has `logginglogEntries.create` permission + on the project so it can write logs out to Cloud Logging. If using a + custom container image, the service account must have permissions to + pull the specified image. + + If you as the administrator want to be able to `ssh` into the + underlying VM, you need to set this value to a service account + for which you have the `iam.serviceAccounts.actAs` permission. + Conversely, if you don't want anyone to be able to `ssh` into the + underlying VM, use a service account where no one has that + permission. + + If not set, VMs run with a service account provided by the + Cloud Workstations service, and the image must be publicly + accessible. */ + // +optional + ServiceAccountRef *v1alpha1.ResourceRef `json:"serviceAccountRef,omitempty"` + + /* Optional. Scopes to grant to the [service_account][google.cloud.workstations.v1.WorkstationConfig.Host.GceInstance.service_account]. Various scopes are automatically added based on feature usage. When specified, users of workstations under this configuration must have `iam.serviceAccounts.actAs` on the service account. */ + // +optional + ServiceAccountScopes []string `json:"serviceAccountScopes,omitempty"` + + /* Optional. A set of Compute Engine Shielded instance options. */ + // +optional + ShieldedInstanceConfig *WorkstationconfigShieldedInstanceConfig `json:"shieldedInstanceConfig,omitempty"` + + /* Optional. Network tags to add to the Compute Engine VMs backing the workstations. This option applies [network tags](https://cloud.google.com/vpc/docs/add-remove-network-tags) to VMs created with this configuration. These network tags enable the creation of [firewall rules](https://cloud.google.com/workstations/docs/configure-firewall-rules). */ + // +optional + Tags []string `json:"tags,omitempty"` +} + +type WorkstationconfigGcePD struct { + /* Optional. The [type of the persistent disk](https://cloud.google.com/compute/docs/disks#disk-types) for the home directory. Defaults to `"pd-standard"`. */ + // +optional + DiskType *string `json:"diskType,omitempty"` + + /* Optional. Type of file system that the disk should be formatted with. The workstation image must support this file system type. Must be empty if [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] is set. Defaults to `"ext4"`. */ + // +optional + FsType *string `json:"fsType,omitempty"` + + /* Optional. Whether the persistent disk should be deleted when the workstation is deleted. Valid values are `DELETE` and `RETAIN`. Defaults to `DELETE`. */ + // +optional + ReclaimPolicy *string `json:"reclaimPolicy,omitempty"` + + /* Optional. The GB capacity of a persistent home directory for each + workstation created with this configuration. Must be empty if + [source_snapshot][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.source_snapshot] + is set. + + Valid values are `10`, `50`, `100`, `200`, `500`, or `1000`. + Defaults to `200`. If less than `200` GB, the + [disk_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.disk_type] + must be + `"pd-balanced"` or `"pd-ssd"`. */ + // +optional + SizeGB *int32 `json:"sizeGB,omitempty"` + + /* Optional. Name of the snapshot to use as the source for the disk. If set, [size_gb][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.size_gb] and [fs_type][google.cloud.workstations.v1.WorkstationConfig.PersistentDirectory.GceRegionalPersistentDisk.fs_type] must be empty. */ + // +optional + SourceSnapshot *string `json:"sourceSnapshot,omitempty"` +} + +type WorkstationconfigHost struct { + /* Specifies a Compute Engine instance as the host. */ + // +optional + GceInstance *WorkstationconfigGceInstance `json:"gceInstance,omitempty"` +} + +type WorkstationconfigLabels struct { + /* Key for the label. */ + // +optional + Key *string `json:"key,omitempty"` + + /* Value for the label. */ + // +optional + Value *string `json:"value,omitempty"` +} + +type WorkstationconfigPersistentDirectories struct { + /* A PersistentDirectory backed by a Compute Engine persistent disk. */ + // +optional + GcePD *WorkstationconfigGcePD `json:"gcePD,omitempty"` + + /* Optional. Location of this directory in the running workstation. */ + // +optional + MountPath *string `json:"mountPath,omitempty"` +} + +type WorkstationconfigReadinessChecks struct { + /* Optional. Path to which the request should be sent. */ + // +optional + Path *string `json:"path,omitempty"` + + /* Optional. Port to which the request should be sent. */ + // +optional + Port *int32 `json:"port,omitempty"` +} + +type WorkstationconfigShieldedInstanceConfig struct { + /* Optional. Whether the instance has integrity monitoring enabled. */ + // +optional + EnableIntegrityMonitoring *bool `json:"enableIntegrityMonitoring,omitempty"` + + /* Optional. Whether the instance has Secure Boot enabled. */ + // +optional + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + + /* Optional. Whether the instance has the vTPM enabled. */ + // +optional + EnableVTPM *bool `json:"enableVTPM,omitempty"` +} + +type WorkstationConfigSpec struct { + /* Optional. Client-specified annotations. */ + // +optional + Annotations []WorkstationconfigAnnotations `json:"annotations,omitempty"` + + /* Optional. Container that runs upon startup for each workstation using this workstation configuration. */ + // +optional + Container *WorkstationconfigContainer `json:"container,omitempty"` + + /* Optional. Human-readable name for this workstation configuration. */ + // +optional + DisplayName *string `json:"displayName,omitempty"` + + /* Immutable. Encrypts resources of this workstation configuration using a + customer-managed encryption key (CMEK). + + If specified, the boot disk of the Compute Engine instance and the + persistent disk are encrypted using this encryption key. If + this field is not set, the disks are encrypted using a generated + key. Customer-managed encryption keys do not protect disk metadata. + + If the customer-managed encryption key is rotated, when the workstation + instance is stopped, the system attempts to recreate the + persistent disk with the new version of the key. Be sure to keep + older versions of the key until the persistent disk is recreated. + Otherwise, data on the persistent disk might be lost. + + If the encryption key is revoked, the workstation session automatically + stops within 7 hours. + + Immutable after the workstation configuration is created. */ + // +optional + EncryptionKey *WorkstationconfigEncryptionKey `json:"encryptionKey,omitempty"` + + /* Optional. Runtime host for the workstation. */ + // +optional + Host *WorkstationconfigHost `json:"host,omitempty"` + + /* Optional. Number of seconds to wait before automatically stopping a + workstation after it last received user traffic. + + A value of `"0s"` indicates that Cloud Workstations VMs created with this + configuration should never time out due to idleness. + Provide + [duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration) + terminated by `s` for seconds—for example, `"7200s"` (2 hours). + The default is `"1200s"` (20 minutes). */ + // +optional + IdleTimeout *string `json:"idleTimeout,omitempty"` + + /* Optional. [Labels](https://cloud.google.com/workstations/docs/label-resources) that are applied to the workstation configuration and that are also propagated to the underlying Compute Engine resources. */ + // +optional + Labels []WorkstationconfigLabels `json:"labels,omitempty"` + + /* The location of the WorkstationConfig. */ + // +optional + Location *string `json:"location,omitempty"` + + /* Parent is a reference to the parent WorkstationCluster for this WorkstationConfig. */ + ParentRef v1alpha1.ResourceRef `json:"parentRef"` + + /* Optional. Directories to persist across workstation sessions. */ + // +optional + PersistentDirectories []WorkstationconfigPersistentDirectories `json:"persistentDirectories,omitempty"` + + /* Immutable. The Project that this resource belongs to. */ + ProjectRef v1alpha1.ResourceRef `json:"projectRef"` + + /* Optional. Readiness checks to perform when starting a workstation using this workstation configuration. Mark a workstation as running only after all specified readiness checks return 200 status codes. */ + // +optional + ReadinessChecks []WorkstationconfigReadinessChecks `json:"readinessChecks,omitempty"` + + /* Optional. Immutable. Specifies the zones used to replicate the VM and disk + resources within the region. If set, exactly two zones within the + workstation cluster's region must be specified—for example, + `['us-central1-a', 'us-central1-f']`. If this field is empty, two default + zones within the region are used. + + Immutable after the workstation configuration is created. */ + // +optional + ReplicaZones []string `json:"replicaZones,omitempty"` + + /* Immutable. The WorkstationConfig name. If not given, the metadata.name will be used. */ + // +optional + ResourceID *string `json:"resourceID,omitempty"` + + /* Optional. Number of seconds that a workstation can run until it is + automatically shut down. We recommend that workstations be shut down daily + to reduce costs and so that security updates can be applied upon restart. + The + [idle_timeout][google.cloud.workstations.v1.WorkstationConfig.idle_timeout] + and + [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + fields are independent of each other. Note that the + [running_timeout][google.cloud.workstations.v1.WorkstationConfig.running_timeout] + field shuts down VMs after the specified time, regardless of whether or not + the VMs are idle. + + Provide duration terminated by `s` for seconds—for example, `"54000s"` + (15 hours). Defaults to `"43200s"` (12 hours). A value of `"0s"` indicates + that workstations using this configuration should never time out. If + [encryption_key][google.cloud.workstations.v1.WorkstationConfig.encryption_key] + is set, it must be greater than `"0s"` and less than + `"86400s"` (24 hours). + + Warning: A value of `"0s"` indicates that Cloud Workstations VMs created + with this configuration have no maximum running time. This is strongly + discouraged because you incur costs and will not pick up security updates. */ + // +optional + RunningTimeout *string `json:"runningTimeout,omitempty"` +} + +type WorkstationconfigGcpConditionsStatus struct { + /* The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. */ + // +optional + Code *int32 `json:"code,omitempty"` + + /* A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. */ + // +optional + Message *string `json:"message,omitempty"` +} + +type WorkstationconfigObservedStateStatus struct { + /* Output only. Time when this workstation configuration was created. */ + // +optional + CreateTime *string `json:"createTime,omitempty"` + + /* Output only. Whether this resource is degraded, in which case it may require user action to restore full functionality. See also the [conditions][google.cloud.workstations.v1.WorkstationConfig.conditions] field. */ + // +optional + Degraded *bool `json:"degraded,omitempty"` + + /* Output only. Time when this workstation configuration was soft-deleted. */ + // +optional + DeleteTime *string `json:"deleteTime,omitempty"` + + /* Optional. Checksum computed by the server. May be sent on update and delete requests to make sure that the client has an up-to-date value before proceeding. */ + // +optional + Etag *string `json:"etag,omitempty"` + + /* Output only. Status conditions describing the current resource state. */ + // +optional + GcpConditions []WorkstationconfigGcpConditionsStatus `json:"gcpConditions,omitempty"` + + /* Output only. Number of instances currently available in the pool for faster workstation startup. */ + // +optional + PooledInstances *int32 `json:"pooledInstances,omitempty"` + + /* Output only. A system-assigned unique identifier for this workstation configuration. */ + // +optional + Uid *string `json:"uid,omitempty"` + + /* Output only. Time when this workstation configuration was most recently updated. */ + // +optional + UpdateTime *string `json:"updateTime,omitempty"` +} + +type WorkstationConfigStatus struct { + /* Conditions represent the latest available observations of the + WorkstationConfig's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + /* A unique specifier for the WorkstationConfig resource in GCP. */ + // +optional + ExternalRef *string `json:"externalRef,omitempty"` + + /* ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. */ + // +optional + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + + /* ObservedState is the state of the resource as most recently observed in GCP. */ + // +optional + ObservedState *WorkstationconfigObservedStateStatus `json:"observedState,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpworkstationconfig;gcpworkstationconfigs +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true" +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" + +// WorkstationConfig is the Schema for the workstations API +// +k8s:openapi-gen=true +type WorkstationConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec WorkstationConfigSpec `json:"spec,omitempty"` + Status WorkstationConfigStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// WorkstationConfigList contains a list of WorkstationConfig +type WorkstationConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []WorkstationConfig `json:"items"` +} + +func init() { + SchemeBuilder.Register(&WorkstationConfig{}, &WorkstationConfigList{}) +} diff --git a/pkg/clients/generated/apis/workstations/v1alpha1/zz_generated.deepcopy.go b/pkg/clients/generated/apis/workstations/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..5613460b93 --- /dev/null +++ b/pkg/clients/generated/apis/workstations/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,686 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + k8sv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfig) DeepCopyInto(out *WorkstationConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfig. +func (in *WorkstationConfig) DeepCopy() *WorkstationConfig { + if in == nil { + return nil + } + out := new(WorkstationConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WorkstationConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigList) DeepCopyInto(out *WorkstationConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]WorkstationConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigList. +func (in *WorkstationConfigList) DeepCopy() *WorkstationConfigList { + if in == nil { + return nil + } + out := new(WorkstationConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WorkstationConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigSpec) DeepCopyInto(out *WorkstationConfigSpec) { + *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make([]WorkstationconfigAnnotations, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(WorkstationconfigContainer) + (*in).DeepCopyInto(*out) + } + if in.DisplayName != nil { + in, out := &in.DisplayName, &out.DisplayName + *out = new(string) + **out = **in + } + if in.EncryptionKey != nil { + in, out := &in.EncryptionKey, &out.EncryptionKey + *out = new(WorkstationconfigEncryptionKey) + (*in).DeepCopyInto(*out) + } + if in.Host != nil { + in, out := &in.Host, &out.Host + *out = new(WorkstationconfigHost) + (*in).DeepCopyInto(*out) + } + if in.IdleTimeout != nil { + in, out := &in.IdleTimeout, &out.IdleTimeout + *out = new(string) + **out = **in + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make([]WorkstationconfigLabels, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Location != nil { + in, out := &in.Location, &out.Location + *out = new(string) + **out = **in + } + out.ParentRef = in.ParentRef + if in.PersistentDirectories != nil { + in, out := &in.PersistentDirectories, &out.PersistentDirectories + *out = make([]WorkstationconfigPersistentDirectories, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.ProjectRef = in.ProjectRef + if in.ReadinessChecks != nil { + in, out := &in.ReadinessChecks, &out.ReadinessChecks + *out = make([]WorkstationconfigReadinessChecks, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ReplicaZones != nil { + in, out := &in.ReplicaZones, &out.ReplicaZones + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.RunningTimeout != nil { + in, out := &in.RunningTimeout, &out.RunningTimeout + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigSpec. +func (in *WorkstationConfigSpec) DeepCopy() *WorkstationConfigSpec { + if in == nil { + return nil + } + out := new(WorkstationConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationConfigStatus) DeepCopyInto(out *WorkstationConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]k8sv1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ExternalRef != nil { + in, out := &in.ExternalRef, &out.ExternalRef + *out = new(string) + **out = **in + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + if in.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(WorkstationconfigObservedStateStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationConfigStatus. +func (in *WorkstationConfigStatus) DeepCopy() *WorkstationConfigStatus { + if in == nil { + return nil + } + out := new(WorkstationConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigAnnotations) DeepCopyInto(out *WorkstationconfigAnnotations) { + *out = *in + if in.Key != nil { + in, out := &in.Key, &out.Key + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigAnnotations. +func (in *WorkstationconfigAnnotations) DeepCopy() *WorkstationconfigAnnotations { + if in == nil { + return nil + } + out := new(WorkstationconfigAnnotations) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigConfidentialInstanceConfig) DeepCopyInto(out *WorkstationconfigConfidentialInstanceConfig) { + *out = *in + if in.EnableConfidentialCompute != nil { + in, out := &in.EnableConfidentialCompute, &out.EnableConfidentialCompute + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigConfidentialInstanceConfig. +func (in *WorkstationconfigConfidentialInstanceConfig) DeepCopy() *WorkstationconfigConfidentialInstanceConfig { + if in == nil { + return nil + } + out := new(WorkstationconfigConfidentialInstanceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigContainer) DeepCopyInto(out *WorkstationconfigContainer) { + *out = *in + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Command != nil { + in, out := &in.Command, &out.Command + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]WorkstationconfigEnv, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.RunAsUser != nil { + in, out := &in.RunAsUser, &out.RunAsUser + *out = new(int32) + **out = **in + } + if in.WorkingDir != nil { + in, out := &in.WorkingDir, &out.WorkingDir + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigContainer. +func (in *WorkstationconfigContainer) DeepCopy() *WorkstationconfigContainer { + if in == nil { + return nil + } + out := new(WorkstationconfigContainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigEncryptionKey) DeepCopyInto(out *WorkstationconfigEncryptionKey) { + *out = *in + if in.KmsCryptoKeyRef != nil { + in, out := &in.KmsCryptoKeyRef, &out.KmsCryptoKeyRef + *out = new(k8sv1alpha1.ResourceRef) + **out = **in + } + if in.ServiceAccountRef != nil { + in, out := &in.ServiceAccountRef, &out.ServiceAccountRef + *out = new(k8sv1alpha1.ResourceRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigEncryptionKey. +func (in *WorkstationconfigEncryptionKey) DeepCopy() *WorkstationconfigEncryptionKey { + if in == nil { + return nil + } + out := new(WorkstationconfigEncryptionKey) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigEnv) DeepCopyInto(out *WorkstationconfigEnv) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigEnv. +func (in *WorkstationconfigEnv) DeepCopy() *WorkstationconfigEnv { + if in == nil { + return nil + } + out := new(WorkstationconfigEnv) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigGceInstance) DeepCopyInto(out *WorkstationconfigGceInstance) { + *out = *in + if in.BootDiskSizeGB != nil { + in, out := &in.BootDiskSizeGB, &out.BootDiskSizeGB + *out = new(int32) + **out = **in + } + if in.ConfidentialInstanceConfig != nil { + in, out := &in.ConfidentialInstanceConfig, &out.ConfidentialInstanceConfig + *out = new(WorkstationconfigConfidentialInstanceConfig) + (*in).DeepCopyInto(*out) + } + if in.DisablePublicIPAddresses != nil { + in, out := &in.DisablePublicIPAddresses, &out.DisablePublicIPAddresses + *out = new(bool) + **out = **in + } + if in.EnableNestedVirtualization != nil { + in, out := &in.EnableNestedVirtualization, &out.EnableNestedVirtualization + *out = new(bool) + **out = **in + } + if in.MachineType != nil { + in, out := &in.MachineType, &out.MachineType + *out = new(string) + **out = **in + } + if in.PoolSize != nil { + in, out := &in.PoolSize, &out.PoolSize + *out = new(int32) + **out = **in + } + if in.ServiceAccountRef != nil { + in, out := &in.ServiceAccountRef, &out.ServiceAccountRef + *out = new(k8sv1alpha1.ResourceRef) + **out = **in + } + if in.ServiceAccountScopes != nil { + in, out := &in.ServiceAccountScopes, &out.ServiceAccountScopes + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ShieldedInstanceConfig != nil { + in, out := &in.ShieldedInstanceConfig, &out.ShieldedInstanceConfig + *out = new(WorkstationconfigShieldedInstanceConfig) + (*in).DeepCopyInto(*out) + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigGceInstance. +func (in *WorkstationconfigGceInstance) DeepCopy() *WorkstationconfigGceInstance { + if in == nil { + return nil + } + out := new(WorkstationconfigGceInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigGcePD) DeepCopyInto(out *WorkstationconfigGcePD) { + *out = *in + if in.DiskType != nil { + in, out := &in.DiskType, &out.DiskType + *out = new(string) + **out = **in + } + if in.FsType != nil { + in, out := &in.FsType, &out.FsType + *out = new(string) + **out = **in + } + if in.ReclaimPolicy != nil { + in, out := &in.ReclaimPolicy, &out.ReclaimPolicy + *out = new(string) + **out = **in + } + if in.SizeGB != nil { + in, out := &in.SizeGB, &out.SizeGB + *out = new(int32) + **out = **in + } + if in.SourceSnapshot != nil { + in, out := &in.SourceSnapshot, &out.SourceSnapshot + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigGcePD. +func (in *WorkstationconfigGcePD) DeepCopy() *WorkstationconfigGcePD { + if in == nil { + return nil + } + out := new(WorkstationconfigGcePD) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigGcpConditionsStatus) DeepCopyInto(out *WorkstationconfigGcpConditionsStatus) { + *out = *in + if in.Code != nil { + in, out := &in.Code, &out.Code + *out = new(int32) + **out = **in + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigGcpConditionsStatus. +func (in *WorkstationconfigGcpConditionsStatus) DeepCopy() *WorkstationconfigGcpConditionsStatus { + if in == nil { + return nil + } + out := new(WorkstationconfigGcpConditionsStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigHost) DeepCopyInto(out *WorkstationconfigHost) { + *out = *in + if in.GceInstance != nil { + in, out := &in.GceInstance, &out.GceInstance + *out = new(WorkstationconfigGceInstance) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigHost. +func (in *WorkstationconfigHost) DeepCopy() *WorkstationconfigHost { + if in == nil { + return nil + } + out := new(WorkstationconfigHost) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigLabels) DeepCopyInto(out *WorkstationconfigLabels) { + *out = *in + if in.Key != nil { + in, out := &in.Key, &out.Key + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigLabels. +func (in *WorkstationconfigLabels) DeepCopy() *WorkstationconfigLabels { + if in == nil { + return nil + } + out := new(WorkstationconfigLabels) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigObservedStateStatus) DeepCopyInto(out *WorkstationconfigObservedStateStatus) { + *out = *in + if in.CreateTime != nil { + in, out := &in.CreateTime, &out.CreateTime + *out = new(string) + **out = **in + } + if in.Degraded != nil { + in, out := &in.Degraded, &out.Degraded + *out = new(bool) + **out = **in + } + if in.DeleteTime != nil { + in, out := &in.DeleteTime, &out.DeleteTime + *out = new(string) + **out = **in + } + if in.Etag != nil { + in, out := &in.Etag, &out.Etag + *out = new(string) + **out = **in + } + if in.GcpConditions != nil { + in, out := &in.GcpConditions, &out.GcpConditions + *out = make([]WorkstationconfigGcpConditionsStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PooledInstances != nil { + in, out := &in.PooledInstances, &out.PooledInstances + *out = new(int32) + **out = **in + } + if in.Uid != nil { + in, out := &in.Uid, &out.Uid + *out = new(string) + **out = **in + } + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigObservedStateStatus. +func (in *WorkstationconfigObservedStateStatus) DeepCopy() *WorkstationconfigObservedStateStatus { + if in == nil { + return nil + } + out := new(WorkstationconfigObservedStateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigPersistentDirectories) DeepCopyInto(out *WorkstationconfigPersistentDirectories) { + *out = *in + if in.GcePD != nil { + in, out := &in.GcePD, &out.GcePD + *out = new(WorkstationconfigGcePD) + (*in).DeepCopyInto(*out) + } + if in.MountPath != nil { + in, out := &in.MountPath, &out.MountPath + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigPersistentDirectories. +func (in *WorkstationconfigPersistentDirectories) DeepCopy() *WorkstationconfigPersistentDirectories { + if in == nil { + return nil + } + out := new(WorkstationconfigPersistentDirectories) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigReadinessChecks) DeepCopyInto(out *WorkstationconfigReadinessChecks) { + *out = *in + if in.Path != nil { + in, out := &in.Path, &out.Path + *out = new(string) + **out = **in + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigReadinessChecks. +func (in *WorkstationconfigReadinessChecks) DeepCopy() *WorkstationconfigReadinessChecks { + if in == nil { + return nil + } + out := new(WorkstationconfigReadinessChecks) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkstationconfigShieldedInstanceConfig) DeepCopyInto(out *WorkstationconfigShieldedInstanceConfig) { + *out = *in + if in.EnableIntegrityMonitoring != nil { + in, out := &in.EnableIntegrityMonitoring, &out.EnableIntegrityMonitoring + *out = new(bool) + **out = **in + } + if in.EnableSecureBoot != nil { + in, out := &in.EnableSecureBoot, &out.EnableSecureBoot + *out = new(bool) + **out = **in + } + if in.EnableVTPM != nil { + in, out := &in.EnableVTPM, &out.EnableVTPM + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkstationconfigShieldedInstanceConfig. +func (in *WorkstationconfigShieldedInstanceConfig) DeepCopy() *WorkstationconfigShieldedInstanceConfig { + if in == nil { + return nil + } + out := new(WorkstationconfigShieldedInstanceConfig) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/clients/generated/apis/workstations/v1beta1/workstationcluster_types.go b/pkg/clients/generated/apis/workstations/v1beta1/workstationcluster_types.go index 6841bfe6c7..cf08ef700e 100644 --- a/pkg/clients/generated/apis/workstations/v1beta1/workstationcluster_types.go +++ b/pkg/clients/generated/apis/workstations/v1beta1/workstationcluster_types.go @@ -64,11 +64,11 @@ type WorkstationclusterAnnotations struct { } type WorkstationclusterLabels struct { - /* Key for the annotation. */ + /* Key for the label. */ // +optional Key *string `json:"key,omitempty"` - /* Value for the annotation. */ + /* Value for the label. */ // +optional Value *string `json:"value,omitempty"` } diff --git a/pkg/clients/generated/client/clientset/versioned/clientset.go b/pkg/clients/generated/client/clientset/versioned/clientset.go index 0b6895ddb5..f23e60fba9 100644 --- a/pkg/clients/generated/client/clientset/versioned/clientset.go +++ b/pkg/clients/generated/client/clientset/versioned/clientset.go @@ -146,6 +146,7 @@ import ( vertexaiv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/vertexai/v1beta1" vpcaccessv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/vpcaccess/v1beta1" workflowsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workflows/v1alpha1" + workstationsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1" workstationsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -275,6 +276,7 @@ type Interface interface { VertexaiV1beta1() vertexaiv1beta1.VertexaiV1beta1Interface VpcaccessV1beta1() vpcaccessv1beta1.VpcaccessV1beta1Interface WorkflowsV1alpha1() workflowsv1alpha1.WorkflowsV1alpha1Interface + WorkstationsV1alpha1() workstationsv1alpha1.WorkstationsV1alpha1Interface WorkstationsV1beta1() workstationsv1beta1.WorkstationsV1beta1Interface } @@ -402,6 +404,7 @@ type Clientset struct { vertexaiV1beta1 *vertexaiv1beta1.VertexaiV1beta1Client vpcaccessV1beta1 *vpcaccessv1beta1.VpcaccessV1beta1Client workflowsV1alpha1 *workflowsv1alpha1.WorkflowsV1alpha1Client + workstationsV1alpha1 *workstationsv1alpha1.WorkstationsV1alpha1Client workstationsV1beta1 *workstationsv1beta1.WorkstationsV1beta1Client } @@ -1010,6 +1013,11 @@ func (c *Clientset) WorkflowsV1alpha1() workflowsv1alpha1.WorkflowsV1alpha1Inter return c.workflowsV1alpha1 } +// WorkstationsV1alpha1 retrieves the WorkstationsV1alpha1Client +func (c *Clientset) WorkstationsV1alpha1() workstationsv1alpha1.WorkstationsV1alpha1Interface { + return c.workstationsV1alpha1 +} + // WorkstationsV1beta1 retrieves the WorkstationsV1beta1Client func (c *Clientset) WorkstationsV1beta1() workstationsv1beta1.WorkstationsV1beta1Interface { return c.workstationsV1beta1 @@ -1543,6 +1551,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.workstationsV1alpha1, err = workstationsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.workstationsV1beta1, err = workstationsv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -1689,6 +1701,7 @@ func New(c rest.Interface) *Clientset { cs.vertexaiV1beta1 = vertexaiv1beta1.New(c) cs.vpcaccessV1beta1 = vpcaccessv1beta1.New(c) cs.workflowsV1alpha1 = workflowsv1alpha1.New(c) + cs.workstationsV1alpha1 = workstationsv1alpha1.New(c) cs.workstationsV1beta1 = workstationsv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go b/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go index c446e6516b..f0bcc3c7fe 100644 --- a/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go @@ -265,6 +265,8 @@ import ( fakevpcaccessv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/vpcaccess/v1beta1/fake" workflowsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workflows/v1alpha1" fakeworkflowsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workflows/v1alpha1/fake" + workstationsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1" + fakeworkstationsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake" workstationsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1beta1" fakeworkstationsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" @@ -929,6 +931,11 @@ func (c *Clientset) WorkflowsV1alpha1() workflowsv1alpha1.WorkflowsV1alpha1Inter return &fakeworkflowsv1alpha1.FakeWorkflowsV1alpha1{Fake: &c.Fake} } +// WorkstationsV1alpha1 retrieves the WorkstationsV1alpha1Client +func (c *Clientset) WorkstationsV1alpha1() workstationsv1alpha1.WorkstationsV1alpha1Interface { + return &fakeworkstationsv1alpha1.FakeWorkstationsV1alpha1{Fake: &c.Fake} +} + // WorkstationsV1beta1 retrieves the WorkstationsV1beta1Client func (c *Clientset) WorkstationsV1beta1() workstationsv1beta1.WorkstationsV1beta1Interface { return &fakeworkstationsv1beta1.FakeWorkstationsV1beta1{Fake: &c.Fake} diff --git a/pkg/clients/generated/client/clientset/versioned/fake/register.go b/pkg/clients/generated/client/clientset/versioned/fake/register.go index 9d1dee405a..384f884653 100644 --- a/pkg/clients/generated/client/clientset/versioned/fake/register.go +++ b/pkg/clients/generated/client/clientset/versioned/fake/register.go @@ -143,6 +143,7 @@ import ( vertexaiv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/vertexai/v1beta1" vpcaccessv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/vpcaccess/v1beta1" workflowsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workflows/v1alpha1" + workstationsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1alpha1" workstationsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -276,6 +277,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ vertexaiv1beta1.AddToScheme, vpcaccessv1beta1.AddToScheme, workflowsv1alpha1.AddToScheme, + workstationsv1alpha1.AddToScheme, workstationsv1beta1.AddToScheme, } diff --git a/pkg/clients/generated/client/clientset/versioned/scheme/register.go b/pkg/clients/generated/client/clientset/versioned/scheme/register.go index cf610ff9d7..c590065c98 100644 --- a/pkg/clients/generated/client/clientset/versioned/scheme/register.go +++ b/pkg/clients/generated/client/clientset/versioned/scheme/register.go @@ -143,6 +143,7 @@ import ( vertexaiv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/vertexai/v1beta1" vpcaccessv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/vpcaccess/v1beta1" workflowsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workflows/v1alpha1" + workstationsv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1alpha1" workstationsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -276,6 +277,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ vertexaiv1beta1.AddToScheme, vpcaccessv1beta1.AddToScheme, workflowsv1alpha1.AddToScheme, + workstationsv1alpha1.AddToScheme, workstationsv1beta1.AddToScheme, } diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/doc.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/doc.go new file mode 100644 index 0000000000..d3dac805d0 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/doc.go @@ -0,0 +1,23 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/doc.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..dfbe79f9af --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/doc.go @@ -0,0 +1,23 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstationconfig.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstationconfig.go new file mode 100644 index 0000000000..f49895cb01 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstationconfig.go @@ -0,0 +1,144 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeWorkstationConfigs implements WorkstationConfigInterface +type FakeWorkstationConfigs struct { + Fake *FakeWorkstationsV1alpha1 + ns string +} + +var workstationconfigsResource = v1alpha1.SchemeGroupVersion.WithResource("workstationconfigs") + +var workstationconfigsKind = v1alpha1.SchemeGroupVersion.WithKind("WorkstationConfig") + +// Get takes name of the workstationConfig, and returns the corresponding workstationConfig object, and an error if there is any. +func (c *FakeWorkstationConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.WorkstationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(workstationconfigsResource, c.ns, name), &v1alpha1.WorkstationConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WorkstationConfig), err +} + +// List takes label and field selectors, and returns the list of WorkstationConfigs that match those selectors. +func (c *FakeWorkstationConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.WorkstationConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(workstationconfigsResource, workstationconfigsKind, c.ns, opts), &v1alpha1.WorkstationConfigList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.WorkstationConfigList{ListMeta: obj.(*v1alpha1.WorkstationConfigList).ListMeta} + for _, item := range obj.(*v1alpha1.WorkstationConfigList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested workstationConfigs. +func (c *FakeWorkstationConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(workstationconfigsResource, c.ns, opts)) + +} + +// Create takes the representation of a workstationConfig and creates it. Returns the server's representation of the workstationConfig, and an error, if there is any. +func (c *FakeWorkstationConfigs) Create(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.CreateOptions) (result *v1alpha1.WorkstationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(workstationconfigsResource, c.ns, workstationConfig), &v1alpha1.WorkstationConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WorkstationConfig), err +} + +// Update takes the representation of a workstationConfig and updates it. Returns the server's representation of the workstationConfig, and an error, if there is any. +func (c *FakeWorkstationConfigs) Update(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (result *v1alpha1.WorkstationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(workstationconfigsResource, c.ns, workstationConfig), &v1alpha1.WorkstationConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WorkstationConfig), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeWorkstationConfigs) UpdateStatus(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (*v1alpha1.WorkstationConfig, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(workstationconfigsResource, "status", c.ns, workstationConfig), &v1alpha1.WorkstationConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WorkstationConfig), err +} + +// Delete takes name of the workstationConfig and deletes it. Returns an error if one occurs. +func (c *FakeWorkstationConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(workstationconfigsResource, c.ns, name, opts), &v1alpha1.WorkstationConfig{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeWorkstationConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(workstationconfigsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.WorkstationConfigList{}) + return err +} + +// Patch applies the patch and returns the patched workstationConfig. +func (c *FakeWorkstationConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.WorkstationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(workstationconfigsResource, c.ns, name, pt, data, subresources...), &v1alpha1.WorkstationConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.WorkstationConfig), err +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstations_client.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstations_client.go new file mode 100644 index 0000000000..885bd37a20 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/fake/fake_workstations_client.go @@ -0,0 +1,43 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeWorkstationsV1alpha1 struct { + *testing.Fake +} + +func (c *FakeWorkstationsV1alpha1) WorkstationConfigs(namespace string) v1alpha1.WorkstationConfigInterface { + return &FakeWorkstationConfigs{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeWorkstationsV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/generated_expansion.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..9e39f40886 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/generated_expansion.go @@ -0,0 +1,24 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type WorkstationConfigExpansion interface{} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstationconfig.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstationconfig.go new file mode 100644 index 0000000000..29cbe93215 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstationconfig.go @@ -0,0 +1,198 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1alpha1" + scheme "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// WorkstationConfigsGetter has a method to return a WorkstationConfigInterface. +// A group's client should implement this interface. +type WorkstationConfigsGetter interface { + WorkstationConfigs(namespace string) WorkstationConfigInterface +} + +// WorkstationConfigInterface has methods to work with WorkstationConfig resources. +type WorkstationConfigInterface interface { + Create(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.CreateOptions) (*v1alpha1.WorkstationConfig, error) + Update(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (*v1alpha1.WorkstationConfig, error) + UpdateStatus(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (*v1alpha1.WorkstationConfig, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.WorkstationConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.WorkstationConfigList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.WorkstationConfig, err error) + WorkstationConfigExpansion +} + +// workstationConfigs implements WorkstationConfigInterface +type workstationConfigs struct { + client rest.Interface + ns string +} + +// newWorkstationConfigs returns a WorkstationConfigs +func newWorkstationConfigs(c *WorkstationsV1alpha1Client, namespace string) *workstationConfigs { + return &workstationConfigs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the workstationConfig, and returns the corresponding workstationConfig object, and an error if there is any. +func (c *workstationConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.WorkstationConfig, err error) { + result = &v1alpha1.WorkstationConfig{} + err = c.client.Get(). + Namespace(c.ns). + Resource("workstationconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of WorkstationConfigs that match those selectors. +func (c *workstationConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.WorkstationConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.WorkstationConfigList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("workstationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested workstationConfigs. +func (c *workstationConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("workstationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a workstationConfig and creates it. Returns the server's representation of the workstationConfig, and an error, if there is any. +func (c *workstationConfigs) Create(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.CreateOptions) (result *v1alpha1.WorkstationConfig, err error) { + result = &v1alpha1.WorkstationConfig{} + err = c.client.Post(). + Namespace(c.ns). + Resource("workstationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(workstationConfig). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a workstationConfig and updates it. Returns the server's representation of the workstationConfig, and an error, if there is any. +func (c *workstationConfigs) Update(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (result *v1alpha1.WorkstationConfig, err error) { + result = &v1alpha1.WorkstationConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("workstationconfigs"). + Name(workstationConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(workstationConfig). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *workstationConfigs) UpdateStatus(ctx context.Context, workstationConfig *v1alpha1.WorkstationConfig, opts v1.UpdateOptions) (result *v1alpha1.WorkstationConfig, err error) { + result = &v1alpha1.WorkstationConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("workstationconfigs"). + Name(workstationConfig.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(workstationConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the workstationConfig and deletes it. Returns an error if one occurs. +func (c *workstationConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("workstationconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *workstationConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("workstationconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched workstationConfig. +func (c *workstationConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.WorkstationConfig, err error) { + result = &v1alpha1.WorkstationConfig{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("workstationconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstations_client.go b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstations_client.go new file mode 100644 index 0000000000..885a30d85a --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/workstations/v1alpha1/workstations_client.go @@ -0,0 +1,110 @@ +// Copyright 2020 Google LLC +// +// 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. + +// *** DISCLAIMER *** +// Config Connector's go-client for CRDs is currently in ALPHA, which means +// that future versions of the go-client may include breaking changes. +// Please try it out and give us feedback! + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/workstations/v1alpha1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type WorkstationsV1alpha1Interface interface { + RESTClient() rest.Interface + WorkstationConfigsGetter +} + +// WorkstationsV1alpha1Client is used to interact with features provided by the workstations.cnrm.cloud.google.com group. +type WorkstationsV1alpha1Client struct { + restClient rest.Interface +} + +func (c *WorkstationsV1alpha1Client) WorkstationConfigs(namespace string) WorkstationConfigInterface { + return newWorkstationConfigs(c, namespace) +} + +// NewForConfig creates a new WorkstationsV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*WorkstationsV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new WorkstationsV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*WorkstationsV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &WorkstationsV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new WorkstationsV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *WorkstationsV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new WorkstationsV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *WorkstationsV1alpha1Client { + return &WorkstationsV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *WorkstationsV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/controller/direct/workstations/workstationcluster_mappings.go b/pkg/controller/direct/workstations/workstationcluster_mappings.go index 6cf03cd33e..afc0a459e9 100644 --- a/pkg/controller/direct/workstations/workstationcluster_mappings.go +++ b/pkg/controller/direct/workstations/workstationcluster_mappings.go @@ -38,7 +38,7 @@ func WorkstationClusterSpec_ToProto(mapCtx *direct.MapContext, in *krm.Workstati return out } -func WorkstationClusterAnnotations_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationClusterAnnotation) map[string]string { +func WorkstationClusterAnnotations_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationAnnotation) map[string]string { if in == nil { return nil } @@ -49,7 +49,7 @@ func WorkstationClusterAnnotations_ToProto(mapCtx *direct.MapContext, in []krm.W return out } -func WorkstationClusterLabels_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationClusterLabel) map[string]string { +func WorkstationClusterLabels_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationLabel) map[string]string { if in == nil { return nil } @@ -101,13 +101,13 @@ func WorkstationClusterSpec_FromProto(mapCtx *direct.MapContext, in *pb.Workstat return out } -func WorkstationClusterAnnotations_FromProto(mapCtx *direct.MapContext, in map[string]string) []krm.WorkstationClusterAnnotation { +func WorkstationClusterAnnotations_FromProto(mapCtx *direct.MapContext, in map[string]string) []krm.WorkstationAnnotation { if in == nil { return nil } - var out []krm.WorkstationClusterAnnotation + var out []krm.WorkstationAnnotation for k, v := range in { - out = append(out, krm.WorkstationClusterAnnotation{ + out = append(out, krm.WorkstationAnnotation{ Key: k, Value: v, }) @@ -115,13 +115,13 @@ func WorkstationClusterAnnotations_FromProto(mapCtx *direct.MapContext, in map[s return out } -func WorkstationClusterLabels_FromProto(mapCtx *direct.MapContext, in map[string]string) []krm.WorkstationClusterLabel { +func WorkstationClusterLabels_FromProto(mapCtx *direct.MapContext, in map[string]string) []krm.WorkstationLabel { if in == nil { return nil } - var out []krm.WorkstationClusterLabel + var out []krm.WorkstationLabel for k, v := range in { - out = append(out, krm.WorkstationClusterLabel{ + out = append(out, krm.WorkstationLabel{ Key: k, Value: v, }) @@ -205,20 +205,20 @@ func WorkstationClusterServiceAttachmentUri_FromProto(mapCtx *direct.MapContext, return direct.LazyPtr(in.GetServiceAttachmentUri()) } -func WorkstationClusterGCPConditions_FromProto(mapCtx *direct.MapContext, in []*status.Status) []krm.WorkstationClusterGCPCondition { +func WorkstationClusterGCPConditions_FromProto(mapCtx *direct.MapContext, in []*status.Status) []krm.WorkstationServiceGCPCondition { if in == nil { return nil } - var out []krm.WorkstationClusterGCPCondition + var out []krm.WorkstationServiceGCPCondition for _, c := range in { - out = append(out, krm.WorkstationClusterGCPCondition{ + out = append(out, krm.WorkstationServiceGCPCondition{ Code: direct.LazyPtr(c.Code), Message: direct.LazyPtr(c.Message), }) } return out } -func WorkstationClusterGCPConditions_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationClusterGCPCondition) []*status.Status { +func WorkstationClusterGCPConditions_ToProto(mapCtx *direct.MapContext, in []krm.WorkstationServiceGCPCondition) []*status.Status { if in == nil { return nil } diff --git a/pkg/gvks/supportedgvks/gvks_generated.go b/pkg/gvks/supportedgvks/gvks_generated.go index f2c166d6fb..fe43637761 100644 --- a/pkg/gvks/supportedgvks/gvks_generated.go +++ b/pkg/gvks/supportedgvks/gvks_generated.go @@ -4444,4 +4444,14 @@ var SupportedGVKs = map[schema.GroupVersionKind]GVKMetadata{ "cnrm.cloud.google.com/managed-by-kcc": "true", "cnrm.cloud.google.com/system": "true", }, + }, + { + Group: "workstations.cnrm.cloud.google.com", + Version: "v1alpha1", + Kind: "WorkstationConfig", + }: { + Labels: map[string]string{ + "cnrm.cloud.google.com/managed-by-kcc": "true", + "cnrm.cloud.google.com/system": "true", + }, }} diff --git a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/workstations/workstationcluster.md b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/workstations/workstationcluster.md index 5478efca0f..ea44647a35 100644 --- a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/workstations/workstationcluster.md +++ b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/workstations/workstationcluster.md @@ -176,7 +176,7 @@ subnetworkRef:

string

-

{% verbatim %}Key for the annotation.{% endverbatim %}

+

{% verbatim %}Key for the label.{% endverbatim %}

@@ -186,7 +186,7 @@ subnetworkRef:

string

-

{% verbatim %}Value for the annotation.{% endverbatim %}

+

{% verbatim %}Value for the label.{% endverbatim %}