From cf619d62f7db0aa83fb64433c7aad67e7bfd0967 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 29 Oct 2024 17:24:25 +0000 Subject: [PATCH 01/14] Define SecureSourceManagerRepository API --- .../v1alpha1/repository_reference.go | 179 +++++++++++ .../securesourcemanagerrepository_types.go | 104 +++++++ .../v1alpha1/types.generated.go | 193 ++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 289 ++++++++++++++++++ ...resourcemanager.cnrm.cloud.google.com.yaml | 125 ++++++++ 5 files changed, 890 insertions(+) create mode 100644 apis/securesourcemanager/v1alpha1/repository_reference.go create mode 100644 apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go create mode 100644 config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml diff --git a/apis/securesourcemanager/v1alpha1/repository_reference.go b/apis/securesourcemanager/v1alpha1/repository_reference.go new file mode 100644 index 0000000000..fbdba69f1e --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/repository_reference.go @@ -0,0 +1,179 @@ +// 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 = &SecureSourceManagerRepositoryRef{} + +// SecureSourceManagerRepositoryRef defines the resource reference to SecureSourceManagerRepository, which "External" field +// holds the GCP identifier for the KRM object. +type SecureSourceManagerRepositoryRef struct { + // A reference to an externally managed SecureSourceManagerRepository resource. + // Should be in the format "projects//locations//repositories/". + External string `json:"external,omitempty"` + + // The name of a SecureSourceManagerRepository resource. + Name string `json:"name,omitempty"` + + // The namespace of a SecureSourceManagerRepository resource. + Namespace string `json:"namespace,omitempty"` + + parent *SecureSourceManagerRepositoryParent +} + +// NormalizedExternal provision the "External" value for other resource that depends on SecureSourceManagerRepository. +// If the "External" is given in the other resource's spec.SecureSourceManagerRepositoryRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual SecureSourceManagerRepository object from the cluster. +func (r *SecureSourceManagerRepositoryRef) 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", SecureSourceManagerRepositoryGVK.Kind) + } + // From given External + if r.External != "" { + if _, _, err := parseSecureSourceManagerRepositoryExternal(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(SecureSourceManagerRepositoryGVK) + 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", SecureSourceManagerRepositoryGVK, 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 SecureSourceManagerRepositoryRef from the Config Connector SecureSourceManagerRepository object. +func NewSecureSourceManagerRepositoryRef(ctx context.Context, reader client.Reader, obj *SecureSourceManagerRepository) (*SecureSourceManagerRepositoryRef, error) { + id := &SecureSourceManagerRepositoryRef{} + + // 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 + id.parent = &SecureSourceManagerRepositoryParent{ProjectID: projectID, Location: 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 == "" { + id.External = asSecureSourceManagerRepositoryExternal(id.parent, resourceID) + return id, nil + } + + // Validate desired with actual + actualParent, actualResourceID, err := parseSecureSourceManagerRepositoryExternal(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 + id.parent = &SecureSourceManagerRepositoryParent{ProjectID: projectID, Location: location} + return id, nil +} + +func (r *SecureSourceManagerRepositoryRef) Parent() (*SecureSourceManagerRepositoryParent, error) { + if r.parent != nil { + return r.parent, nil + } + if r.External != "" { + parent, _, err := parseSecureSourceManagerRepositoryExternal(r.External) + if err != nil { + return nil, err + } + return parent, nil + } + return nil, fmt.Errorf("SecureSourceManagerRepositoryRef not initialized from `NewSecureSourceManagerRepositoryRef` or `NormalizedExternal`") +} + +type SecureSourceManagerRepositoryParent struct { + ProjectID string + Location string +} + +func (p *SecureSourceManagerRepositoryParent) String() string { + return "projects/" + p.ProjectID + "/locations/" + p.Location +} + +func asSecureSourceManagerRepositoryExternal(parent *SecureSourceManagerRepositoryParent, resourceID string) (external string) { + return parent.String() + "/repositories/" + resourceID +} + +func parseSecureSourceManagerRepositoryExternal(external string) (parent *SecureSourceManagerRepositoryParent, resourceID string, err error) { + external = strings.TrimPrefix(external, "/") + tokens := strings.Split(external, "/") + if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "repositories" { + return nil, "", fmt.Errorf("format of SecureSourceManagerRepository external=%q was not known (use projects//locations//repositories/)", external) + } + parent = &SecureSourceManagerRepositoryParent{ + ProjectID: tokens[1], + Location: tokens[3], + } + resourceID = tokens[5] + return parent, resourceID, nil +} diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go new file mode 100644 index 0000000000..f3d4205653 --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -0,0 +1,104 @@ +// 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 SecureSourceManagerRepositoryGVK = GroupVersion.WithKind("SecureSourceManagerRepository") + +// 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. + +// SecureSourceManagerRepositorySpec defines the desired state of SecureSourceManagerRepository +// +kcc:proto=google.cloud.securesourcemanager.v1.Repository +type SecureSourceManagerRepositorySpec struct { + /* Immutable. The Project that this resource belongs to. */ + // +required + ProjectRef *refs.ProjectRef `json:"projectRef"` + + /* Immutable. Location of the instance. */ + Location string `json:"location"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" + // Immutable. + // The SecureSourceManagerRepository name. If not given, the metadata.name will be used. + ResourceID *string `json:"resourceID,omitempty"` + + // Immutable. The name of the instance in which the repository is hosted, formatted as + // `projects/{project_number}/locations/{location_id}/instances/{instance_id}` + // +required + InstanceRef *SecureSourceManagerInstanceRef `json:"instanceRef,omitempty"` + + // Input only. Initial configurations for the repository. + InitialConfig *Repository_InitialConfig `json:"initialConfig,omitempty"` +} + +// SecureSourceManagerRepositoryStatus defines the config connector machine state of SecureSourceManagerRepository +type SecureSourceManagerRepositoryStatus 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 SecureSourceManagerRepository resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + // ObservedState is the state of the resource as most recently observed in GCP. + ObservedState *SecureSourceManagerRepositoryObservedState `json:"observedState,omitempty"` +} + +// SecureSourceManagerRepositoryObservedState is the state of the SecureSourceManagerRepository resource as most recently observed in GCP. +type SecureSourceManagerRepositoryObservedState struct { +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// TODO(user): make sure the pluralizaiton below is correct +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositorys +// +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'" + +// SecureSourceManagerRepository is the Schema for the SecureSourceManagerRepository API +// +k8s:openapi-gen=true +type SecureSourceManagerRepository struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +required + Spec SecureSourceManagerRepositorySpec `json:"spec,omitempty"` + Status SecureSourceManagerRepositoryStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// SecureSourceManagerRepositoryList contains a list of SecureSourceManagerRepository +type SecureSourceManagerRepositoryList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SecureSourceManagerRepository `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SecureSourceManagerRepository{}, &SecureSourceManagerRepositoryList{}) +} diff --git a/apis/securesourcemanager/v1alpha1/types.generated.go b/apis/securesourcemanager/v1alpha1/types.generated.go index 1c694feda5..1a337c862e 100644 --- a/apis/securesourcemanager/v1alpha1/types.generated.go +++ b/apis/securesourcemanager/v1alpha1/types.generated.go @@ -47,3 +47,196 @@ type Instance_PrivateConfig struct { // `projects/{project}/regions/{region}/serviceAttachments/{service_attachment}`. SSHServiceAttachment *string `json:"sshServiceAttachment,omitempty"` } + +// +kcc:proto=google.cloud.securesourcemanager.v1.Repository +type Repository struct { + // Optional. A unique identifier for a repository. The name should be of the + // format: + // `projects/{project}/locations/{location_id}/repositories/{repository_id}` + Name *string `json:"name,omitempty"` + + // Optional. Description of the repository, which cannot exceed 500 + // characters. + Description *string `json:"description,omitempty"` + + // Optional. The name of the instance in which the repository is hosted, + // formatted as + // `projects/{project_number}/locations/{location_id}/instances/{instance_id}` + // When creating repository via + // securesourcemanager.googleapis.com (Control Plane API), this field is used + // as input. When creating repository via *.sourcemanager.dev (Data Plane + // API), this field is output only. + Instance *string `json:"instance,omitempty"` + + // Output only. Unique identifier of the repository. + Uid *string `json:"uid,omitempty"` + + // Output only. Create timestamp. + CreateTime *string `json:"createTime,omitempty"` + + // Output only. Update timestamp. + UpdateTime *string `json:"updateTime,omitempty"` + + // Optional. This checksum is computed by the server based on the value of + // other fields, and may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + Etag *string `json:"etag,omitempty"` + + // Output only. URIs for the repository. + Uris *Repository_URIs `json:"uris,omitempty"` + + // Input only. Initial configurations for the repository. + InitialConfig *Repository_InitialConfig `json:"initialConfig,omitempty"` +} + +// +kcc:proto=google.cloud.securesourcemanager.v1.Repository.InitialConfig +type Repository_InitialConfig struct { + // Default branch name of the repository. + DefaultBranch *string `json:"defaultBranch,omitempty"` + + // List of gitignore template names user can choose from. + // Valid values: actionscript, ada, agda, android, + // anjuta, ansible, appcelerator-titanium, app-engine, archives, + // arch-linux-packages, atmel-studio, autotools, backup, bazaar, bazel, + // bitrix, bricx-cc, c, cake-php, calabash, cf-wheels, chef-cookbook, + // clojure, cloud9, c-make, code-igniter, code-kit, code-sniffer, + // common-lisp, composer, concrete5, coq, cordova, cpp, craft-cms, cuda, + // cvs, d, dart, dart-editor, delphi, diff, dm, dreamweaver, dropbox, + // drupal, drupal-7, eagle, eclipse, eiffel-studio, elisp, elixir, elm, + // emacs, ensime, epi-server, erlang, esp-idf, espresso, exercism, + // expression-engine, ext-js, fancy, finale, flex-builder, force-dot-com, + // fortran, fuel-php, gcov, git-book, gnome-shell-extension, go, godot, gpg, + // gradle, grails, gwt, haskell, hugo, iar-ewarm, idris, igor-pro, images, + // infor-cms, java, jboss, jboss-4, jboss-6, jdeveloper, jekyll, + // jenkins-home, jenv, jet-brains, jigsaw, joomla, julia, jupyter-notebooks, + // kate, kdevelop4, kentico, ki-cad, kohana, kotlin, lab-view, laravel, + // lazarus, leiningen, lemon-stand, libre-office, lilypond, linux, lithium, + // logtalk, lua, lyx, mac-os, magento, magento-1, magento-2, matlab, maven, + // mercurial, mercury, metals, meta-programming-system, meteor, + // microsoft-office, model-sim, momentics, mono-develop, nanoc, net-beans, + // nikola, nim, ninja, node, notepad-pp, nwjs, objective--c, ocaml, octave, + // opa, open-cart, openssl, oracle-forms, otto, packer, patch, perl, perl6, + // phalcon, phoenix, pimcore, play-framework, plone, prestashop, processing, + // psoc-creator, puppet, pure-script, putty, python, qooxdoo, qt, r, racket, + // rails, raku, red, redcar, redis, rhodes-rhomobile, ros, ruby, rust, sam, + // sass, sbt, scala, scheme, scons, scrivener, sdcc, seam-gen, sketch-up, + // slick-edit, smalltalk, snap, splunk, stata, stella, sublime-text, + // sugar-crm, svn, swift, symfony, symphony-cms, synopsys-vcs, tags, + // terraform, tex, text-mate, textpattern, think-php, tortoise-git, + // turbo-gears-2, typo3, umbraco, unity, unreal-engine, vagrant, vim, + // virtual-env, virtuoso, visual-studio, visual-studio-code, vue, vvvv, waf, + // web-methods, windows, word-press, xcode, xilinx, xilinx-ise, xojo, + // yeoman, yii, zend-framework, zephir. + Gitignores []string `json:"gitignores,omitempty"` + + // License template name user can choose from. + // Valid values: license-0bsd, license-389-exception, aal, abstyles, + // adobe-2006, adobe-glyph, adsl, afl-1-1, afl-1-2, afl-2-0, afl-2-1, + // afl-3-0, afmparse, agpl-1-0, agpl-1-0-only, agpl-1-0-or-later, + // agpl-3-0-only, agpl-3-0-or-later, aladdin, amdplpa, aml, ampas, antlr-pd, + // antlr-pd-fallback, apache-1-0, apache-1-1, apache-2-0, apafml, apl-1-0, + // apsl-1-0, apsl-1-1, apsl-1-2, apsl-2-0, artistic-1-0, artistic-1-0-cl8, + // artistic-1-0-perl, artistic-2-0, autoconf-exception-2-0, + // autoconf-exception-3-0, bahyph, barr, beerware, bison-exception-2-2, + // bittorrent-1-0, bittorrent-1-1, blessing, blueoak-1-0-0, + // bootloader-exception, borceux, bsd-1-clause, bsd-2-clause, + // bsd-2-clause-freebsd, bsd-2-clause-netbsd, bsd-2-clause-patent, + // bsd-2-clause-views, bsd-3-clause, bsd-3-clause-attribution, + // bsd-3-clause-clear, bsd-3-clause-lbnl, bsd-3-clause-modification, + // bsd-3-clause-no-nuclear-license, bsd-3-clause-no-nuclear-license-2014, + // bsd-3-clause-no-nuclear-warranty, bsd-3-clause-open-mpi, bsd-4-clause, + // bsd-4-clause-shortened, bsd-4-clause-uc, bsd-protection, bsd-source-code, + // bsl-1-0, busl-1-1, cal-1-0, cal-1-0-combined-work-exception, caldera, + // catosl-1-1, cc0-1-0, cc-by-1-0, cc-by-2-0, cc-by-3-0, cc-by-3-0-at, + // cc-by-3-0-us, cc-by-4-0, cc-by-nc-1-0, cc-by-nc-2-0, cc-by-nc-3-0, + // cc-by-nc-4-0, cc-by-nc-nd-1-0, cc-by-nc-nd-2-0, cc-by-nc-nd-3-0, + // cc-by-nc-nd-3-0-igo, cc-by-nc-nd-4-0, cc-by-nc-sa-1-0, cc-by-nc-sa-2-0, + // cc-by-nc-sa-3-0, cc-by-nc-sa-4-0, cc-by-nd-1-0, cc-by-nd-2-0, + // cc-by-nd-3-0, cc-by-nd-4-0, cc-by-sa-1-0, cc-by-sa-2-0, cc-by-sa-2-0-uk, + // cc-by-sa-2-1-jp, cc-by-sa-3-0, cc-by-sa-3-0-at, cc-by-sa-4-0, cc-pddc, + // cddl-1-0, cddl-1-1, cdla-permissive-1-0, cdla-sharing-1-0, cecill-1-0, + // cecill-1-1, cecill-2-0, cecill-2-1, cecill-b, cecill-c, cern-ohl-1-1, + // cern-ohl-1-2, cern-ohl-p-2-0, cern-ohl-s-2-0, cern-ohl-w-2-0, clartistic, + // classpath-exception-2-0, clisp-exception-2-0, cnri-jython, cnri-python, + // cnri-python-gpl-compatible, condor-1-1, copyleft-next-0-3-0, + // copyleft-next-0-3-1, cpal-1-0, cpl-1-0, cpol-1-02, crossword, + // crystal-stacker, cua-opl-1-0, cube, c-uda-1-0, curl, d-fsl-1-0, diffmark, + // digirule-foss-exception, doc, dotseqn, drl-1-0, dsdp, dvipdfm, ecl-1-0, + // ecl-2-0, ecos-exception-2-0, efl-1-0, efl-2-0, egenix, entessa, epics, + // epl-1-0, epl-2-0, erlpl-1-1, etalab-2-0, eu-datagrid, eupl-1-0, eupl-1-1, + // eupl-1-2, eurosym, fair, fawkes-runtime-exception, fltk-exception, + // font-exception-2-0, frameworx-1-0, freebsd-doc, freeimage, + // freertos-exception-2-0, fsfap, fsful, fsfullr, ftl, gcc-exception-2-0, + // gcc-exception-3-1, gd, gfdl-1-1-invariants-only, + // gfdl-1-1-invariants-or-later, gfdl-1-1-no-invariants-only, + // gfdl-1-1-no-invariants-or-later, gfdl-1-1-only, gfdl-1-1-or-later, + // gfdl-1-2-invariants-only, gfdl-1-2-invariants-or-later, + // gfdl-1-2-no-invariants-only, gfdl-1-2-no-invariants-or-later, + // gfdl-1-2-only, gfdl-1-2-or-later, gfdl-1-3-invariants-only, + // gfdl-1-3-invariants-or-later, gfdl-1-3-no-invariants-only, + // gfdl-1-3-no-invariants-or-later, gfdl-1-3-only, gfdl-1-3-or-later, + // giftware, gl2ps, glide, glulxe, glwtpl, gnu-javamail-exception, gnuplot, + // gpl-1-0-only, gpl-1-0-or-later, gpl-2-0-only, gpl-2-0-or-later, + // gpl-3-0-linking-exception, gpl-3-0-linking-source-exception, + // gpl-3-0-only, gpl-3-0-or-later, gpl-cc-1-0, gsoap-1-3b, haskell-report, + // hippocratic-2-1, hpnd, hpnd-sell-variant, htmltidy, + // i2p-gpl-java-exception, ibm-pibs, icu, ijg, image-magick, imatix, imlib2, + // info-zip, intel, intel-acpi, interbase-1-0, ipa, ipl-1-0, isc, + // jasper-2-0, jpnic, json, lal-1-2, lal-1-3, latex2e, leptonica, + // lgpl-2-0-only, lgpl-2-0-or-later, lgpl-2-1-only, lgpl-2-1-or-later, + // lgpl-3-0-linking-exception, lgpl-3-0-only, lgpl-3-0-or-later, lgpllr, + // libpng, libpng-2-0, libselinux-1-0, libtiff, libtool-exception, + // liliq-p-1-1, liliq-r-1-1, liliq-rplus-1-1, linux-openib, + // linux-syscall-note, llvm-exception, lpl-1-0, lpl-1-02, lppl-1-0, + // lppl-1-1, lppl-1-2, lppl-1-3a, lppl-1-3c, lzma-exception, make-index, + // mif-exception, miros, mit, mit-0, mit-advertising, mit-cmu, mit-enna, + // mit-feh, mit-modern-variant, mitnfa, mit-open-group, motosoto, mpich2, + // mpl-1-0, mpl-1-1, mpl-2-0, mpl-2-0-no-copyleft-exception, ms-pl, ms-rl, + // mtll, mulanpsl-1-0, mulanpsl-2-0, multics, mup, naist-2003, nasa-1-3, + // naumen, nbpl-1-0, ncgl-uk-2-0, ncsa, netcdf, net-snmp, newsletr, ngpl, + // nist-pd, nist-pd-fallback, nlod-1-0, nlpl, nokia, nokia-qt-exception-1-1, + // nosl, noweb, npl-1-0, npl-1-1, nposl-3-0, nrl, ntp, ntp-0, + // ocaml-lgpl-linking-exception, occt-exception-1-0, occt-pl, oclc-2-0, + // odbl-1-0, odc-by-1-0, ofl-1-0, ofl-1-0-no-rfn, ofl-1-0-rfn, ofl-1-1, + // ofl-1-1-no-rfn, ofl-1-1-rfn, ogc-1-0, ogdl-taiwan-1-0, ogl-canada-2-0, + // ogl-uk-1-0, ogl-uk-2-0, ogl-uk-3-0, ogtsl, oldap-1-1, oldap-1-2, + // oldap-1-3, oldap-1-4, oldap-2-0, oldap-2-0-1, oldap-2-1, oldap-2-2, + // oldap-2-2-1, oldap-2-2-2, oldap-2-3, oldap-2-4, oldap-2-7, oml, + // openjdk-assembly-exception-1-0, openssl, openvpn-openssl-exception, + // opl-1-0, oset-pl-2-1, osl-1-0, osl-1-1, osl-2-0, osl-2-1, osl-3-0, + // o-uda-1-0, parity-6-0-0, parity-7-0-0, pddl-1-0, php-3-0, php-3-01, + // plexus, polyform-noncommercial-1-0-0, polyform-small-business-1-0-0, + // postgresql, psf-2-0, psfrag, ps-or-pdf-font-exception-20170817, psutils, + // python-2-0, qhull, qpl-1-0, qt-gpl-exception-1-0, qt-lgpl-exception-1-1, + // qwt-exception-1-0, rdisc, rhecos-1-1, rpl-1-1, rpsl-1-0, rsa-md, rscpl, + // ruby, saxpath, sax-pd, scea, sendmail, sendmail-8-23, sgi-b-1-0, + // sgi-b-1-1, sgi-b-2-0, shl-0-51, shl-2-0, shl-2-1, simpl-2-0, sissl, + // sissl-1-2, sleepycat, smlnj, smppl, snia, spencer-86, spencer-94, + // spencer-99, spl-1-0, ssh-openssh, ssh-short, sspl-1-0, sugarcrm-1-1-3, + // swift-exception, swl, tapr-ohl-1-0, tcl, tcp-wrappers, tmate, torque-1-1, + // tosl, tu-berlin-1-0, tu-berlin-2-0, u-boot-exception-2-0, ucl-1-0, + // unicode-dfs-2015, unicode-dfs-2016, unicode-tou, + // universal-foss-exception-1-0, unlicense, upl-1-0, vim, vostrom, vsl-1-0, + // w3c, w3c-19980720, w3c-20150513, watcom-1-0, wsuipa, wtfpl, + // wxwindows-exception-3-1, x11, xerox, xfree86-1-1, xinetd, xnet, xpp, + // xskat, ypl-1-0, ypl-1-1, zed, zend-2-0, zimbra-1-3, zimbra-1-4, zlib, + // zlib-acknowledgement, zpl-1-1, zpl-2-0, zpl-2-1. + License *string `json:"license,omitempty"` + + // README template name. + // Valid template name(s) are: default. + Readme *string `json:"readme,omitempty"` +} + +// +kcc:proto=google.cloud.securesourcemanager.v1.Repository.URIs +type Repository_URIs struct { + // Output only. HTML is the URI for user to view the repository in a + // browser. + HTML *string `json:"html,omitempty"` + + // Output only. git_https is the git HTTPS URI for git operations. + GitHTTPS *string `json:"gitHTTPS,omitempty"` + + // Output only. API is the URI for API access. + Api *string `json:"api,omitempty"` +} diff --git a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index 7168d14178..38fdb4a12f 100644 --- a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -94,6 +94,131 @@ func (in *Instance_PrivateConfig) DeepCopy() *Instance_PrivateConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Repository) DeepCopyInto(out *Repository) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Instance != nil { + in, out := &in.Instance, &out.Instance + *out = new(string) + **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.Etag != nil { + in, out := &in.Etag, &out.Etag + *out = new(string) + **out = **in + } + if in.Uris != nil { + in, out := &in.Uris, &out.Uris + *out = new(Repository_URIs) + (*in).DeepCopyInto(*out) + } + if in.InitialConfig != nil { + in, out := &in.InitialConfig, &out.InitialConfig + *out = new(Repository_InitialConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Repository. +func (in *Repository) DeepCopy() *Repository { + if in == nil { + return nil + } + out := new(Repository) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Repository_InitialConfig) DeepCopyInto(out *Repository_InitialConfig) { + *out = *in + if in.DefaultBranch != nil { + in, out := &in.DefaultBranch, &out.DefaultBranch + *out = new(string) + **out = **in + } + if in.Gitignores != nil { + in, out := &in.Gitignores, &out.Gitignores + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.License != nil { + in, out := &in.License, &out.License + *out = new(string) + **out = **in + } + if in.Readme != nil { + in, out := &in.Readme, &out.Readme + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Repository_InitialConfig. +func (in *Repository_InitialConfig) DeepCopy() *Repository_InitialConfig { + if in == nil { + return nil + } + out := new(Repository_InitialConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Repository_URIs) DeepCopyInto(out *Repository_URIs) { + *out = *in + if in.HTML != nil { + in, out := &in.HTML, &out.HTML + *out = new(string) + **out = **in + } + if in.GitHTTPS != nil { + in, out := &in.GitHTTPS, &out.GitHTTPS + *out = new(string) + **out = **in + } + if in.Api != nil { + in, out := &in.Api, &out.Api + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Repository_URIs. +func (in *Repository_URIs) DeepCopy() *Repository_URIs { + if in == nil { + return nil + } + out := new(Repository_URIs) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerInstance) DeepCopyInto(out *SecureSourceManagerInstance) { *out = *in @@ -262,3 +387,167 @@ func (in *SecureSourceManagerInstanceStatus) DeepCopy() *SecureSourceManagerInst in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepository) DeepCopyInto(out *SecureSourceManagerRepository) { + *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 SecureSourceManagerRepository. +func (in *SecureSourceManagerRepository) DeepCopy() *SecureSourceManagerRepository { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepository) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerRepository) 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 *SecureSourceManagerRepositoryList) DeepCopyInto(out *SecureSourceManagerRepositoryList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SecureSourceManagerRepository, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryList. +func (in *SecureSourceManagerRepositoryList) DeepCopy() *SecureSourceManagerRepositoryList { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerRepositoryList) 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 *SecureSourceManagerRepositoryObservedState) DeepCopyInto(out *SecureSourceManagerRepositoryObservedState) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryObservedState. +func (in *SecureSourceManagerRepositoryObservedState) DeepCopy() *SecureSourceManagerRepositoryObservedState { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepositoryParent) DeepCopyInto(out *SecureSourceManagerRepositoryParent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryParent. +func (in *SecureSourceManagerRepositoryParent) DeepCopy() *SecureSourceManagerRepositoryParent { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryParent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepositoryRef) DeepCopyInto(out *SecureSourceManagerRepositoryRef) { + *out = *in + if in.parent != nil { + in, out := &in.parent, &out.parent + *out = new(SecureSourceManagerRepositoryParent) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryRef. +func (in *SecureSourceManagerRepositoryRef) DeepCopy() *SecureSourceManagerRepositoryRef { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepositorySpec) DeepCopyInto(out *SecureSourceManagerRepositorySpec) { + *out = *in + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositorySpec. +func (in *SecureSourceManagerRepositorySpec) DeepCopy() *SecureSourceManagerRepositorySpec { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositorySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepositoryStatus) DeepCopyInto(out *SecureSourceManagerRepositoryStatus) { + *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(SecureSourceManagerRepositoryObservedState) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryStatus. +func (in *SecureSourceManagerRepositoryStatus) DeepCopy() *SecureSourceManagerRepositoryStatus { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml new file mode 100644 index 0000000000..99f08d9de1 --- /dev/null +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml @@ -0,0 +1,125 @@ +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: securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com +spec: + group: securesourcemanager.cnrm.cloud.google.com + names: + categories: + - gcp + kind: SecureSourceManagerRepository + listKind: SecureSourceManagerRepositoryList + plural: securesourcemanagerrepositories + shortNames: + - gcpsecuresourcemanagerrepository + - gcpsecuresourcemanagerrepositorys + singular: securesourcemanagerrepository + 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: SecureSourceManagerRepository is the Schema for the SecureSourceManagerRepository + 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: SecureSourceManagerRepositorySpec defines the desired state + of SecureSourceManagerRepository + properties: + resourceID: + description: Immutable. The SecureSourceManagerRepository name. If + not given, the metadata.name will be used. + type: string + x-kubernetes-validations: + - message: ResourceID field is immutable + rule: self == oldSelf + type: object + status: + description: SecureSourceManagerRepositoryStatus defines the config connector + machine state of SecureSourceManagerRepository + 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 SecureSourceManagerRepository + 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. + type: object + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} From cfe2a81f710cdb6f4cad77e092c039a525f43c76 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 29 Oct 2024 17:39:50 +0000 Subject: [PATCH 02/14] run make pr --- .../v1alpha1/zz_generated.deepcopy.go | 15 ++ ...resourcemanager.cnrm.cloud.google.com.yaml | 210 ++++++++++++++++++ .../securesourcemanager/v1alpha1/register.go | 6 + .../securesourcemanagerrepository_types.go | 126 +++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 177 +++++++++++++++ .../fake/fake_securesourcemanager_client.go | 4 + .../fake_securesourcemanagerrepository.go | 144 ++++++++++++ .../v1alpha1/generated_expansion.go | 2 + .../v1alpha1/securesourcemanager_client.go | 5 + .../v1alpha1/securesourcemanagerrepository.go | 198 +++++++++++++++++ pkg/gvks/supportedgvks/gvks_generated.go | 10 + 11 files changed, 897 insertions(+) create mode 100644 pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerrepository.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerrepository.go diff --git a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index 38fdb4a12f..faee2ed248 100644 --- a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -500,11 +500,26 @@ func (in *SecureSourceManagerRepositoryRef) DeepCopy() *SecureSourceManagerRepos // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerRepositorySpec) DeepCopyInto(out *SecureSourceManagerRepositorySpec) { *out = *in + if in.ProjectRef != nil { + in, out := &in.ProjectRef, &out.ProjectRef + *out = new(v1beta1.ProjectRef) + **out = **in + } if in.ResourceID != nil { in, out := &in.ResourceID, &out.ResourceID *out = new(string) **out = **in } + if in.InstanceRef != nil { + in, out := &in.InstanceRef, &out.InstanceRef + *out = new(SecureSourceManagerInstanceRef) + **out = **in + } + if in.InitialConfig != nil { + in, out := &in.InitialConfig, &out.InitialConfig + *out = new(Repository_InitialConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositorySpec. diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml index 99f08d9de1..4ce32f3d47 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml @@ -61,6 +61,212 @@ spec: description: SecureSourceManagerRepositorySpec defines the desired state of SecureSourceManagerRepository properties: + initialConfig: + description: Input only. Initial configurations for the repository. + properties: + defaultBranch: + description: Default branch name of the repository. + type: string + gitignores: + description: 'List of gitignore template names user can choose + from. Valid values: actionscript, ada, agda, android, anjuta, + ansible, appcelerator-titanium, app-engine, archives, arch-linux-packages, + atmel-studio, autotools, backup, bazaar, bazel, bitrix, bricx-cc, + c, cake-php, calabash, cf-wheels, chef-cookbook, clojure, cloud9, + c-make, code-igniter, code-kit, code-sniffer, common-lisp, composer, + concrete5, coq, cordova, cpp, craft-cms, cuda, cvs, d, dart, + dart-editor, delphi, diff, dm, dreamweaver, dropbox, drupal, + drupal-7, eagle, eclipse, eiffel-studio, elisp, elixir, elm, + emacs, ensime, epi-server, erlang, esp-idf, espresso, exercism, + expression-engine, ext-js, fancy, finale, flex-builder, force-dot-com, + fortran, fuel-php, gcov, git-book, gnome-shell-extension, go, + godot, gpg, gradle, grails, gwt, haskell, hugo, iar-ewarm, idris, + igor-pro, images, infor-cms, java, jboss, jboss-4, jboss-6, + jdeveloper, jekyll, jenkins-home, jenv, jet-brains, jigsaw, + joomla, julia, jupyter-notebooks, kate, kdevelop4, kentico, + ki-cad, kohana, kotlin, lab-view, laravel, lazarus, leiningen, + lemon-stand, libre-office, lilypond, linux, lithium, logtalk, + lua, lyx, mac-os, magento, magento-1, magento-2, matlab, maven, + mercurial, mercury, metals, meta-programming-system, meteor, + microsoft-office, model-sim, momentics, mono-develop, nanoc, + net-beans, nikola, nim, ninja, node, notepad-pp, nwjs, objective--c, + ocaml, octave, opa, open-cart, openssl, oracle-forms, otto, + packer, patch, perl, perl6, phalcon, phoenix, pimcore, play-framework, + plone, prestashop, processing, psoc-creator, puppet, pure-script, + putty, python, qooxdoo, qt, r, racket, rails, raku, red, redcar, + redis, rhodes-rhomobile, ros, ruby, rust, sam, sass, sbt, scala, + scheme, scons, scrivener, sdcc, seam-gen, sketch-up, slick-edit, + smalltalk, snap, splunk, stata, stella, sublime-text, sugar-crm, + svn, swift, symfony, symphony-cms, synopsys-vcs, tags, terraform, + tex, text-mate, textpattern, think-php, tortoise-git, turbo-gears-2, + typo3, umbraco, unity, unreal-engine, vagrant, vim, virtual-env, + virtuoso, visual-studio, visual-studio-code, vue, vvvv, waf, + web-methods, windows, word-press, xcode, xilinx, xilinx-ise, + xojo, yeoman, yii, zend-framework, zephir.' + items: + type: string + type: array + license: + description: 'License template name user can choose from. Valid + values: license-0bsd, license-389-exception, aal, abstyles, + adobe-2006, adobe-glyph, adsl, afl-1-1, afl-1-2, afl-2-0, afl-2-1, + afl-3-0, afmparse, agpl-1-0, agpl-1-0-only, agpl-1-0-or-later, + agpl-3-0-only, agpl-3-0-or-later, aladdin, amdplpa, aml, ampas, + antlr-pd, antlr-pd-fallback, apache-1-0, apache-1-1, apache-2-0, + apafml, apl-1-0, apsl-1-0, apsl-1-1, apsl-1-2, apsl-2-0, artistic-1-0, + artistic-1-0-cl8, artistic-1-0-perl, artistic-2-0, autoconf-exception-2-0, + autoconf-exception-3-0, bahyph, barr, beerware, bison-exception-2-2, + bittorrent-1-0, bittorrent-1-1, blessing, blueoak-1-0-0, bootloader-exception, + borceux, bsd-1-clause, bsd-2-clause, bsd-2-clause-freebsd, bsd-2-clause-netbsd, + bsd-2-clause-patent, bsd-2-clause-views, bsd-3-clause, bsd-3-clause-attribution, + bsd-3-clause-clear, bsd-3-clause-lbnl, bsd-3-clause-modification, + bsd-3-clause-no-nuclear-license, bsd-3-clause-no-nuclear-license-2014, + bsd-3-clause-no-nuclear-warranty, bsd-3-clause-open-mpi, bsd-4-clause, + bsd-4-clause-shortened, bsd-4-clause-uc, bsd-protection, bsd-source-code, + bsl-1-0, busl-1-1, cal-1-0, cal-1-0-combined-work-exception, + caldera, catosl-1-1, cc0-1-0, cc-by-1-0, cc-by-2-0, cc-by-3-0, + cc-by-3-0-at, cc-by-3-0-us, cc-by-4-0, cc-by-nc-1-0, cc-by-nc-2-0, + cc-by-nc-3-0, cc-by-nc-4-0, cc-by-nc-nd-1-0, cc-by-nc-nd-2-0, + cc-by-nc-nd-3-0, cc-by-nc-nd-3-0-igo, cc-by-nc-nd-4-0, cc-by-nc-sa-1-0, + cc-by-nc-sa-2-0, cc-by-nc-sa-3-0, cc-by-nc-sa-4-0, cc-by-nd-1-0, + cc-by-nd-2-0, cc-by-nd-3-0, cc-by-nd-4-0, cc-by-sa-1-0, cc-by-sa-2-0, + cc-by-sa-2-0-uk, cc-by-sa-2-1-jp, cc-by-sa-3-0, cc-by-sa-3-0-at, + cc-by-sa-4-0, cc-pddc, cddl-1-0, cddl-1-1, cdla-permissive-1-0, + cdla-sharing-1-0, cecill-1-0, cecill-1-1, cecill-2-0, cecill-2-1, + cecill-b, cecill-c, cern-ohl-1-1, cern-ohl-1-2, cern-ohl-p-2-0, + cern-ohl-s-2-0, cern-ohl-w-2-0, clartistic, classpath-exception-2-0, + clisp-exception-2-0, cnri-jython, cnri-python, cnri-python-gpl-compatible, + condor-1-1, copyleft-next-0-3-0, copyleft-next-0-3-1, cpal-1-0, + cpl-1-0, cpol-1-02, crossword, crystal-stacker, cua-opl-1-0, + cube, c-uda-1-0, curl, d-fsl-1-0, diffmark, digirule-foss-exception, + doc, dotseqn, drl-1-0, dsdp, dvipdfm, ecl-1-0, ecl-2-0, ecos-exception-2-0, + efl-1-0, efl-2-0, egenix, entessa, epics, epl-1-0, epl-2-0, + erlpl-1-1, etalab-2-0, eu-datagrid, eupl-1-0, eupl-1-1, eupl-1-2, + eurosym, fair, fawkes-runtime-exception, fltk-exception, font-exception-2-0, + frameworx-1-0, freebsd-doc, freeimage, freertos-exception-2-0, + fsfap, fsful, fsfullr, ftl, gcc-exception-2-0, gcc-exception-3-1, + gd, gfdl-1-1-invariants-only, gfdl-1-1-invariants-or-later, + gfdl-1-1-no-invariants-only, gfdl-1-1-no-invariants-or-later, + gfdl-1-1-only, gfdl-1-1-or-later, gfdl-1-2-invariants-only, + gfdl-1-2-invariants-or-later, gfdl-1-2-no-invariants-only, gfdl-1-2-no-invariants-or-later, + gfdl-1-2-only, gfdl-1-2-or-later, gfdl-1-3-invariants-only, + gfdl-1-3-invariants-or-later, gfdl-1-3-no-invariants-only, gfdl-1-3-no-invariants-or-later, + gfdl-1-3-only, gfdl-1-3-or-later, giftware, gl2ps, glide, glulxe, + glwtpl, gnu-javamail-exception, gnuplot, gpl-1-0-only, gpl-1-0-or-later, + gpl-2-0-only, gpl-2-0-or-later, gpl-3-0-linking-exception, gpl-3-0-linking-source-exception, + gpl-3-0-only, gpl-3-0-or-later, gpl-cc-1-0, gsoap-1-3b, haskell-report, + hippocratic-2-1, hpnd, hpnd-sell-variant, htmltidy, i2p-gpl-java-exception, + ibm-pibs, icu, ijg, image-magick, imatix, imlib2, info-zip, + intel, intel-acpi, interbase-1-0, ipa, ipl-1-0, isc, jasper-2-0, + jpnic, json, lal-1-2, lal-1-3, latex2e, leptonica, lgpl-2-0-only, + lgpl-2-0-or-later, lgpl-2-1-only, lgpl-2-1-or-later, lgpl-3-0-linking-exception, + lgpl-3-0-only, lgpl-3-0-or-later, lgpllr, libpng, libpng-2-0, + libselinux-1-0, libtiff, libtool-exception, liliq-p-1-1, liliq-r-1-1, + liliq-rplus-1-1, linux-openib, linux-syscall-note, llvm-exception, + lpl-1-0, lpl-1-02, lppl-1-0, lppl-1-1, lppl-1-2, lppl-1-3a, + lppl-1-3c, lzma-exception, make-index, mif-exception, miros, + mit, mit-0, mit-advertising, mit-cmu, mit-enna, mit-feh, mit-modern-variant, + mitnfa, mit-open-group, motosoto, mpich2, mpl-1-0, mpl-1-1, + mpl-2-0, mpl-2-0-no-copyleft-exception, ms-pl, ms-rl, mtll, + mulanpsl-1-0, mulanpsl-2-0, multics, mup, naist-2003, nasa-1-3, + naumen, nbpl-1-0, ncgl-uk-2-0, ncsa, netcdf, net-snmp, newsletr, + ngpl, nist-pd, nist-pd-fallback, nlod-1-0, nlpl, nokia, nokia-qt-exception-1-1, + nosl, noweb, npl-1-0, npl-1-1, nposl-3-0, nrl, ntp, ntp-0, ocaml-lgpl-linking-exception, + occt-exception-1-0, occt-pl, oclc-2-0, odbl-1-0, odc-by-1-0, + ofl-1-0, ofl-1-0-no-rfn, ofl-1-0-rfn, ofl-1-1, ofl-1-1-no-rfn, + ofl-1-1-rfn, ogc-1-0, ogdl-taiwan-1-0, ogl-canada-2-0, ogl-uk-1-0, + ogl-uk-2-0, ogl-uk-3-0, ogtsl, oldap-1-1, oldap-1-2, oldap-1-3, + oldap-1-4, oldap-2-0, oldap-2-0-1, oldap-2-1, oldap-2-2, oldap-2-2-1, + oldap-2-2-2, oldap-2-3, oldap-2-4, oldap-2-7, oml, openjdk-assembly-exception-1-0, + openssl, openvpn-openssl-exception, opl-1-0, oset-pl-2-1, osl-1-0, + osl-1-1, osl-2-0, osl-2-1, osl-3-0, o-uda-1-0, parity-6-0-0, + parity-7-0-0, pddl-1-0, php-3-0, php-3-01, plexus, polyform-noncommercial-1-0-0, + polyform-small-business-1-0-0, postgresql, psf-2-0, psfrag, + ps-or-pdf-font-exception-20170817, psutils, python-2-0, qhull, + qpl-1-0, qt-gpl-exception-1-0, qt-lgpl-exception-1-1, qwt-exception-1-0, + rdisc, rhecos-1-1, rpl-1-1, rpsl-1-0, rsa-md, rscpl, ruby, saxpath, + sax-pd, scea, sendmail, sendmail-8-23, sgi-b-1-0, sgi-b-1-1, + sgi-b-2-0, shl-0-51, shl-2-0, shl-2-1, simpl-2-0, sissl, sissl-1-2, + sleepycat, smlnj, smppl, snia, spencer-86, spencer-94, spencer-99, + spl-1-0, ssh-openssh, ssh-short, sspl-1-0, sugarcrm-1-1-3, swift-exception, + swl, tapr-ohl-1-0, tcl, tcp-wrappers, tmate, torque-1-1, tosl, + tu-berlin-1-0, tu-berlin-2-0, u-boot-exception-2-0, ucl-1-0, + unicode-dfs-2015, unicode-dfs-2016, unicode-tou, universal-foss-exception-1-0, + unlicense, upl-1-0, vim, vostrom, vsl-1-0, w3c, w3c-19980720, + w3c-20150513, watcom-1-0, wsuipa, wtfpl, wxwindows-exception-3-1, + x11, xerox, xfree86-1-1, xinetd, xnet, xpp, xskat, ypl-1-0, + ypl-1-1, zed, zend-2-0, zimbra-1-3, zimbra-1-4, zlib, zlib-acknowledgement, + zpl-1-1, zpl-2-0, zpl-2-1.' + type: string + readme: + description: 'README template name. Valid template name(s) are: + default.' + type: string + type: object + instanceRef: + description: Immutable. The name of the instance in which the repository + is hosted, formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: A reference to an externally managed SecureSourceManagerInstance + resource. Should be in the format "projects//locations//instances/". + type: string + name: + description: The name of a SecureSourceManagerInstance resource. + type: string + namespace: + description: The namespace of a SecureSourceManagerInstance resource. + type: string + type: object + location: + description: Immutable. Location of the instance. + type: string + 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 resourceID: description: Immutable. The SecureSourceManagerRepository name. If not given, the metadata.name will be used. @@ -68,6 +274,10 @@ spec: x-kubernetes-validations: - message: ResourceID field is immutable rule: self == oldSelf + required: + - instanceRef + - location + - projectRef type: object status: description: SecureSourceManagerRepositoryStatus defines the config connector diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go index 4a6331cf28..2df32d10f3 100644 --- a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go @@ -59,5 +59,11 @@ var ( Kind: reflect.TypeOf(SecureSourceManagerInstance{}).Name(), } + SecureSourceManagerRepositoryGVK = schema.GroupVersionKind{ + Group: SchemeGroupVersion.Group, + Version: SchemeGroupVersion.Version, + Kind: reflect.TypeOf(SecureSourceManagerRepository{}).Name(), + } + securesourcemanagerAPIVersion = SchemeGroupVersion.String() ) diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go new file mode 100644 index 0000000000..f46a0d1020 --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -0,0 +1,126 @@ +// 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 RepositoryInitialConfig struct { + /* Default branch name of the repository. */ + // +optional + DefaultBranch *string `json:"defaultBranch,omitempty"` + + /* List of gitignore template names user can choose from. Valid values: actionscript, ada, agda, android, anjuta, ansible, appcelerator-titanium, app-engine, archives, arch-linux-packages, atmel-studio, autotools, backup, bazaar, bazel, bitrix, bricx-cc, c, cake-php, calabash, cf-wheels, chef-cookbook, clojure, cloud9, c-make, code-igniter, code-kit, code-sniffer, common-lisp, composer, concrete5, coq, cordova, cpp, craft-cms, cuda, cvs, d, dart, dart-editor, delphi, diff, dm, dreamweaver, dropbox, drupal, drupal-7, eagle, eclipse, eiffel-studio, elisp, elixir, elm, emacs, ensime, epi-server, erlang, esp-idf, espresso, exercism, expression-engine, ext-js, fancy, finale, flex-builder, force-dot-com, fortran, fuel-php, gcov, git-book, gnome-shell-extension, go, godot, gpg, gradle, grails, gwt, haskell, hugo, iar-ewarm, idris, igor-pro, images, infor-cms, java, jboss, jboss-4, jboss-6, jdeveloper, jekyll, jenkins-home, jenv, jet-brains, jigsaw, joomla, julia, jupyter-notebooks, kate, kdevelop4, kentico, ki-cad, kohana, kotlin, lab-view, laravel, lazarus, leiningen, lemon-stand, libre-office, lilypond, linux, lithium, logtalk, lua, lyx, mac-os, magento, magento-1, magento-2, matlab, maven, mercurial, mercury, metals, meta-programming-system, meteor, microsoft-office, model-sim, momentics, mono-develop, nanoc, net-beans, nikola, nim, ninja, node, notepad-pp, nwjs, objective--c, ocaml, octave, opa, open-cart, openssl, oracle-forms, otto, packer, patch, perl, perl6, phalcon, phoenix, pimcore, play-framework, plone, prestashop, processing, psoc-creator, puppet, pure-script, putty, python, qooxdoo, qt, r, racket, rails, raku, red, redcar, redis, rhodes-rhomobile, ros, ruby, rust, sam, sass, sbt, scala, scheme, scons, scrivener, sdcc, seam-gen, sketch-up, slick-edit, smalltalk, snap, splunk, stata, stella, sublime-text, sugar-crm, svn, swift, symfony, symphony-cms, synopsys-vcs, tags, terraform, tex, text-mate, textpattern, think-php, tortoise-git, turbo-gears-2, typo3, umbraco, unity, unreal-engine, vagrant, vim, virtual-env, virtuoso, visual-studio, visual-studio-code, vue, vvvv, waf, web-methods, windows, word-press, xcode, xilinx, xilinx-ise, xojo, yeoman, yii, zend-framework, zephir. */ + // +optional + Gitignores []string `json:"gitignores,omitempty"` + + /* License template name user can choose from. Valid values: license-0bsd, license-389-exception, aal, abstyles, adobe-2006, adobe-glyph, adsl, afl-1-1, afl-1-2, afl-2-0, afl-2-1, afl-3-0, afmparse, agpl-1-0, agpl-1-0-only, agpl-1-0-or-later, agpl-3-0-only, agpl-3-0-or-later, aladdin, amdplpa, aml, ampas, antlr-pd, antlr-pd-fallback, apache-1-0, apache-1-1, apache-2-0, apafml, apl-1-0, apsl-1-0, apsl-1-1, apsl-1-2, apsl-2-0, artistic-1-0, artistic-1-0-cl8, artistic-1-0-perl, artistic-2-0, autoconf-exception-2-0, autoconf-exception-3-0, bahyph, barr, beerware, bison-exception-2-2, bittorrent-1-0, bittorrent-1-1, blessing, blueoak-1-0-0, bootloader-exception, borceux, bsd-1-clause, bsd-2-clause, bsd-2-clause-freebsd, bsd-2-clause-netbsd, bsd-2-clause-patent, bsd-2-clause-views, bsd-3-clause, bsd-3-clause-attribution, bsd-3-clause-clear, bsd-3-clause-lbnl, bsd-3-clause-modification, bsd-3-clause-no-nuclear-license, bsd-3-clause-no-nuclear-license-2014, bsd-3-clause-no-nuclear-warranty, bsd-3-clause-open-mpi, bsd-4-clause, bsd-4-clause-shortened, bsd-4-clause-uc, bsd-protection, bsd-source-code, bsl-1-0, busl-1-1, cal-1-0, cal-1-0-combined-work-exception, caldera, catosl-1-1, cc0-1-0, cc-by-1-0, cc-by-2-0, cc-by-3-0, cc-by-3-0-at, cc-by-3-0-us, cc-by-4-0, cc-by-nc-1-0, cc-by-nc-2-0, cc-by-nc-3-0, cc-by-nc-4-0, cc-by-nc-nd-1-0, cc-by-nc-nd-2-0, cc-by-nc-nd-3-0, cc-by-nc-nd-3-0-igo, cc-by-nc-nd-4-0, cc-by-nc-sa-1-0, cc-by-nc-sa-2-0, cc-by-nc-sa-3-0, cc-by-nc-sa-4-0, cc-by-nd-1-0, cc-by-nd-2-0, cc-by-nd-3-0, cc-by-nd-4-0, cc-by-sa-1-0, cc-by-sa-2-0, cc-by-sa-2-0-uk, cc-by-sa-2-1-jp, cc-by-sa-3-0, cc-by-sa-3-0-at, cc-by-sa-4-0, cc-pddc, cddl-1-0, cddl-1-1, cdla-permissive-1-0, cdla-sharing-1-0, cecill-1-0, cecill-1-1, cecill-2-0, cecill-2-1, cecill-b, cecill-c, cern-ohl-1-1, cern-ohl-1-2, cern-ohl-p-2-0, cern-ohl-s-2-0, cern-ohl-w-2-0, clartistic, classpath-exception-2-0, clisp-exception-2-0, cnri-jython, cnri-python, cnri-python-gpl-compatible, condor-1-1, copyleft-next-0-3-0, copyleft-next-0-3-1, cpal-1-0, cpl-1-0, cpol-1-02, crossword, crystal-stacker, cua-opl-1-0, cube, c-uda-1-0, curl, d-fsl-1-0, diffmark, digirule-foss-exception, doc, dotseqn, drl-1-0, dsdp, dvipdfm, ecl-1-0, ecl-2-0, ecos-exception-2-0, efl-1-0, efl-2-0, egenix, entessa, epics, epl-1-0, epl-2-0, erlpl-1-1, etalab-2-0, eu-datagrid, eupl-1-0, eupl-1-1, eupl-1-2, eurosym, fair, fawkes-runtime-exception, fltk-exception, font-exception-2-0, frameworx-1-0, freebsd-doc, freeimage, freertos-exception-2-0, fsfap, fsful, fsfullr, ftl, gcc-exception-2-0, gcc-exception-3-1, gd, gfdl-1-1-invariants-only, gfdl-1-1-invariants-or-later, gfdl-1-1-no-invariants-only, gfdl-1-1-no-invariants-or-later, gfdl-1-1-only, gfdl-1-1-or-later, gfdl-1-2-invariants-only, gfdl-1-2-invariants-or-later, gfdl-1-2-no-invariants-only, gfdl-1-2-no-invariants-or-later, gfdl-1-2-only, gfdl-1-2-or-later, gfdl-1-3-invariants-only, gfdl-1-3-invariants-or-later, gfdl-1-3-no-invariants-only, gfdl-1-3-no-invariants-or-later, gfdl-1-3-only, gfdl-1-3-or-later, giftware, gl2ps, glide, glulxe, glwtpl, gnu-javamail-exception, gnuplot, gpl-1-0-only, gpl-1-0-or-later, gpl-2-0-only, gpl-2-0-or-later, gpl-3-0-linking-exception, gpl-3-0-linking-source-exception, gpl-3-0-only, gpl-3-0-or-later, gpl-cc-1-0, gsoap-1-3b, haskell-report, hippocratic-2-1, hpnd, hpnd-sell-variant, htmltidy, i2p-gpl-java-exception, ibm-pibs, icu, ijg, image-magick, imatix, imlib2, info-zip, intel, intel-acpi, interbase-1-0, ipa, ipl-1-0, isc, jasper-2-0, jpnic, json, lal-1-2, lal-1-3, latex2e, leptonica, lgpl-2-0-only, lgpl-2-0-or-later, lgpl-2-1-only, lgpl-2-1-or-later, lgpl-3-0-linking-exception, lgpl-3-0-only, lgpl-3-0-or-later, lgpllr, libpng, libpng-2-0, libselinux-1-0, libtiff, libtool-exception, liliq-p-1-1, liliq-r-1-1, liliq-rplus-1-1, linux-openib, linux-syscall-note, llvm-exception, lpl-1-0, lpl-1-02, lppl-1-0, lppl-1-1, lppl-1-2, lppl-1-3a, lppl-1-3c, lzma-exception, make-index, mif-exception, miros, mit, mit-0, mit-advertising, mit-cmu, mit-enna, mit-feh, mit-modern-variant, mitnfa, mit-open-group, motosoto, mpich2, mpl-1-0, mpl-1-1, mpl-2-0, mpl-2-0-no-copyleft-exception, ms-pl, ms-rl, mtll, mulanpsl-1-0, mulanpsl-2-0, multics, mup, naist-2003, nasa-1-3, naumen, nbpl-1-0, ncgl-uk-2-0, ncsa, netcdf, net-snmp, newsletr, ngpl, nist-pd, nist-pd-fallback, nlod-1-0, nlpl, nokia, nokia-qt-exception-1-1, nosl, noweb, npl-1-0, npl-1-1, nposl-3-0, nrl, ntp, ntp-0, ocaml-lgpl-linking-exception, occt-exception-1-0, occt-pl, oclc-2-0, odbl-1-0, odc-by-1-0, ofl-1-0, ofl-1-0-no-rfn, ofl-1-0-rfn, ofl-1-1, ofl-1-1-no-rfn, ofl-1-1-rfn, ogc-1-0, ogdl-taiwan-1-0, ogl-canada-2-0, ogl-uk-1-0, ogl-uk-2-0, ogl-uk-3-0, ogtsl, oldap-1-1, oldap-1-2, oldap-1-3, oldap-1-4, oldap-2-0, oldap-2-0-1, oldap-2-1, oldap-2-2, oldap-2-2-1, oldap-2-2-2, oldap-2-3, oldap-2-4, oldap-2-7, oml, openjdk-assembly-exception-1-0, openssl, openvpn-openssl-exception, opl-1-0, oset-pl-2-1, osl-1-0, osl-1-1, osl-2-0, osl-2-1, osl-3-0, o-uda-1-0, parity-6-0-0, parity-7-0-0, pddl-1-0, php-3-0, php-3-01, plexus, polyform-noncommercial-1-0-0, polyform-small-business-1-0-0, postgresql, psf-2-0, psfrag, ps-or-pdf-font-exception-20170817, psutils, python-2-0, qhull, qpl-1-0, qt-gpl-exception-1-0, qt-lgpl-exception-1-1, qwt-exception-1-0, rdisc, rhecos-1-1, rpl-1-1, rpsl-1-0, rsa-md, rscpl, ruby, saxpath, sax-pd, scea, sendmail, sendmail-8-23, sgi-b-1-0, sgi-b-1-1, sgi-b-2-0, shl-0-51, shl-2-0, shl-2-1, simpl-2-0, sissl, sissl-1-2, sleepycat, smlnj, smppl, snia, spencer-86, spencer-94, spencer-99, spl-1-0, ssh-openssh, ssh-short, sspl-1-0, sugarcrm-1-1-3, swift-exception, swl, tapr-ohl-1-0, tcl, tcp-wrappers, tmate, torque-1-1, tosl, tu-berlin-1-0, tu-berlin-2-0, u-boot-exception-2-0, ucl-1-0, unicode-dfs-2015, unicode-dfs-2016, unicode-tou, universal-foss-exception-1-0, unlicense, upl-1-0, vim, vostrom, vsl-1-0, w3c, w3c-19980720, w3c-20150513, watcom-1-0, wsuipa, wtfpl, wxwindows-exception-3-1, x11, xerox, xfree86-1-1, xinetd, xnet, xpp, xskat, ypl-1-0, ypl-1-1, zed, zend-2-0, zimbra-1-3, zimbra-1-4, zlib, zlib-acknowledgement, zpl-1-1, zpl-2-0, zpl-2-1. */ + // +optional + License *string `json:"license,omitempty"` + + /* README template name. Valid template name(s) are: default. */ + // +optional + Readme *string `json:"readme,omitempty"` +} + +type SecureSourceManagerRepositorySpec struct { + /* Input only. Initial configurations for the repository. */ + // +optional + InitialConfig *RepositoryInitialConfig `json:"initialConfig,omitempty"` + + /* Immutable. The name of the instance in which the repository is hosted, formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` */ + InstanceRef v1alpha1.ResourceRef `json:"instanceRef"` + + /* Immutable. Location of the instance. */ + Location string `json:"location"` + + /* Immutable. The Project that this resource belongs to. */ + ProjectRef v1alpha1.ResourceRef `json:"projectRef"` + + /* Immutable. The SecureSourceManagerRepository name. If not given, the metadata.name will be used. */ + // +optional + ResourceID *string `json:"resourceID,omitempty"` +} + +type RepositoryObservedStateStatus struct { +} + +type SecureSourceManagerRepositoryStatus struct { + /* Conditions represent the latest available observations of the + SecureSourceManagerRepository's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + /* A unique specifier for the SecureSourceManagerRepository 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 *RepositoryObservedStateStatus `json:"observedState,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositorys +// +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'" + +// SecureSourceManagerRepository is the Schema for the securesourcemanager API +// +k8s:openapi-gen=true +type SecureSourceManagerRepository struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SecureSourceManagerRepositorySpec `json:"spec,omitempty"` + Status SecureSourceManagerRepositoryStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SecureSourceManagerRepositoryList contains a list of SecureSourceManagerRepository +type SecureSourceManagerRepositoryList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SecureSourceManagerRepository `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SecureSourceManagerRepository{}, &SecureSourceManagerRepositoryList{}) +} diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index ea2b26ed51..e3cb67ccd0 100644 --- a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -96,6 +96,58 @@ func (in *InstanceObservedStateStatus) DeepCopy() *InstanceObservedStateStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryInitialConfig) DeepCopyInto(out *RepositoryInitialConfig) { + *out = *in + if in.DefaultBranch != nil { + in, out := &in.DefaultBranch, &out.DefaultBranch + *out = new(string) + **out = **in + } + if in.Gitignores != nil { + in, out := &in.Gitignores, &out.Gitignores + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.License != nil { + in, out := &in.License, &out.License + *out = new(string) + **out = **in + } + if in.Readme != nil { + in, out := &in.Readme, &out.Readme + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryInitialConfig. +func (in *RepositoryInitialConfig) DeepCopy() *RepositoryInitialConfig { + if in == nil { + return nil + } + out := new(RepositoryInitialConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryObservedStateStatus) DeepCopyInto(out *RepositoryObservedStateStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryObservedStateStatus. +func (in *RepositoryObservedStateStatus) DeepCopy() *RepositoryObservedStateStatus { + if in == nil { + return nil + } + out := new(RepositoryObservedStateStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerInstance) DeepCopyInto(out *SecureSourceManagerInstance) { *out = *in @@ -219,3 +271,128 @@ func (in *SecureSourceManagerInstanceStatus) DeepCopy() *SecureSourceManagerInst in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepository) DeepCopyInto(out *SecureSourceManagerRepository) { + *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 SecureSourceManagerRepository. +func (in *SecureSourceManagerRepository) DeepCopy() *SecureSourceManagerRepository { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepository) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerRepository) 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 *SecureSourceManagerRepositoryList) DeepCopyInto(out *SecureSourceManagerRepositoryList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SecureSourceManagerRepository, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryList. +func (in *SecureSourceManagerRepositoryList) DeepCopy() *SecureSourceManagerRepositoryList { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerRepositoryList) 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 *SecureSourceManagerRepositorySpec) DeepCopyInto(out *SecureSourceManagerRepositorySpec) { + *out = *in + if in.InitialConfig != nil { + in, out := &in.InitialConfig, &out.InitialConfig + *out = new(RepositoryInitialConfig) + (*in).DeepCopyInto(*out) + } + out.InstanceRef = in.InstanceRef + out.ProjectRef = in.ProjectRef + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositorySpec. +func (in *SecureSourceManagerRepositorySpec) DeepCopy() *SecureSourceManagerRepositorySpec { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositorySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerRepositoryStatus) DeepCopyInto(out *SecureSourceManagerRepositoryStatus) { + *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(RepositoryObservedStateStatus) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryStatus. +func (in *SecureSourceManagerRepositoryStatus) DeepCopy() *SecureSourceManagerRepositoryStatus { + if in == nil { + return nil + } + out := new(SecureSourceManagerRepositoryStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go index cff98ae6fb..0f2a497d40 100644 --- a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go @@ -35,6 +35,10 @@ func (c *FakeSecuresourcemanagerV1alpha1) SecureSourceManagerInstances(namespace return &FakeSecureSourceManagerInstances{c, namespace} } +func (c *FakeSecuresourcemanagerV1alpha1) SecureSourceManagerRepositories(namespace string) v1alpha1.SecureSourceManagerRepositoryInterface { + return &FakeSecureSourceManagerRepositories{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeSecuresourcemanagerV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerrepository.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerrepository.go new file mode 100644 index 0000000000..d3d019b165 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerrepository.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/securesourcemanager/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" +) + +// FakeSecureSourceManagerRepositories implements SecureSourceManagerRepositoryInterface +type FakeSecureSourceManagerRepositories struct { + Fake *FakeSecuresourcemanagerV1alpha1 + ns string +} + +var securesourcemanagerrepositoriesResource = v1alpha1.SchemeGroupVersion.WithResource("securesourcemanagerrepositories") + +var securesourcemanagerrepositoriesKind = v1alpha1.SchemeGroupVersion.WithKind("SecureSourceManagerRepository") + +// Get takes name of the secureSourceManagerRepository, and returns the corresponding secureSourceManagerRepository object, and an error if there is any. +func (c *FakeSecureSourceManagerRepositories) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(securesourcemanagerrepositoriesResource, c.ns, name), &v1alpha1.SecureSourceManagerRepository{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerRepository), err +} + +// List takes label and field selectors, and returns the list of SecureSourceManagerRepositories that match those selectors. +func (c *FakeSecureSourceManagerRepositories) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SecureSourceManagerRepositoryList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(securesourcemanagerrepositoriesResource, securesourcemanagerrepositoriesKind, c.ns, opts), &v1alpha1.SecureSourceManagerRepositoryList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SecureSourceManagerRepositoryList{ListMeta: obj.(*v1alpha1.SecureSourceManagerRepositoryList).ListMeta} + for _, item := range obj.(*v1alpha1.SecureSourceManagerRepositoryList).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 secureSourceManagerRepositories. +func (c *FakeSecureSourceManagerRepositories) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(securesourcemanagerrepositoriesResource, c.ns, opts)) + +} + +// Create takes the representation of a secureSourceManagerRepository and creates it. Returns the server's representation of the secureSourceManagerRepository, and an error, if there is any. +func (c *FakeSecureSourceManagerRepositories) Create(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.CreateOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(securesourcemanagerrepositoriesResource, c.ns, secureSourceManagerRepository), &v1alpha1.SecureSourceManagerRepository{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerRepository), err +} + +// Update takes the representation of a secureSourceManagerRepository and updates it. Returns the server's representation of the secureSourceManagerRepository, and an error, if there is any. +func (c *FakeSecureSourceManagerRepositories) Update(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(securesourcemanagerrepositoriesResource, c.ns, secureSourceManagerRepository), &v1alpha1.SecureSourceManagerRepository{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerRepository), 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 *FakeSecureSourceManagerRepositories) UpdateStatus(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerRepository, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(securesourcemanagerrepositoriesResource, "status", c.ns, secureSourceManagerRepository), &v1alpha1.SecureSourceManagerRepository{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerRepository), err +} + +// Delete takes name of the secureSourceManagerRepository and deletes it. Returns an error if one occurs. +func (c *FakeSecureSourceManagerRepositories) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(securesourcemanagerrepositoriesResource, c.ns, name, opts), &v1alpha1.SecureSourceManagerRepository{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSecureSourceManagerRepositories) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(securesourcemanagerrepositoriesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SecureSourceManagerRepositoryList{}) + return err +} + +// Patch applies the patch and returns the patched secureSourceManagerRepository. +func (c *FakeSecureSourceManagerRepositories) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SecureSourceManagerRepository, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(securesourcemanagerrepositoriesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SecureSourceManagerRepository{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerRepository), err +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go index c0ac7f5c2a..b9dc98f32c 100644 --- a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go @@ -22,3 +22,5 @@ package v1alpha1 type SecureSourceManagerInstanceExpansion interface{} + +type SecureSourceManagerRepositoryExpansion interface{} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go index 5d49f3e1da..94e47d915e 100644 --- a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go @@ -32,6 +32,7 @@ import ( type SecuresourcemanagerV1alpha1Interface interface { RESTClient() rest.Interface SecureSourceManagerInstancesGetter + SecureSourceManagerRepositoriesGetter } // SecuresourcemanagerV1alpha1Client is used to interact with features provided by the securesourcemanager.cnrm.cloud.google.com group. @@ -43,6 +44,10 @@ func (c *SecuresourcemanagerV1alpha1Client) SecureSourceManagerInstances(namespa return newSecureSourceManagerInstances(c, namespace) } +func (c *SecuresourcemanagerV1alpha1Client) SecureSourceManagerRepositories(namespace string) SecureSourceManagerRepositoryInterface { + return newSecureSourceManagerRepositories(c, namespace) +} + // NewForConfig creates a new SecuresourcemanagerV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerrepository.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerrepository.go new file mode 100644 index 0000000000..b935bb2d6f --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerrepository.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/securesourcemanager/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" +) + +// SecureSourceManagerRepositoriesGetter has a method to return a SecureSourceManagerRepositoryInterface. +// A group's client should implement this interface. +type SecureSourceManagerRepositoriesGetter interface { + SecureSourceManagerRepositories(namespace string) SecureSourceManagerRepositoryInterface +} + +// SecureSourceManagerRepositoryInterface has methods to work with SecureSourceManagerRepository resources. +type SecureSourceManagerRepositoryInterface interface { + Create(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.CreateOptions) (*v1alpha1.SecureSourceManagerRepository, error) + Update(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerRepository, error) + UpdateStatus(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerRepository, 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.SecureSourceManagerRepository, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SecureSourceManagerRepositoryList, 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.SecureSourceManagerRepository, err error) + SecureSourceManagerRepositoryExpansion +} + +// secureSourceManagerRepositories implements SecureSourceManagerRepositoryInterface +type secureSourceManagerRepositories struct { + client rest.Interface + ns string +} + +// newSecureSourceManagerRepositories returns a SecureSourceManagerRepositories +func newSecureSourceManagerRepositories(c *SecuresourcemanagerV1alpha1Client, namespace string) *secureSourceManagerRepositories { + return &secureSourceManagerRepositories{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the secureSourceManagerRepository, and returns the corresponding secureSourceManagerRepository object, and an error if there is any. +func (c *secureSourceManagerRepositories) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + result = &v1alpha1.SecureSourceManagerRepository{} + err = c.client.Get(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SecureSourceManagerRepositories that match those selectors. +func (c *secureSourceManagerRepositories) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SecureSourceManagerRepositoryList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SecureSourceManagerRepositoryList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested secureSourceManagerRepositories. +func (c *secureSourceManagerRepositories) 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("securesourcemanagerrepositories"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a secureSourceManagerRepository and creates it. Returns the server's representation of the secureSourceManagerRepository, and an error, if there is any. +func (c *secureSourceManagerRepositories) Create(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.CreateOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + result = &v1alpha1.SecureSourceManagerRepository{} + err = c.client.Post(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerRepository). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a secureSourceManagerRepository and updates it. Returns the server's representation of the secureSourceManagerRepository, and an error, if there is any. +func (c *secureSourceManagerRepositories) Update(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + result = &v1alpha1.SecureSourceManagerRepository{} + err = c.client.Put(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + Name(secureSourceManagerRepository.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerRepository). + 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 *secureSourceManagerRepositories) UpdateStatus(ctx context.Context, secureSourceManagerRepository *v1alpha1.SecureSourceManagerRepository, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerRepository, err error) { + result = &v1alpha1.SecureSourceManagerRepository{} + err = c.client.Put(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + Name(secureSourceManagerRepository.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerRepository). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the secureSourceManagerRepository and deletes it. Returns an error if one occurs. +func (c *secureSourceManagerRepositories) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *secureSourceManagerRepositories) 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("securesourcemanagerrepositories"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched secureSourceManagerRepository. +func (c *secureSourceManagerRepositories) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SecureSourceManagerRepository, err error) { + result = &v1alpha1.SecureSourceManagerRepository{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("securesourcemanagerrepositories"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gvks/supportedgvks/gvks_generated.go b/pkg/gvks/supportedgvks/gvks_generated.go index c7d626d735..59aab54b32 100644 --- a/pkg/gvks/supportedgvks/gvks_generated.go +++ b/pkg/gvks/supportedgvks/gvks_generated.go @@ -3902,6 +3902,16 @@ var SupportedGVKs = map[schema.GroupVersionKind]GVKMetadata{ "cnrm.cloud.google.com/system": "true", }, }, + { + Group: "securesourcemanager.cnrm.cloud.google.com", + Version: "v1alpha1", + Kind: "SecureSourceManagerRepository", + }: { + Labels: map[string]string{ + "cnrm.cloud.google.com/managed-by-kcc": "true", + "cnrm.cloud.google.com/system": "true", + }, + }, { Group: "securitycenter.cnrm.cloud.google.com", Version: "v1alpha1", From ff48ef0f713d5432fcf771bfb1c648d92e8130f7 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 29 Oct 2024 21:25:25 +0000 Subject: [PATCH 03/14] Add output fields and fix pluralization --- .../securesourcemanagerrepository_types.go | 14 ++++++++++++-- ....securesourcemanager.cnrm.cloud.google.com.yaml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index f3d4205653..b109b67b5e 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -67,12 +67,22 @@ type SecureSourceManagerRepositoryStatus struct { // SecureSourceManagerRepositoryObservedState is the state of the SecureSourceManagerRepository resource as most recently observed in GCP. type SecureSourceManagerRepositoryObservedState struct { + // // Output only. Create timestamp. + // CreateTime *string `json:"createTime,omitempty"` + + // // Output only. Update timestamp. + // UpdateTime *string `json:"updateTime,omitempty" + + // Output only. Unique identifier of the repository. + Uid *string `json:"uid,omitempty"` + + // Output only. URIs for the repository. + URIs *Repository_URIs `json:"uris,omitempty"` } // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// TODO(user): make sure the pluralizaiton below is correct -// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositorys +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositories // +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" diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml index 4ce32f3d47..36090eb0d1 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml @@ -18,7 +18,7 @@ spec: plural: securesourcemanagerrepositories shortNames: - gcpsecuresourcemanagerrepository - - gcpsecuresourcemanagerrepositorys + - gcpsecuresourcemanagerrepositories singular: securesourcemanagerrepository preserveUnknownFields: false scope: Namespaced From e5853223c3fff387e124b28e8c7ed23107e0a66b Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 29 Oct 2024 21:56:00 +0000 Subject: [PATCH 04/14] Add mock repo --- config/tests/samples/create/harness.go | 1 + mockgcp/mocksecuresourcemanager/repository.go | 166 ++++++++++++++++++ .../create.yaml | 24 +++ .../dependencies.yaml | 22 +++ 4 files changed, 213 insertions(+) create mode 100644 mockgcp/mocksecuresourcemanager/repository.go create mode 100644 pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index 581b4ca36c..fbaec55492 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -846,6 +846,7 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured case schema.GroupKind{Group: "secretmanager.cnrm.cloud.google.com", Kind: "SecretManagerSecretVersion"}: case schema.GroupKind{Group: "securesourcemanager.cnrm.cloud.google.com", Kind: "SecureSourceManagerInstance"}: + case schema.GroupKind{Group: "securesourcemanager.cnrm.cloud.google.com", Kind: "SecureSourceManagerRepository"}: case schema.GroupKind{Group: "servicedirectory.cnrm.cloud.google.com", Kind: "ServiceDirectoryNamespace"}: case schema.GroupKind{Group: "servicedirectory.cnrm.cloud.google.com", Kind: "ServiceDirectoryService"}: diff --git a/mockgcp/mocksecuresourcemanager/repository.go b/mockgcp/mocksecuresourcemanager/repository.go new file mode 100644 index 0000000000..55eecdf6a9 --- /dev/null +++ b/mockgcp/mocksecuresourcemanager/repository.go @@ -0,0 +1,166 @@ +// 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 mocksecuresourcemanager + +import ( + "context" + "fmt" + "strings" + "time" + + longrunning "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" + pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/securesourcemanager/v1" +) + +func (s *secureSourceManagerServer) GetRepository(ctx context.Context, req *pb.GetRepositoryRequest) (*pb.Repository, error) { + name, err := s.parseRepositoryName(req.Name) + if err != nil { + return nil, err + } + + fqn := name.String() + + obj := &pb.Repository{} + if err := s.storage.Get(ctx, fqn, obj); err != nil { + if status.Code(err) == codes.NotFound { + return nil, status.Errorf(codes.NotFound, "Resource '%s' was not found", fqn) + } + return nil, err + } + + return obj, nil +} + +func (s *secureSourceManagerServer) CreateRepository(ctx context.Context, req *pb.CreateRepositoryRequest) (*longrunning.Operation, error) { + reqName := req.Parent + "/repositories/" + req.RepositoryId + name, err := s.parseRepositoryName(reqName) + if err != nil { + return nil, err + } + + fqn := name.String() + + now := time.Now() + + obj := proto.Clone(req.Repository).(*pb.Repository) + obj.Name = fqn + + obj.CreateTime = timestamppb.New(now) + obj.UpdateTime = timestamppb.New(now) + + instanceName, err := s.parseInstanceName(req.GetRepository().GetInstance()) + if err != nil { + return nil, err + } + + prefix := fmt.Sprintf("%s-%d", instanceName.InstanceID, name.Project.Number) + domain := "." + name.Location + ".sourcemanager.dev" + obj.Uris = &pb.Repository_URIs{ + Html: prefix + domain + fmt.Sprintf("%s/%s", name.Project.ID, req.GetRepositoryId()), + Api: prefix + "-api" + domain + fmt.Sprintf("/v1/projects/%s/locations/%s/repositories/%s", name.Project.ID, name.Location, req.GetRepositoryId()), + GitHttps: prefix + "-git" + domain + fmt.Sprintf("%s/%s.git", name.Project.ID, req.GetRepositoryId()), + } + + if err := s.storage.Create(ctx, fqn, obj); err != nil { + return nil, err + } + + op := &pb.OperationMetadata{ + CreateTime: timestamppb.New(now), + Target: name.String(), + Verb: "create", + ApiVersion: "v1", + } + opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) + return s.operations.StartLRO(ctx, opPrefix, op, func() (proto.Message, error) { + op.EndTime = timestamppb.Now() + return obj, nil + }) +} + +func (s *secureSourceManagerServer) DeleteRepository(ctx context.Context, req *pb.DeleteRepositoryRequest) (*longrunning.Operation, error) { + name, err := s.parseRepositoryName(req.GetName()) + if err != nil { + return nil, err + } + + fqn := name.String() + now := time.Now() + + deleted := &pb.Repository{} + if err := s.storage.Delete(ctx, fqn, deleted); err != nil { + return nil, err + } + + op := &pb.OperationMetadata{ + CreateTime: timestamppb.New(now), + Target: name.String(), + Verb: "delete", + ApiVersion: "v1", + } + opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) + return s.operations.StartLRO(ctx, opPrefix, op, func() (proto.Message, error) { + op.EndTime = timestamppb.Now() + return &emptypb.Empty{}, nil + }) +} + +type RepositoryName struct { + Project *projects.ProjectData + Location string + RepositoryID string +} + +func (n *RepositoryName) String() string { + return fmt.Sprintf("projects/%s/locations/%s/repositories/%s", n.Project.ID, n.Location, n.RepositoryID) +} + +// func (n *RepositoryName) Target() string { +// return fmt.Sprintf("projects/%s/locations/%s/repositories/%s", n.Project.ID, n.Location, n.RepositoryID) +// } + +// parseRepositoryName parses a string into a RepositoryName. +// The expected form is projects/*/locations/*/repositories/* +func (s *MockService) parseRepositoryName(name string) (*RepositoryName, error) { + tokens := strings.Split(name, "/") + + if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "repositories" { + projectName, err := projects.ParseProjectName(tokens[0] + "/" + tokens[1]) + if err != nil { + return nil, err + } + project, err := s.Projects.GetProject(projectName) + if err != nil { + return nil, err + } + + name := &RepositoryName{ + Project: project, + Location: tokens[3], + RepositoryID: tokens[5], + } + + return name, nil + } else { + return nil, status.Errorf(codes.InvalidArgument, "name %q is not valid", name) + } +} diff --git a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml new file mode 100644 index 0000000000..a1d166e2b0 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml @@ -0,0 +1,24 @@ +# 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. + +apiVersion: securesourcemanager.cnrm.cloud.google.com/v1alpha1 +kind: SecureSourceManagerRepository +metadata: + name: ssmrepository-${uniqueId} +spec: + location: us-central1 + projectRef: + external: ${projectId} + instanceRef: + name: ssminstance-${uniqueId} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml new file mode 100644 index 0000000000..a36bd3f188 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml @@ -0,0 +1,22 @@ +# 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. + +apiVersion: securesourcemanager.cnrm.cloud.google.com/v1alpha1 +kind: SecureSourceManagerInstance +metadata: + name: ssminstance-${uniqueId} +spec: + location: us-central1 + projectRef: + external: ${projectId} From a9b3445073d152eca7a19278ef43491a30383b21 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 29 Oct 2024 22:06:35 +0000 Subject: [PATCH 05/14] remove generated comment --- .../v1alpha1/securesourcemanagerrepository_types.go | 1 - 1 file changed, 1 deletion(-) diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index b109b67b5e..47a4d61413 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -22,7 +22,6 @@ import ( var SecureSourceManagerRepositoryGVK = GroupVersion.WithKind("SecureSourceManagerRepository") -// 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. // SecureSourceManagerRepositorySpec defines the desired state of SecureSourceManagerRepository From 7a31726e497a5bc4d2058cecdbbe1e073f4f2aa4 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Thu, 31 Oct 2024 16:09:56 +0000 Subject: [PATCH 06/14] Revert "remove generated comment" This reverts commit 1e488a4d5fd8e8b07ab43f1bdd8bbc520db68601. --- .../v1alpha1/securesourcemanagerrepository_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index 47a4d61413..b109b67b5e 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -22,6 +22,7 @@ import ( var SecureSourceManagerRepositoryGVK = GroupVersion.WithKind("SecureSourceManagerRepository") +// 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. // SecureSourceManagerRepositorySpec defines the desired state of SecureSourceManagerRepository From 77dd67bd013ef3fef7a417050b4b2b3c3bcaa87a Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Thu, 31 Oct 2024 16:10:06 +0000 Subject: [PATCH 07/14] Revert "Add mock repo" This reverts commit 48facf26cc42950ceef6f08ea80ae07699d09591. --- config/tests/samples/create/harness.go | 1 - mockgcp/mocksecuresourcemanager/repository.go | 166 ------------------ .../create.yaml | 24 --- .../dependencies.yaml | 22 --- 4 files changed, 213 deletions(-) delete mode 100644 mockgcp/mocksecuresourcemanager/repository.go delete mode 100644 pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml delete mode 100644 pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index fbaec55492..581b4ca36c 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -846,7 +846,6 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured case schema.GroupKind{Group: "secretmanager.cnrm.cloud.google.com", Kind: "SecretManagerSecretVersion"}: case schema.GroupKind{Group: "securesourcemanager.cnrm.cloud.google.com", Kind: "SecureSourceManagerInstance"}: - case schema.GroupKind{Group: "securesourcemanager.cnrm.cloud.google.com", Kind: "SecureSourceManagerRepository"}: case schema.GroupKind{Group: "servicedirectory.cnrm.cloud.google.com", Kind: "ServiceDirectoryNamespace"}: case schema.GroupKind{Group: "servicedirectory.cnrm.cloud.google.com", Kind: "ServiceDirectoryService"}: diff --git a/mockgcp/mocksecuresourcemanager/repository.go b/mockgcp/mocksecuresourcemanager/repository.go deleted file mode 100644 index 55eecdf6a9..0000000000 --- a/mockgcp/mocksecuresourcemanager/repository.go +++ /dev/null @@ -1,166 +0,0 @@ -// 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 mocksecuresourcemanager - -import ( - "context" - "fmt" - "strings" - "time" - - longrunning "google.golang.org/genproto/googleapis/longrunning" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/emptypb" - "google.golang.org/protobuf/types/known/timestamppb" - - "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" - pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/securesourcemanager/v1" -) - -func (s *secureSourceManagerServer) GetRepository(ctx context.Context, req *pb.GetRepositoryRequest) (*pb.Repository, error) { - name, err := s.parseRepositoryName(req.Name) - if err != nil { - return nil, err - } - - fqn := name.String() - - obj := &pb.Repository{} - if err := s.storage.Get(ctx, fqn, obj); err != nil { - if status.Code(err) == codes.NotFound { - return nil, status.Errorf(codes.NotFound, "Resource '%s' was not found", fqn) - } - return nil, err - } - - return obj, nil -} - -func (s *secureSourceManagerServer) CreateRepository(ctx context.Context, req *pb.CreateRepositoryRequest) (*longrunning.Operation, error) { - reqName := req.Parent + "/repositories/" + req.RepositoryId - name, err := s.parseRepositoryName(reqName) - if err != nil { - return nil, err - } - - fqn := name.String() - - now := time.Now() - - obj := proto.Clone(req.Repository).(*pb.Repository) - obj.Name = fqn - - obj.CreateTime = timestamppb.New(now) - obj.UpdateTime = timestamppb.New(now) - - instanceName, err := s.parseInstanceName(req.GetRepository().GetInstance()) - if err != nil { - return nil, err - } - - prefix := fmt.Sprintf("%s-%d", instanceName.InstanceID, name.Project.Number) - domain := "." + name.Location + ".sourcemanager.dev" - obj.Uris = &pb.Repository_URIs{ - Html: prefix + domain + fmt.Sprintf("%s/%s", name.Project.ID, req.GetRepositoryId()), - Api: prefix + "-api" + domain + fmt.Sprintf("/v1/projects/%s/locations/%s/repositories/%s", name.Project.ID, name.Location, req.GetRepositoryId()), - GitHttps: prefix + "-git" + domain + fmt.Sprintf("%s/%s.git", name.Project.ID, req.GetRepositoryId()), - } - - if err := s.storage.Create(ctx, fqn, obj); err != nil { - return nil, err - } - - op := &pb.OperationMetadata{ - CreateTime: timestamppb.New(now), - Target: name.String(), - Verb: "create", - ApiVersion: "v1", - } - opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) - return s.operations.StartLRO(ctx, opPrefix, op, func() (proto.Message, error) { - op.EndTime = timestamppb.Now() - return obj, nil - }) -} - -func (s *secureSourceManagerServer) DeleteRepository(ctx context.Context, req *pb.DeleteRepositoryRequest) (*longrunning.Operation, error) { - name, err := s.parseRepositoryName(req.GetName()) - if err != nil { - return nil, err - } - - fqn := name.String() - now := time.Now() - - deleted := &pb.Repository{} - if err := s.storage.Delete(ctx, fqn, deleted); err != nil { - return nil, err - } - - op := &pb.OperationMetadata{ - CreateTime: timestamppb.New(now), - Target: name.String(), - Verb: "delete", - ApiVersion: "v1", - } - opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) - return s.operations.StartLRO(ctx, opPrefix, op, func() (proto.Message, error) { - op.EndTime = timestamppb.Now() - return &emptypb.Empty{}, nil - }) -} - -type RepositoryName struct { - Project *projects.ProjectData - Location string - RepositoryID string -} - -func (n *RepositoryName) String() string { - return fmt.Sprintf("projects/%s/locations/%s/repositories/%s", n.Project.ID, n.Location, n.RepositoryID) -} - -// func (n *RepositoryName) Target() string { -// return fmt.Sprintf("projects/%s/locations/%s/repositories/%s", n.Project.ID, n.Location, n.RepositoryID) -// } - -// parseRepositoryName parses a string into a RepositoryName. -// The expected form is projects/*/locations/*/repositories/* -func (s *MockService) parseRepositoryName(name string) (*RepositoryName, error) { - tokens := strings.Split(name, "/") - - if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "repositories" { - projectName, err := projects.ParseProjectName(tokens[0] + "/" + tokens[1]) - if err != nil { - return nil, err - } - project, err := s.Projects.GetProject(projectName) - if err != nil { - return nil, err - } - - name := &RepositoryName{ - Project: project, - Location: tokens[3], - RepositoryID: tokens[5], - } - - return name, nil - } else { - return nil, status.Errorf(codes.InvalidArgument, "name %q is not valid", name) - } -} diff --git a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml deleted file mode 100644 index a1d166e2b0..0000000000 --- a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/create.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -apiVersion: securesourcemanager.cnrm.cloud.google.com/v1alpha1 -kind: SecureSourceManagerRepository -metadata: - name: ssmrepository-${uniqueId} -spec: - location: us-central1 - projectRef: - external: ${projectId} - instanceRef: - name: ssminstance-${uniqueId} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml deleted file mode 100644 index a36bd3f188..0000000000 --- a/pkg/test/resourcefixture/testdata/basic/securesourcemanager/securesourcemanagerrepository/securesourcemanagerrepositorybasic/dependencies.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - -apiVersion: securesourcemanager.cnrm.cloud.google.com/v1alpha1 -kind: SecureSourceManagerInstance -metadata: - name: ssminstance-${uniqueId} -spec: - location: us-central1 - projectRef: - external: ${projectId} From 27c600786830838ad4be06aa63a87bde78d44baf Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Mon, 4 Nov 2024 19:44:21 +0000 Subject: [PATCH 08/14] Fix repo reference --- .../v1alpha1/instance_reference.go | 82 +++++++++++++++++++ .../v1alpha1/repository_reference.go | 12 +++ .../securesourcemanagerrepository_types.go | 5 +- .../v1alpha1/zz_generated.deepcopy.go | 22 ++++- ...resourcemanager.cnrm.cloud.google.com.yaml | 16 ++++ .../securesourcemanagerrepository_types.go | 19 ++++- .../v1alpha1/zz_generated.deepcopy.go | 38 ++++++++- 7 files changed, 187 insertions(+), 7 deletions(-) diff --git a/apis/securesourcemanager/v1alpha1/instance_reference.go b/apis/securesourcemanager/v1alpha1/instance_reference.go index 616a5dd8ac..a35f58bad9 100644 --- a/apis/securesourcemanager/v1alpha1/instance_reference.go +++ b/apis/securesourcemanager/v1alpha1/instance_reference.go @@ -23,6 +23,7 @@ import ( "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/runtime/schema" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -43,6 +44,12 @@ type SecureSourceManagerInstanceRef struct { Namespace string `json:"namespace,omitempty"` } +type SecureSourceManagerInstanceID struct { + ProjectID string + Location string + InstanceID string +} + func ParseSecureSourceManagerInstanceRef(url string) (*SecureSourceManagerInstanceRef, error) { parent, resourceID, err := parseSecureSourceManagerExternal(url) if err != nil { @@ -183,6 +190,10 @@ func (r *SecureSourceManagerInstanceRef) ResourceID() (string, error) { return resourceID, nil } +func (r *SecureSourceManagerInstanceID) String() string { + return fmt.Sprintf("projects/%s/locations/%s/instances/%s", r.ProjectID, r.Location, r.InstanceID) +} + // +k8s:deepcopy-gen=false type ProjectIDAndLocation struct { ProjectID string @@ -200,3 +211,74 @@ func valueOf[T any](t *T) T { } return *t } + +func ResolveSecureSourceManagerInstanceRef(ctx context.Context, reader client.Reader, obj client.Object, ref *SecureSourceManagerInstanceRef) (*SecureSourceManagerInstanceID, error) { + if ref == nil { + return nil, nil + } + + if ref.Name == "" && ref.External == "" { + return nil, fmt.Errorf("must specify either name or external on instanceRef") + } + if ref.External != "" && ref.Name != "" { + return nil, fmt.Errorf("cannot specify both spec.instanceRef.name and spec.instanceRef.external") + } + + if ref.External != "" { + // External should be in the `projects/[projectID]/locations/[Location]/instances/[instanceName]` format. + tokens := strings.Split(ref.External, "/") + if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "instances" { + return &SecureSourceManagerInstanceID{ + ProjectID: tokens[1], + Location: tokens[3], + InstanceID: tokens[5], + }, nil + } + return nil, fmt.Errorf("format of securesourcemanagerinstance external=%q was not known (use projects//locations/[Location]/instances/)", ref.External) + } + + key := types.NamespacedName{ + Namespace: ref.Namespace, + Name: ref.Name, + } + if key.Namespace == "" { + key.Namespace = obj.GetNamespace() + } + + ssminstance := &unstructured.Unstructured{} + ssminstance.SetGroupVersionKind(schema.GroupVersionKind{ + Group: "securesourcemanager.cnrm.cloud.google.com", + Version: "v1alpha1", + Kind: "SecureSourceManagerInstance", + }) + if err := reader.Get(ctx, key, ssminstance); err != nil { + if apierrors.IsNotFound(err) { + return nil, fmt.Errorf("referenced SecureSourceManagerInstance %v not found", key) + } + return nil, fmt.Errorf("error reading referenced SecureSourceManagerInstance %v: %w", key, err) + } + + resourceID, _, err := unstructured.NestedString(ssminstance.Object, "spec", "resourceID") + if err != nil { + return nil, fmt.Errorf("reading spec.resourceID from SecureSourceManagerInstance %s/%s: %w", ssminstance.GetNamespace(), ssminstance.GetName(), err) + } + if resourceID == "" { + resourceID = ssminstance.GetName() + } + + location, _, err := unstructured.NestedString(ssminstance.Object, "spec", "location") + if err != nil { + return nil, fmt.Errorf("reading spec.location from SecureSourceManagerInstance %s/%s: %w", ssminstance.GetNamespace(), ssminstance.GetName(), err) + } + + projectID, err := refsv1beta1.ResolveProjectID(ctx, reader, ssminstance) + if err != nil { + return nil, err + } + + return &SecureSourceManagerInstanceID{ + ProjectID: projectID, + Location: location, + InstanceID: resourceID, + }, nil +} diff --git a/apis/securesourcemanager/v1alpha1/repository_reference.go b/apis/securesourcemanager/v1alpha1/repository_reference.go index fbdba69f1e..07982266f3 100644 --- a/apis/securesourcemanager/v1alpha1/repository_reference.go +++ b/apis/securesourcemanager/v1alpha1/repository_reference.go @@ -151,6 +151,18 @@ func (r *SecureSourceManagerRepositoryRef) Parent() (*SecureSourceManagerReposit return nil, fmt.Errorf("SecureSourceManagerRepositoryRef not initialized from `NewSecureSourceManagerRepositoryRef` or `NormalizedExternal`") } +func (r *SecureSourceManagerRepositoryRef) ResourceID() (string, error) { + if r.External == "" { + return "", fmt.Errorf("reference has not been normalized (external is empty)") + } + + _, resourceID, err := parseSecureSourceManagerRepositoryExternal(r.External) + if err != nil { + return "", err + } + return resourceID, nil +} + type SecureSourceManagerRepositoryParent struct { ProjectID string Location string diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index b109b67b5e..e2d507d943 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -71,10 +71,7 @@ type SecureSourceManagerRepositoryObservedState struct { // CreateTime *string `json:"createTime,omitempty"` // // Output only. Update timestamp. - // UpdateTime *string `json:"updateTime,omitempty" - - // Output only. Unique identifier of the repository. - Uid *string `json:"uid,omitempty"` + // UpdateTime *string `json:"updateTime,omitempty"` // Output only. URIs for the repository. URIs *Repository_URIs `json:"uris,omitempty"` diff --git a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index faee2ed248..6174dcae5f 100644 --- a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -246,6 +246,21 @@ func (in *SecureSourceManagerInstance) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstanceID) DeepCopyInto(out *SecureSourceManagerInstanceID) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceID. +func (in *SecureSourceManagerInstanceID) DeepCopy() *SecureSourceManagerInstanceID { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceID) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerInstanceList) DeepCopyInto(out *SecureSourceManagerInstanceList) { *out = *in @@ -450,6 +465,11 @@ func (in *SecureSourceManagerRepositoryList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerRepositoryObservedState) DeepCopyInto(out *SecureSourceManagerRepositoryObservedState) { *out = *in + if in.URIs != nil { + in, out := &in.URIs, &out.URIs + *out = new(Repository_URIs) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerRepositoryObservedState. @@ -553,7 +573,7 @@ func (in *SecureSourceManagerRepositoryStatus) DeepCopyInto(out *SecureSourceMan if in.ObservedState != nil { in, out := &in.ObservedState, &out.ObservedState *out = new(SecureSourceManagerRepositoryObservedState) - **out = **in + (*in).DeepCopyInto(*out) } } diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml index 36090eb0d1..debada52e3 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml @@ -324,6 +324,22 @@ spec: observedState: description: ObservedState is the state of the resource as most recently observed in GCP. + properties: + uris: + description: Output only. URIs for the repository. + properties: + api: + description: Output only. API is the URI for API access. + type: string + gitHTTPS: + description: Output only. git_https is the git HTTPS URI for + git operations. + type: string + html: + description: Output only. HTML is the URI for user to view + the repository in a browser. + type: string + type: object type: object type: object required: diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index f46a0d1020..a828c54430 100644 --- a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -73,6 +73,23 @@ type SecureSourceManagerRepositorySpec struct { } type RepositoryObservedStateStatus struct { + /* Output only. URIs for the repository. */ + // +optional + Uris *RepositoryUrisStatus `json:"uris,omitempty"` +} + +type RepositoryUrisStatus struct { + /* Output only. API is the URI for API access. */ + // +optional + Api *string `json:"api,omitempty"` + + /* Output only. git_https is the git HTTPS URI for git operations. */ + // +optional + GitHTTPS *string `json:"gitHTTPS,omitempty"` + + /* Output only. HTML is the URI for user to view the repository in a browser. */ + // +optional + Html *string `json:"html,omitempty"` } type SecureSourceManagerRepositoryStatus struct { @@ -94,7 +111,7 @@ type SecureSourceManagerRepositoryStatus struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositorys +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerrepository;gcpsecuresourcemanagerrepositories // +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" diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index e3cb67ccd0..60a724db96 100644 --- a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -135,6 +135,11 @@ func (in *RepositoryInitialConfig) DeepCopy() *RepositoryInitialConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RepositoryObservedStateStatus) DeepCopyInto(out *RepositoryObservedStateStatus) { *out = *in + if in.Uris != nil { + in, out := &in.Uris, &out.Uris + *out = new(RepositoryUrisStatus) + (*in).DeepCopyInto(*out) + } return } @@ -148,6 +153,37 @@ func (in *RepositoryObservedStateStatus) DeepCopy() *RepositoryObservedStateStat return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryUrisStatus) DeepCopyInto(out *RepositoryUrisStatus) { + *out = *in + if in.Api != nil { + in, out := &in.Api, &out.Api + *out = new(string) + **out = **in + } + if in.GitHTTPS != nil { + in, out := &in.GitHTTPS, &out.GitHTTPS + *out = new(string) + **out = **in + } + if in.Html != nil { + in, out := &in.Html, &out.Html + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryUrisStatus. +func (in *RepositoryUrisStatus) DeepCopy() *RepositoryUrisStatus { + if in == nil { + return nil + } + out := new(RepositoryUrisStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerInstance) DeepCopyInto(out *SecureSourceManagerInstance) { *out = *in @@ -382,7 +418,7 @@ func (in *SecureSourceManagerRepositoryStatus) DeepCopyInto(out *SecureSourceMan if in.ObservedState != nil { in, out := &in.ObservedState, &out.ObservedState *out = new(RepositoryObservedStateStatus) - **out = **in + (*in).DeepCopyInto(*out) } return } From 3623d5153bcb41ac052dbb683535033ebd554298 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 5 Nov 2024 16:03:06 +0000 Subject: [PATCH 09/14] Remove comment --- .../v1alpha1/securesourcemanagerrepository_types.go | 1 - 1 file changed, 1 deletion(-) diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index e2d507d943..7dea101457 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -22,7 +22,6 @@ import ( var SecureSourceManagerRepositoryGVK = GroupVersion.WithKind("SecureSourceManagerRepository") -// 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. // SecureSourceManagerRepositorySpec defines the desired state of SecureSourceManagerRepository From d06fc50ec15e1805e76f8e28ecb143b61042653a Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 5 Nov 2024 16:31:29 +0000 Subject: [PATCH 10/14] remove extra resolve instance ref func, add required to location field --- .../v1alpha1/instance_reference.go | 82 ------------------- .../v1alpha1/instance_types.go | 1 + .../securesourcemanagerrepository_types.go | 1 + 3 files changed, 2 insertions(+), 82 deletions(-) diff --git a/apis/securesourcemanager/v1alpha1/instance_reference.go b/apis/securesourcemanager/v1alpha1/instance_reference.go index a35f58bad9..616a5dd8ac 100644 --- a/apis/securesourcemanager/v1alpha1/instance_reference.go +++ b/apis/securesourcemanager/v1alpha1/instance_reference.go @@ -23,7 +23,6 @@ import ( "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/runtime/schema" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -44,12 +43,6 @@ type SecureSourceManagerInstanceRef struct { Namespace string `json:"namespace,omitempty"` } -type SecureSourceManagerInstanceID struct { - ProjectID string - Location string - InstanceID string -} - func ParseSecureSourceManagerInstanceRef(url string) (*SecureSourceManagerInstanceRef, error) { parent, resourceID, err := parseSecureSourceManagerExternal(url) if err != nil { @@ -190,10 +183,6 @@ func (r *SecureSourceManagerInstanceRef) ResourceID() (string, error) { return resourceID, nil } -func (r *SecureSourceManagerInstanceID) String() string { - return fmt.Sprintf("projects/%s/locations/%s/instances/%s", r.ProjectID, r.Location, r.InstanceID) -} - // +k8s:deepcopy-gen=false type ProjectIDAndLocation struct { ProjectID string @@ -211,74 +200,3 @@ func valueOf[T any](t *T) T { } return *t } - -func ResolveSecureSourceManagerInstanceRef(ctx context.Context, reader client.Reader, obj client.Object, ref *SecureSourceManagerInstanceRef) (*SecureSourceManagerInstanceID, error) { - if ref == nil { - return nil, nil - } - - if ref.Name == "" && ref.External == "" { - return nil, fmt.Errorf("must specify either name or external on instanceRef") - } - if ref.External != "" && ref.Name != "" { - return nil, fmt.Errorf("cannot specify both spec.instanceRef.name and spec.instanceRef.external") - } - - if ref.External != "" { - // External should be in the `projects/[projectID]/locations/[Location]/instances/[instanceName]` format. - tokens := strings.Split(ref.External, "/") - if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "instances" { - return &SecureSourceManagerInstanceID{ - ProjectID: tokens[1], - Location: tokens[3], - InstanceID: tokens[5], - }, nil - } - return nil, fmt.Errorf("format of securesourcemanagerinstance external=%q was not known (use projects//locations/[Location]/instances/)", ref.External) - } - - key := types.NamespacedName{ - Namespace: ref.Namespace, - Name: ref.Name, - } - if key.Namespace == "" { - key.Namespace = obj.GetNamespace() - } - - ssminstance := &unstructured.Unstructured{} - ssminstance.SetGroupVersionKind(schema.GroupVersionKind{ - Group: "securesourcemanager.cnrm.cloud.google.com", - Version: "v1alpha1", - Kind: "SecureSourceManagerInstance", - }) - if err := reader.Get(ctx, key, ssminstance); err != nil { - if apierrors.IsNotFound(err) { - return nil, fmt.Errorf("referenced SecureSourceManagerInstance %v not found", key) - } - return nil, fmt.Errorf("error reading referenced SecureSourceManagerInstance %v: %w", key, err) - } - - resourceID, _, err := unstructured.NestedString(ssminstance.Object, "spec", "resourceID") - if err != nil { - return nil, fmt.Errorf("reading spec.resourceID from SecureSourceManagerInstance %s/%s: %w", ssminstance.GetNamespace(), ssminstance.GetName(), err) - } - if resourceID == "" { - resourceID = ssminstance.GetName() - } - - location, _, err := unstructured.NestedString(ssminstance.Object, "spec", "location") - if err != nil { - return nil, fmt.Errorf("reading spec.location from SecureSourceManagerInstance %s/%s: %w", ssminstance.GetNamespace(), ssminstance.GetName(), err) - } - - projectID, err := refsv1beta1.ResolveProjectID(ctx, reader, ssminstance) - if err != nil { - return nil, err - } - - return &SecureSourceManagerInstanceID{ - ProjectID: projectID, - Location: location, - InstanceID: resourceID, - }, nil -} diff --git a/apis/securesourcemanager/v1alpha1/instance_types.go b/apis/securesourcemanager/v1alpha1/instance_types.go index a124630ece..474a81c48a 100644 --- a/apis/securesourcemanager/v1alpha1/instance_types.go +++ b/apis/securesourcemanager/v1alpha1/instance_types.go @@ -30,6 +30,7 @@ type SecureSourceManagerInstanceSpec struct { ProjectRef *refs.ProjectRef `json:"projectRef"` /* Immutable. Location of the instance. */ + // +required Location string `json:"location"` /* Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */ diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index 7dea101457..c63446b2a5 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -32,6 +32,7 @@ type SecureSourceManagerRepositorySpec struct { ProjectRef *refs.ProjectRef `json:"projectRef"` /* Immutable. Location of the instance. */ + // +required Location string `json:"location"` // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" From cf5eed77e79dfb44ecaa980aa2a16dbe27f61fdb Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Tue, 5 Nov 2024 19:44:16 +0000 Subject: [PATCH 11/14] remove immutable on instance ref --- .../v1alpha1/securesourcemanagerrepository_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index c63446b2a5..25d8b3df01 100644 --- a/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -40,7 +40,7 @@ type SecureSourceManagerRepositorySpec struct { // The SecureSourceManagerRepository name. If not given, the metadata.name will be used. ResourceID *string `json:"resourceID,omitempty"` - // Immutable. The name of the instance in which the repository is hosted, formatted as + // The name of the instance in which the repository is hosted, formatted as // `projects/{project_number}/locations/{location_id}/instances/{instance_id}` // +required InstanceRef *SecureSourceManagerInstanceRef `json:"instanceRef,omitempty"` From 0790d82320e01de8044467f993dc2d3c19a8b643 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Wed, 6 Nov 2024 17:05:26 +0000 Subject: [PATCH 12/14] remove deleted struct reference --- .../v1alpha1/zz_generated.deepcopy.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go index 6174dcae5f..e76807ddc4 100644 --- a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go +++ b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -246,21 +246,6 @@ func (in *SecureSourceManagerInstance) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecureSourceManagerInstanceID) DeepCopyInto(out *SecureSourceManagerInstanceID) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceID. -func (in *SecureSourceManagerInstanceID) DeepCopy() *SecureSourceManagerInstanceID { - if in == nil { - return nil - } - out := new(SecureSourceManagerInstanceID) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecureSourceManagerInstanceList) DeepCopyInto(out *SecureSourceManagerInstanceList) { *out = *in From c060669a9db43d60d902afb0a88b2e26c3d19d91 Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Wed, 6 Nov 2024 17:08:43 +0000 Subject: [PATCH 13/14] regenerate crd --- ...epositories.securesourcemanager.cnrm.cloud.google.com.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml index debada52e3..87b8200fc3 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerrepositories.securesourcemanager.cnrm.cloud.google.com.yaml @@ -204,8 +204,8 @@ spec: type: string type: object instanceRef: - description: Immutable. The name of the instance in which the repository - is hosted, formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` + description: The name of the instance in which the repository is hosted, + formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` oneOf: - not: required: From ab2a211946742de6f99a91d94dd395e253849e1b Mon Sep 17 00:00:00 2001 From: Eric Pang Date: Wed, 6 Nov 2024 18:36:26 +0000 Subject: [PATCH 14/14] run make ready pr --- .../v1alpha1/securesourcemanagerrepository_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go index a828c54430..e0c588873d 100644 --- a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerrepository_types.go @@ -58,7 +58,7 @@ type SecureSourceManagerRepositorySpec struct { // +optional InitialConfig *RepositoryInitialConfig `json:"initialConfig,omitempty"` - /* Immutable. The name of the instance in which the repository is hosted, formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` */ + /* The name of the instance in which the repository is hosted, formatted as `projects/{project_number}/locations/{location_id}/instances/{instance_id}` */ InstanceRef v1alpha1.ResourceRef `json:"instanceRef"` /* Immutable. Location of the instance. */