diff --git a/apis/artifactregistry/registry.go b/apis/artifactregistry/registry.go new file mode 100644 index 000000000..28f2cc304 --- /dev/null +++ b/apis/artifactregistry/registry.go @@ -0,0 +1,18 @@ +/* +Copyright 2022 The Crossplane Authors. + +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 artifactregistry contains GCP resources, e.g. Repository (Artifact registry) +package artifactregistry diff --git a/apis/artifactregistry/v1alpha1/doc.go b/apis/artifactregistry/v1alpha1/doc.go new file mode 100644 index 000000000..a1eb85649 --- /dev/null +++ b/apis/artifactregistry/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2022 The Crossplane Authors. + +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 contains managed resources for GCP Artifact Registry Repository +// +kubebuilder:object:generate=true +// +groupName=artifactregistry.gcp.crossplane.io +// +versionName=v1alpha1 +package v1alpha1 diff --git a/apis/artifactregistry/v1alpha1/register.go b/apis/artifactregistry/v1alpha1/register.go new file mode 100644 index 000000000..cb8e80b07 --- /dev/null +++ b/apis/artifactregistry/v1alpha1/register.go @@ -0,0 +1,50 @@ +/* +Copyright 2022 The Crossplane Authors. + +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 ( + "reflect" + + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +// Package type metadata. +const ( + Group = "artifactregistry.gcp.crossplane.io" + Version = "v1alpha1" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} +) + +// Repository type metadata. +var ( + RepositoryKind = reflect.TypeOf(Repository{}).Name() + RepositoryGroupKind = schema.GroupKind{Group: Group, Kind: RepositoryKind}.String() + RepositoryKindAPIVersion = RepositoryKind + "." + SchemeGroupVersion.String() + RepositoryGroupVersionKind = SchemeGroupVersion.WithKind(RepositoryKind) +) + +func init() { + SchemeBuilder.Register(&Repository{}, &RepositoryList{}) +} diff --git a/apis/artifactregistry/v1alpha1/repository_types.go b/apis/artifactregistry/v1alpha1/repository_types.go new file mode 100644 index 000000000..c30530394 --- /dev/null +++ b/apis/artifactregistry/v1alpha1/repository_types.go @@ -0,0 +1,159 @@ +/* +Copyright 2022 The Crossplane Authors. + +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 ( + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + RepositoryFormatUnspecified = "FORMAT_UNSPECIFIED" + RepositoryFormatDocker = "DOCKER" + RepositoryFormatMaven = "MAVEN" + RepositoryFormatNpm = "NPM" + RepositoryFormatApt = "APT" + RepositoryFormatYum = "YUM" + RepositoryFormatPython = "PYTHON" +) + +// RepositoryParameters define the desired state of a Repository +type RepositoryParameters struct { + // Location: The name of the Google Compute zone or region + // +immutable + Location string `json:"location"` + + // Description: The user-provided description of the repository. + // +optional + Description string `json:"description,omitempty"` + + // Format: The format of packages that are stored in the repository. + // + // Possible values: + // "FORMAT_UNSPECIFIED" - Unspecified package format. + // "DOCKER" - Docker package format. + // "MAVEN" - Maven package format. + // "NPM" - NPM package format. + // "PYPI" - PyPI package format. Deprecated, use PYTHON instead. + // "APT" - APT package format. + // "YUM" - YUM package format. + // "PYTHON" - Python package format. + // +immutable + // +kubebuilder:validation:Enum=FORMAT_UNSPECIFIED;DOCKER;MAVEN;NPM;APT;YUM;PYTHON + Format string `json:"format,omitempty"` + + // Labels: Labels with user-defined metadata. This field may contain up + // to 64 entries. Label keys and values may be no longer than 63 + // characters. Label keys must begin with a lowercase letter and may + // only contain lowercase letters, numeric characters, underscores, and + // dashes. + // +optional + Labels map[string]string `json:"labels,omitempty"` + + // MavenConfig: Maven repository config contains repository level + // configuration for the repositories of maven type. + // +optional + MavenConfig *MavenRepositoryConfig `json:"mavenConfig,omitempty"` + + // KmsKeyName is the resource name of the Cloud KMS CryptoKey to be used to + // protect access to messages published on this topic. + // + // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. + // +optional + // +immutable + // +crossplane:generate:reference:type=github.com/crossplane/provider-gcp/apis/kms/v1alpha1.CryptoKey + // +crossplane:generate:reference:extractor=github.com/crossplane/provider-gcp/apis/kms/v1alpha1.CryptoKeyRRN() + KmsKeyName *string `json:"kmsKeyName,omitempty"` + + // KmsKeyNameRef allows you to specify custom resource name of the KMS Key + // to fill KmsKeyName field. + KmsKeyNameRef *xpv1.Reference `json:"kmsKeyNameRef,omitempty"` + + // KmsKeyNameSelector allows you to use selector constraints to select a + // KMS Key. + KmsKeyNameSelector *xpv1.Selector `json:"kmsKeyNameSelector,omitempty"` +} + +// MavenRepositoryConfig: MavenRepositoryConfig is maven related +// repository details. Provides additional configuration details for +// repositories of the maven format type. +type MavenRepositoryConfig struct { + // AllowSnapshotOverwrites: The repository with this flag will allow + // publishing the same snapshot versions. + AllowSnapshotOverwrites bool `json:"allowSnapshotOverwrites,omitempty"` + + // VersionPolicy: Version policy defines the versions that the registry + // will accept. + // + // Possible values: + // "VERSION_POLICY_UNSPECIFIED" - VERSION_POLICY_UNSPECIFIED - the + // version policy is not defined. When the version policy is not + // defined, no validation is performed for the versions. + // "RELEASE" - RELEASE - repository will accept only Release versions. + // "SNAPSHOT" - SNAPSHOT - repository will accept only Snapshot + // versions. + VersionPolicy *string `json:"versionPolicy,omitempty"` +} + +// RepositoryObservation is used to show the observed state of the Repository +type RepositoryObservation struct { + + // CreateTime: The time when the repository was created. + CreateTime string `json:"createTime,omitempty"` + + // UpdateTime: The time when the repository was last updated. + UpdateTime string `json:"updateTime,omitempty"` +} + +// RepositorySpec defines the desired state of Repository +type RepositorySpec struct { + xpv1.ResourceSpec `json:",inline"` + ForProvider RepositoryParameters `json:"forProvider"` +} + +// RepositoryStatus defines the observed state of Repository +type RepositoryStatus struct { + xpv1.ResourceStatus `json:",inline"` + AtProvider RepositoryObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,gcp} +// Repository is a managed resource that represents a Google Artifact registry Repository. +type Repository struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec RepositorySpec `json:"spec,omitempty"` + Status RepositoryStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// RepositoryList contains a list of Repository +type RepositoryList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Repository `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Repository{}, &RepositoryList{}) +} diff --git a/apis/artifactregistry/v1alpha1/zz_generated.deepcopy.go b/apis/artifactregistry/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..f6275aa2d --- /dev/null +++ b/apis/artifactregistry/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,197 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The Crossplane Authors. + +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MavenRepositoryConfig) DeepCopyInto(out *MavenRepositoryConfig) { + *out = *in + if in.VersionPolicy != nil { + in, out := &in.VersionPolicy, &out.VersionPolicy + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MavenRepositoryConfig. +func (in *MavenRepositoryConfig) DeepCopy() *MavenRepositoryConfig { + if in == nil { + return nil + } + out := new(MavenRepositoryConfig) + 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) DeepCopyInto(out *Repository) { + *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 Repository. +func (in *Repository) DeepCopy() *Repository { + if in == nil { + return nil + } + out := new(Repository) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Repository) 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 *RepositoryList) DeepCopyInto(out *RepositoryList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Repository, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryList. +func (in *RepositoryList) DeepCopy() *RepositoryList { + if in == nil { + return nil + } + out := new(RepositoryList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RepositoryList) 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 *RepositoryObservation) DeepCopyInto(out *RepositoryObservation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryObservation. +func (in *RepositoryObservation) DeepCopy() *RepositoryObservation { + if in == nil { + return nil + } + out := new(RepositoryObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryParameters) DeepCopyInto(out *RepositoryParameters) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.MavenConfig != nil { + in, out := &in.MavenConfig, &out.MavenConfig + *out = new(MavenRepositoryConfig) + (*in).DeepCopyInto(*out) + } + if in.KmsKeyName != nil { + in, out := &in.KmsKeyName, &out.KmsKeyName + *out = new(string) + **out = **in + } + if in.KmsKeyNameRef != nil { + in, out := &in.KmsKeyNameRef, &out.KmsKeyNameRef + *out = new(v1.Reference) + **out = **in + } + if in.KmsKeyNameSelector != nil { + in, out := &in.KmsKeyNameSelector, &out.KmsKeyNameSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryParameters. +func (in *RepositoryParameters) DeepCopy() *RepositoryParameters { + if in == nil { + return nil + } + out := new(RepositoryParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositorySpec) DeepCopyInto(out *RepositorySpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositorySpec. +func (in *RepositorySpec) DeepCopy() *RepositorySpec { + if in == nil { + return nil + } + out := new(RepositorySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryStatus) DeepCopyInto(out *RepositoryStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + out.AtProvider = in.AtProvider +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryStatus. +func (in *RepositoryStatus) DeepCopy() *RepositoryStatus { + if in == nil { + return nil + } + out := new(RepositoryStatus) + in.DeepCopyInto(out) + return out +} diff --git a/apis/artifactregistry/v1alpha1/zz_generated.managed.go b/apis/artifactregistry/v1alpha1/zz_generated.managed.go new file mode 100644 index 000000000..673f81b6d --- /dev/null +++ b/apis/artifactregistry/v1alpha1/zz_generated.managed.go @@ -0,0 +1,77 @@ +/* +Copyright 2022 The Crossplane Authors. + +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Repository. +func (mg *Repository) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Repository. +func (mg *Repository) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetProviderConfigReference of this Repository. +func (mg *Repository) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this Repository. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *Repository) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetWriteConnectionSecretToReference of this Repository. +func (mg *Repository) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Repository. +func (mg *Repository) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Repository. +func (mg *Repository) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetProviderConfigReference of this Repository. +func (mg *Repository) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this Repository. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *Repository) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetWriteConnectionSecretToReference of this Repository. +func (mg *Repository) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/artifactregistry/v1alpha1/zz_generated.managedlist.go b/apis/artifactregistry/v1alpha1/zz_generated.managedlist.go new file mode 100644 index 000000000..a35b040c8 --- /dev/null +++ b/apis/artifactregistry/v1alpha1/zz_generated.managedlist.go @@ -0,0 +1,30 @@ +/* +Copyright 2022 The Crossplane Authors. + +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import resource "github.com/crossplane/crossplane-runtime/pkg/resource" + +// GetItems of this RepositoryList. +func (l *RepositoryList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/apis/artifactregistry/v1alpha1/zz_generated.resolvers.go b/apis/artifactregistry/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 000000000..6d6edf1be --- /dev/null +++ b/apis/artifactregistry/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,53 @@ +/* +Copyright 2022 The Crossplane Authors. + +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" + v1alpha1 "github.com/crossplane/provider-gcp/apis/kms/v1alpha1" + errors "github.com/pkg/errors" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ResolveReferences of this Repository. +func (mg *Repository) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.KmsKeyName), + Extract: v1alpha1.CryptoKeyRRN(), + Reference: mg.Spec.ForProvider.KmsKeyNameRef, + Selector: mg.Spec.ForProvider.KmsKeyNameSelector, + To: reference.To{ + List: &v1alpha1.CryptoKeyList{}, + Managed: &v1alpha1.CryptoKey{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.KmsKeyName") + } + mg.Spec.ForProvider.KmsKeyName = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.KmsKeyNameRef = rsp.ResolvedReference + + return nil +} diff --git a/apis/gcp.go b/apis/gcp.go index 47e4c3dcd..d5bc31858 100644 --- a/apis/gcp.go +++ b/apis/gcp.go @@ -20,6 +20,7 @@ package apis import ( "k8s.io/apimachinery/pkg/runtime" + artifactregistry "github.com/crossplane/provider-gcp/apis/artifactregistry/v1alpha1" cachev1beta1 "github.com/crossplane/provider-gcp/apis/cache/v1beta1" computev1alpha1 "github.com/crossplane/provider-gcp/apis/compute/v1alpha1" computev1beta1 "github.com/crossplane/provider-gcp/apis/compute/v1beta1" @@ -57,6 +58,7 @@ func init() { storagev1alpha3.SchemeBuilder.AddToScheme, dnsv1alpha1.SchemeBuilder.AddToScheme, registry.SchemeBuilder.AddToScheme, + artifactregistry.SchemeBuilder.AddToScheme, ) } diff --git a/build b/build index d393bdfee..bd63a4167 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit d393bdfee0adf9732e32ecca8437586917fc5018 +Subproject commit bd63a4167ae20a71788537217b022fced8f2f854 diff --git a/examples/artifact-registry/repository.yaml b/examples/artifact-registry/repository.yaml new file mode 100644 index 000000000..2d2763034 --- /dev/null +++ b/examples/artifact-registry/repository.yaml @@ -0,0 +1,13 @@ +apiVersion: artifactregistry.gcp.crossplane.io/v1alpha1 +kind: Repository +metadata: + name: my-repository +spec: + forProvider: + location: us-west2 + labels: + example: "true" + format: DOCKER + + providerConfigRef: + name: gcp-provider diff --git a/go.mod b/go.mod index 7fb43a6c3..44ec4158d 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/crossplane/provider-gcp go 1.16 require ( + cloud.google.com/go/iam v0.1.1 // indirect cloud.google.com/go/storage v1.15.0 github.com/crossplane/crossplane-runtime v0.15.1-0.20211202230900-d43d510ec578 github.com/crossplane/crossplane-tools v0.0.0-20210916125540-071de511ae8e @@ -11,8 +12,9 @@ require ( github.com/imdario/mergo v0.3.12 github.com/mitchellh/copystructure v1.0.0 github.com/pkg/errors v0.9.1 - google.golang.org/api v0.52.0 - google.golang.org/grpc v1.39.0 + google.golang.org/api v0.64.0 + google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 // indirect + google.golang.org/grpc v1.40.1 gopkg.in/alecthomas/kingpin.v2 v2.2.6 k8s.io/api v0.21.3 k8s.io/apimachinery v0.21.3 diff --git a/go.sum b/go.sum index ae4c94024..c811f210f 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,14 @@ cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.88.0 h1:MZ2cf9Elnv1wqccq8ooKO2MqHQLc+ChCp/+QWObCpxg= -cloud.google.com/go v0.88.0/go.mod h1:dnKwfYbP9hQhefiUvpbcAyoGSHUrOxR20JVElLiUvEY= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.1 h1:i2ukt/HTgcBhgL1J0Dx9w7gb5oCe7zWEcumzQSh+9I4= +cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -32,6 +38,8 @@ cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM7 cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/iam v0.1.1 h1:4CapQyNFjiksks1/x7jsvsygFPhihslYk5GptIrlX68= +cloud.google.com/go/iam v0.1.1/go.mod h1:CKqrcnI/suGpybEHxZ7BMehL0oA4LpdyJdUlTl9jVMw= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -425,7 +433,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210715191844-86eeefc3e471/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -433,8 +442,10 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= @@ -503,7 +514,6 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -929,8 +939,11 @@ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210413134643-5e61552d6c78/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1030,8 +1043,14 @@ golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= @@ -1150,8 +1169,15 @@ google.golang.org/api v0.45.0/go.mod h1:ISLIJCedJolbZvDfAk+Ctuq5hf+aJ33WgtUsfyFo google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.52.0 h1:m5FLEd6dp5CU1F0tMWyqDi2XjchviIz8ntzOSz7w8As= -google.golang.org/api v0.52.0/go.mod h1:Him/adpjt0sxtkWViy0b6xyKW/SD71CwdJ7HqJo7SrU= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.64.0 h1:l3pi8ncrQgB9+ncFw3A716L8lWujnXniBYbxWqqy6tE= +google.golang.org/api v0.64.0/go.mod h1:931CdxA8Rm4t6zqTFGSsgwbAEZ2+GMYurbndwSimebM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1212,9 +1238,25 @@ google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxH google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210721163202-f1cecdd8b78a/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f h1:YORWxaStkWBnWgELOHTmDrqNlFXuVGEbhwbB5iK94bQ= -google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220111164026-67b88f271998/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 h1:YxHp5zqIcAShDEvRr5/0rVESVS+njYF68PSdazrNLJo= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1241,8 +1283,11 @@ google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1 h1:pnP7OclFFFgFi4VHQDQDaoXUVauOFyktqTsqqgzFKbc= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/package/crds/artifactregistry.gcp.crossplane.io_repositories.yaml b/package/crds/artifactregistry.gcp.crossplane.io_repositories.yaml new file mode 100644 index 000000000..6a16b6411 --- /dev/null +++ b/package/crds/artifactregistry.gcp.crossplane.io_repositories.yaml @@ -0,0 +1,249 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.2 + creationTimestamp: null + name: repositories.artifactregistry.gcp.crossplane.io +spec: + group: artifactregistry.gcp.crossplane.io + names: + categories: + - crossplane + - managed + - gcp + kind: Repository + listKind: RepositoryList + plural: repositories + singular: repository + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Repository is a managed resource that represents a Google Artifact + registry Repository. + 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: RepositorySpec defines the desired state of Repository + properties: + deletionPolicy: + default: Delete + description: DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. + enum: + - Orphan + - Delete + type: string + forProvider: + description: RepositoryParameters define the desired state of a Repository + properties: + description: + description: 'Description: The user-provided description of the + repository.' + type: string + format: + description: "Format: The format of packages that are stored in + the repository. \n Possible values: \"FORMAT_UNSPECIFIED\" + - Unspecified package format. \"DOCKER\" - Docker package + format. \"MAVEN\" - Maven package format. \"NPM\" - NPM + package format. \"PYPI\" - PyPI package format. Deprecated, + use PYTHON instead. \"APT\" - APT package format. \"YUM\" + - YUM package format. \"PYTHON\" - Python package format." + enum: + - FORMAT_UNSPECIFIED + - DOCKER + - MAVEN + - NPM + - APT + - YUM + - PYTHON + type: string + kmsKeyName: + description: "KmsKeyName is the resource name of the Cloud KMS + CryptoKey to be used to protect access to messages published + on this topic. \n The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`." + type: string + kmsKeyNameRef: + description: KmsKeyNameRef allows you to specify custom resource + name of the KMS Key to fill KmsKeyName field. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + kmsKeyNameSelector: + description: KmsKeyNameSelector allows you to use selector constraints + to select a KMS Key. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + type: object + labels: + additionalProperties: + type: string + description: 'Labels: Labels with user-defined metadata. This + field may contain up to 64 entries. Label keys and values may + be no longer than 63 characters. Label keys must begin with + a lowercase letter and may only contain lowercase letters, numeric + characters, underscores, and dashes.' + type: object + location: + description: 'Location: The name of the Google Compute zone or + region' + type: string + mavenConfig: + description: 'MavenConfig: Maven repository config contains repository + level configuration for the repositories of maven type.' + properties: + allowSnapshotOverwrites: + description: 'AllowSnapshotOverwrites: The repository with + this flag will allow publishing the same snapshot versions.' + type: boolean + versionPolicy: + description: "VersionPolicy: Version policy defines the versions + that the registry will accept. \n Possible values: \"VERSION_POLICY_UNSPECIFIED\" + - VERSION_POLICY_UNSPECIFIED - the version policy is not + defined. When the version policy is not defined, no validation + is performed for the versions. \"RELEASE\" - RELEASE - + repository will accept only Release versions. \"SNAPSHOT\" + - SNAPSHOT - repository will accept only Snapshot versions." + type: string + type: object + required: + - location + type: object + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: RepositoryStatus defines the observed state of Repository + properties: + atProvider: + description: RepositoryObservation is used to show the observed state + of the Repository + properties: + createTime: + description: 'CreateTime: The time when the repository was created.' + type: string + updateTime: + description: 'UpdateTime: The time when the repository was last + updated.' + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/clients/artifactregistry/repository.go b/pkg/clients/artifactregistry/repository.go new file mode 100644 index 000000000..0d2e4e1a5 --- /dev/null +++ b/pkg/clients/artifactregistry/repository.go @@ -0,0 +1,120 @@ +package artifactregistry + +import ( + "fmt" + "strings" + + "github.com/google/go-cmp/cmp" + + "github.com/crossplane/provider-gcp/apis/artifactregistry/v1alpha1" + gcp "github.com/crossplane/provider-gcp/pkg/clients" + artifactregistry "google.golang.org/api/artifactregistry/v1beta2" +) + +const ( + repositoryNameFormat = "projects/%s/locations/%s/repositories/%s" + repositoryParentFormat = "projects/%s/locations/%s" +) + +// GetFullyQualifiedName builds the fully qualified name of the Repository. +func GetFullyQualifiedName(project, location, name string) string { + return fmt.Sprintf(repositoryNameFormat, project, location, name) +} + +// GetFullyQualifiedParent builds the fully qualified parent name of the Repository. +func GetFullyQualifiedParent(project, location string) string { + return fmt.Sprintf(repositoryParentFormat, project, location) +} + +// GenerateRepository produces a Repository that is configured via given RepositoryParameters. +func GenerateRepository(projectID, name string, p v1alpha1.RepositoryParameters) *artifactregistry.Repository { + r := &artifactregistry.Repository{ + Name: name, + Description: p.Description, + Format: p.Format, + Labels: p.Labels, + KmsKeyName: gcp.StringValue(p.KmsKeyName), + } + setMavenConfig(p, r) + return r +} + +// setMavenConfig sets MavenConfig of Repository based on RepositoryParameters. +func setMavenConfig(p v1alpha1.RepositoryParameters, r *artifactregistry.Repository) { + if p.MavenConfig != nil { + r.MavenConfig = &artifactregistry.MavenRepositoryConfig{ + AllowSnapshotOverwrites: p.MavenConfig.AllowSnapshotOverwrites, + VersionPolicy: *p.MavenConfig.VersionPolicy, + } + + } +} + +// LateInitialize fills the empty fields of RepositoryParameters if the corresponding +// fields are given in Repository. +func LateInitialize(p *v1alpha1.RepositoryParameters, r artifactregistry.Repository) { // nolint:gocyclo + + if p.Description == "" && r.Description != "" { + p.Description = r.Description + } + + if p.Format == "" && r.Format != "" { + p.Format = r.Format + } + + if len(p.Labels) == 0 && len(r.Labels) != 0 { + p.Labels = map[string]string{} + for k, v := range r.Labels { + p.Labels[k] = v + } + } + if p.KmsKeyName == nil && len(r.KmsKeyName) != 0 { + p.KmsKeyName = gcp.StringPtr(r.KmsKeyName) + } + if p.MavenConfig == nil && r.MavenConfig != nil { + p.MavenConfig = &v1alpha1.MavenRepositoryConfig{ + AllowSnapshotOverwrites: r.MavenConfig.AllowSnapshotOverwrites, + VersionPolicy: &r.MavenConfig.VersionPolicy, + } + } +} + +// IsUpToDate checks whether Repository is configured with given RepositoryParameters. +func IsUpToDate(projectID string, p v1alpha1.RepositoryParameters, r artifactregistry.Repository) bool { + observed := &v1alpha1.RepositoryParameters{} + LateInitialize(observed, r) + + return cmp.Equal(observed, &p) +} + +// GenerateUpdateRequest produces a (Repository, updateMask) with the difference +// between RepositoryParameters and Repository. +func GenerateUpdateRequest(name string, p v1alpha1.RepositoryParameters, r artifactregistry.Repository) (*artifactregistry.Repository, string) { + observed := &v1alpha1.RepositoryParameters{} + LateInitialize(observed, r) + ur := &artifactregistry.Repository{ + Name: name, + } + mask := []string{} + + if !cmp.Equal(p.Description, observed.Description) { + mask = append(mask, "description") + ur.Description = p.Description + } + + if !cmp.Equal(p.MavenConfig, observed.MavenConfig) { + mask = append(mask, "mavenConfig") + if p.MavenConfig != nil { + ur.MavenConfig = &artifactregistry.MavenRepositoryConfig{ + AllowSnapshotOverwrites: p.MavenConfig.AllowSnapshotOverwrites, + VersionPolicy: gcp.StringValue(p.MavenConfig.VersionPolicy), + } + } + } + if !cmp.Equal(p.Labels, observed.Labels) { + mask = append(mask, "labels") + ur.Labels = p.Labels + } + updateMask := strings.Join(mask, ",") + return ur, updateMask +} diff --git a/pkg/clients/cluster/cluster.go b/pkg/clients/cluster/cluster.go index af14bff88..cf79f16f9 100644 --- a/pkg/clients/cluster/cluster.go +++ b/pkg/clients/cluster/cluster.go @@ -995,20 +995,6 @@ func newBinaryAuthorizationUpdateFn(in *v1beta2.BinaryAuthorization) UpdateFn { } } -// newAutopilotUpdateFn returns a function that updates the Autopilot of a cluster. -func newAutopilotUpdateFn(in *v1beta2.Autopilot) UpdateFn { - return func(ctx context.Context, s *container.Service, name string) (*container.Operation, error) { - out := &container.Cluster{} - GenerateAutopilot(in, out) - update := &container.UpdateClusterRequest{ - Update: &container.ClusterUpdate{ - DesiredAutopilot: out.Autopilot, - }, - } - return s.Projects.Locations.Clusters.Update(name, update).Context(ctx).Do() - } -} - // newDatabaseEncryptionUpdateFn returns a function that updates the DatabaseEncryption of a cluster. func newDatabaseEncryptionUpdateFn(in *v1beta2.DatabaseEncryption) UpdateFn { return func(ctx context.Context, s *container.Service, name string) (*container.Operation, error) { @@ -1286,9 +1272,9 @@ func IsUpToDate(name string, in *v1beta2.ClusterParameters, observed *container. cmpopts.IgnoreFields(container.AddonsConfig{}, "NetworkPolicyConfig.ForceSendFields")) { return false, newAddonsConfigUpdateFn(in.AddonsConfig), nil } - if !cmp.Equal(desired.Autopilot, observed.Autopilot, cmpopts.EquateEmpty()) { - return false, newAutopilotUpdateFn(in.Autopilot), nil - } + // if !cmp.Equal(desired.Autopilot, observed.Autopilot, cmpopts.EquateEmpty()) { + // return false, newAutopilotUpdateFn(in.Autopilot), nil + // } if !cmp.Equal(desired.Autoscaling, observed.Autoscaling, cmpopts.EquateEmpty()) { return false, newAutoscalingUpdateFn(in.Autoscaling), nil } diff --git a/pkg/controller/artifactregistry/artifactregistry.go b/pkg/controller/artifactregistry/artifactregistry.go new file mode 100644 index 000000000..cbf02d0b1 --- /dev/null +++ b/pkg/controller/artifactregistry/artifactregistry.go @@ -0,0 +1,174 @@ +/* +Copyright 2022 The Crossplane Authors. + +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 artifactregistry + +import ( + "context" + "fmt" + + "github.com/crossplane/crossplane-runtime/pkg/controller" + + "github.com/google/go-cmp/cmp" + artifactregistry "google.golang.org/api/artifactregistry/v1beta2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/errors" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + + "github.com/crossplane/provider-gcp/apis/artifactregistry/v1alpha1" + gcp "github.com/crossplane/provider-gcp/pkg/clients" + repository "github.com/crossplane/provider-gcp/pkg/clients/artifactregistry" +) + +const ( + errNewClient = "cannot create new Artifact registry Service" + errNotRepository = "managed resource is not of type Repository" + errCreateRepository = "cannot create Repository" + errGetRepository = "cannot get Repository" + errUpdateRepository = "cannot update Repository custom resource" + errDeleteRepository = "cannot delete Repository" +) + +// SetupRepository adds a controller that reconciles Repositories. +func SetupRepository(mgr ctrl.Manager, o controller.Options) error { + name := managed.ControllerName(v1alpha1.RepositoryGroupKind) + + r := managed.NewReconciler(mgr, + resource.ManagedKind(v1alpha1.RepositoryGroupVersionKind), + managed.WithExternalConnecter(&repositoryConnecter{client: mgr.GetClient()}), + managed.WithPollInterval(o.PollInterval), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name)))) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + For(&v1alpha1.Repository{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} + +type repositoryConnecter struct { + client client.Client +} + +// Connect returns an ExternalClient with necessary information to talk to GCP API. +func (c *repositoryConnecter) Connect(ctx context.Context, mg resource.Managed) (managed.ExternalClient, error) { + projectID, opts, err := gcp.GetAuthInfo(ctx, c.client, mg) + if err != nil { + return nil, err + } + + s, err := artifactregistry.NewService(ctx, opts) + if err != nil { + return nil, errors.Wrap(err, errNewClient) + } + + return &repositoryExternal{projectID: projectID, client: c.client, ps: s}, nil +} + +type repositoryExternal struct { + projectID string + client client.Client + ps *artifactregistry.Service +} + +// Observe makes observation about the external resource. +func (e *repositoryExternal) Observe(ctx context.Context, mg resource.Managed) (managed.ExternalObservation, error) { + cr, ok := mg.(*v1alpha1.Repository) + if !ok { + return managed.ExternalObservation{}, errors.New(errNotRepository) + } + + r, err := e.ps.Projects.Locations.Repositories.Get(repository.GetFullyQualifiedName(e.projectID, cr.Spec.ForProvider.Location, meta.GetExternalName(cr))).Context(ctx).Do() + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(resource.Ignore(gcp.IsErrorNotFound, err), errGetRepository) + } + + currentSpec := cr.Spec.ForProvider.DeepCopy() + repository.LateInitialize(&cr.Spec.ForProvider, *r) + + if !cmp.Equal(currentSpec, &cr.Spec.ForProvider) { + if err := e.client.Update(ctx, cr); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errUpdateRepository) + } + } + + cr.Status.AtProvider.CreateTime = r.CreateTime + cr.Status.AtProvider.UpdateTime = r.UpdateTime + cr.SetConditions(xpv1.Available()) + + return managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: repository.IsUpToDate(e.projectID, cr.Spec.ForProvider, *r), + }, nil +} + +// Create initiates creation of external resource. +func (e *repositoryExternal) Create(ctx context.Context, mg resource.Managed) (managed.ExternalCreation, error) { + cr, ok := mg.(*v1alpha1.Repository) + if !ok { + return managed.ExternalCreation{}, errors.New(errNotRepository) + } + + cr.SetConditions(xpv1.Creating()) + + parent := repository.GetFullyQualifiedParent(e.projectID, cr.Spec.ForProvider.Location) + desired := repository.GenerateRepository(e.projectID, meta.GetExternalName(cr), cr.Spec.ForProvider) + fmt.Println("desired", desired) + _, err := e.ps.Projects.Locations.Repositories.Create(parent, + desired).RepositoryId(meta.GetExternalName(cr)).Context(ctx).Do() + + return managed.ExternalCreation{}, errors.Wrap(err, errCreateRepository) +} + +// Update initiates an update to the external resource. +func (e *repositoryExternal) Update(ctx context.Context, mg resource.Managed) (managed.ExternalUpdate, error) { + cr, ok := mg.(*v1alpha1.Repository) + if !ok { + return managed.ExternalUpdate{}, errors.New(errNotRepository) + } + + r, err := e.ps.Projects.Locations.Repositories.Get(repository.GetFullyQualifiedName(e.projectID, cr.Spec.ForProvider.Location, meta.GetExternalName(cr))).Context(ctx).Do() + if err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, errGetRepository) + } + + updated, updateMask := repository.GenerateUpdateRequest(meta.GetExternalName(cr), cr.Spec.ForProvider, *r) + _, err = e.ps.Projects.Locations.Repositories.Patch(repository.GetFullyQualifiedName(e.projectID, cr.Spec.ForProvider.Location, meta.GetExternalName(cr)), + updated).UpdateMask(updateMask).Context(ctx).Do() + + return managed.ExternalUpdate{}, errors.Wrap(err, errUpdateRepository) +} + +// Delete initiates an deletion of the external resource. +func (e *repositoryExternal) Delete(ctx context.Context, mg resource.Managed) error { + cr, ok := mg.(*v1alpha1.Repository) + if !ok { + return errors.New(errNotRepository) + } + + _, err := e.ps.Projects.Locations.Repositories.Delete(repository.GetFullyQualifiedName(e.projectID, cr.Spec.ForProvider.Location, + meta.GetExternalName(cr))).Context(ctx).Do() + + return errors.Wrap(resource.Ignore(gcp.IsErrorNotFound, err), errDeleteRepository) +} diff --git a/pkg/controller/gcp.go b/pkg/controller/gcp.go index 3c32f02df..5c5d39ace 100644 --- a/pkg/controller/gcp.go +++ b/pkg/controller/gcp.go @@ -21,6 +21,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/provider-gcp/pkg/controller/artifactregistry" "github.com/crossplane/provider-gcp/pkg/controller/cache" "github.com/crossplane/provider-gcp/pkg/controller/compute" "github.com/crossplane/provider-gcp/pkg/controller/config" @@ -63,6 +64,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { storage.SetupBucketPolicy, storage.SetupBucketPolicyMember, registry.SetupContainerRegistry, + artifactregistry.SetupRepository, } { if err := setup(mgr, o); err != nil { return err