From 90128823267db93f67746baff0021be53d8dd106 Mon Sep 17 00:00:00 2001 From: Asaf Haim Date: Tue, 15 Oct 2024 17:18:50 +0300 Subject: [PATCH 1/2] Added RepositoryCollaborator resource (human modified files) Signed-off-by: Asaf Haim --- README.md | 1 + config/external_name.go | 2 ++ config/provider.go | 2 ++ config/repositorycollaborator/config.go | 17 +++++++++++++ tests/cases/repo-collaborator/repository.yaml | 25 +++++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 config/repositorycollaborator/config.go create mode 100644 tests/cases/repo-collaborator/repository.yaml diff --git a/README.md b/README.md index 81045a4..7508f66 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ spec: | `BranchProtection` | `repo` | `github_branch_protection` | | | `RepositoryFile` | `repo` | `github_repository_file` | | | `RepositoryAutolinkReference` | `repo` | `github_repository_autolink_reference` | | +| `RepositoryCollaborator` | `repo` | `github_repository_collaborator` | | | `RepositoryWebhook` | `repo` | `github_repository_webhook` | | | `PullRequest` | `repo` | `github_repository_pull_request` | | | `DeployKey` | `repo` | `github_repository_deploy_key` | | diff --git a/config/external_name.go b/config/external_name.go index 1bc7b52..eaed821 100644 --- a/config/external_name.go +++ b/config/external_name.go @@ -51,6 +51,8 @@ var terraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{ "github_organization_ruleset": config.IdentifierFromProvider, // Can be imported using the following format: {{ repository }}/{{ id }} or {{ key_prefix }}. "github_repository_autolink_reference": config.IdentifierFromProvider, + // Can be imported using the following format: {{ repository }}:{{ username }}. + "github_repository_collaborator": config.IdentifierFromProvider, } // cliReconciledExternalNameConfigs contains all external name configurations diff --git a/config/provider.go b/config/provider.go index 3640259..627ead7 100644 --- a/config/provider.go +++ b/config/provider.go @@ -22,6 +22,7 @@ import ( "github.com/crossplane-contrib/provider-upjet-github/config/pullrequest" "github.com/crossplane-contrib/provider-upjet-github/config/repository" "github.com/crossplane-contrib/provider-upjet-github/config/repositoryautolinkreference" + "github.com/crossplane-contrib/provider-upjet-github/config/repositorycollaborator" "github.com/crossplane-contrib/provider-upjet-github/config/repositoryfile" "github.com/crossplane-contrib/provider-upjet-github/config/repositorywebhook" "github.com/crossplane-contrib/provider-upjet-github/config/team" @@ -79,6 +80,7 @@ func GetProvider(ctx context.Context) (*ujconfig.Provider, error) { organization.Configure, organizationruleset.Configure, repositoryautolinkreference.Configure, + repositorycollaborator.Configure, membership.Configure, teamsettings.Configure, teamsyncgroupmapping.Configure, diff --git a/config/repositorycollaborator/config.go b/config/repositorycollaborator/config.go new file mode 100644 index 0000000..bd74b13 --- /dev/null +++ b/config/repositorycollaborator/config.go @@ -0,0 +1,17 @@ +package repositorycollaborator + +import "github.com/crossplane/upjet/pkg/config" + +// Configure github_repository_collaborator resource. +func Configure(p *config.Provider) { + p.AddResourceConfigurator("github_repository_collaborator", func(r *config.Resource) { + // We need to override the default group that upjet generated for + // this resource, which would be "github" + r.Kind = "RepositoryCollaborator" + r.ShortGroup = "repo" + + r.References["repository"] = config.Reference{ + TerraformName: "github_repository", + } + }) +} diff --git a/tests/cases/repo-collaborator/repository.yaml b/tests/cases/repo-collaborator/repository.yaml new file mode 100644 index 0000000..16798b8 --- /dev/null +++ b/tests/cases/repo-collaborator/repository.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: repo.github.upbound.io/v1alpha1 +kind: Repository +metadata: + name: github-crossplane-collaborator-test +spec: + forProvider: + visibility: public + autoInit: true + gitignoreTemplate: Terraform + providerConfigRef: + name: default +--- +apiVersion: repo.github.upbound.io/v1alpha1 +kind: RepositoryCollaborator +metadata: + name: repo-collaborator +spec: + forProvider: + repositoryRef: + name: github-crossplane-collaborator-test + username: someuser + permission: admin + providerConfigRef: + name: default From 4a8990b62002d469bb87a0a69a049611e6531e3c Mon Sep 17 00:00:00 2001 From: Atze de Vries Date: Mon, 9 Dec 2024 13:55:21 +0100 Subject: [PATCH 2/2] add generated resources to PR --- .../v1alpha1/zz_generated.conversion_hubs.go | 3 + apis/repo/v1alpha1/zz_generated.deepcopy.go | 229 ++++++++ apis/repo/v1alpha1/zz_generated.managed.go | 60 ++ .../repo/v1alpha1/zz_generated.managedlist.go | 9 + apis/repo/v1alpha1/zz_generated.resolvers.go | 42 ++ .../zz_repositorycollaborator_terraformed.go | 129 ++++ .../zz_repositorycollaborator_types.go | 166 ++++++ .../repo/v1alpha1/repositorycollaborator.yaml | 15 + .../repositorycollaborator/zz_controller.go | 91 +++ internal/controller/zz_setup.go | 2 + ...ub.upbound.io_repositorycollaborators.yaml | 551 ++++++++++++++++++ 11 files changed, 1297 insertions(+) create mode 100755 apis/repo/v1alpha1/zz_repositorycollaborator_terraformed.go create mode 100755 apis/repo/v1alpha1/zz_repositorycollaborator_types.go create mode 100644 examples-generated/repo/v1alpha1/repositorycollaborator.yaml create mode 100755 internal/controller/repo/repositorycollaborator/zz_controller.go create mode 100644 package/crds/repo.github.upbound.io_repositorycollaborators.yaml diff --git a/apis/repo/v1alpha1/zz_generated.conversion_hubs.go b/apis/repo/v1alpha1/zz_generated.conversion_hubs.go index 89d787a..d1722e1 100755 --- a/apis/repo/v1alpha1/zz_generated.conversion_hubs.go +++ b/apis/repo/v1alpha1/zz_generated.conversion_hubs.go @@ -27,6 +27,9 @@ func (tr *Repository) Hub() {} // Hub marks this type as a conversion hub. func (tr *RepositoryAutolinkReference) Hub() {} +// Hub marks this type as a conversion hub. +func (tr *RepositoryCollaborator) Hub() {} + // Hub marks this type as a conversion hub. func (tr *RepositoryFile) Hub() {} diff --git a/apis/repo/v1alpha1/zz_generated.deepcopy.go b/apis/repo/v1alpha1/zz_generated.deepcopy.go index d698b14..17bc796 100644 --- a/apis/repo/v1alpha1/zz_generated.deepcopy.go +++ b/apis/repo/v1alpha1/zz_generated.deepcopy.go @@ -1921,6 +1921,235 @@ func (in *RepositoryAutolinkReferenceStatus) DeepCopy() *RepositoryAutolinkRefer return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryCollaborator) DeepCopyInto(out *RepositoryCollaborator) { + *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 RepositoryCollaborator. +func (in *RepositoryCollaborator) DeepCopy() *RepositoryCollaborator { + if in == nil { + return nil + } + out := new(RepositoryCollaborator) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RepositoryCollaborator) 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 *RepositoryCollaboratorInitParameters) DeepCopyInto(out *RepositoryCollaboratorInitParameters) { + *out = *in + if in.Permission != nil { + in, out := &in.Permission, &out.Permission + *out = new(string) + **out = **in + } + if in.PermissionDiffSuppression != nil { + in, out := &in.PermissionDiffSuppression, &out.PermissionDiffSuppression + *out = new(bool) + **out = **in + } + if in.Repository != nil { + in, out := &in.Repository, &out.Repository + *out = new(string) + **out = **in + } + if in.RepositoryRef != nil { + in, out := &in.RepositoryRef, &out.RepositoryRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RepositorySelector != nil { + in, out := &in.RepositorySelector, &out.RepositorySelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorInitParameters. +func (in *RepositoryCollaboratorInitParameters) DeepCopy() *RepositoryCollaboratorInitParameters { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryCollaboratorList) DeepCopyInto(out *RepositoryCollaboratorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]RepositoryCollaborator, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorList. +func (in *RepositoryCollaboratorList) DeepCopy() *RepositoryCollaboratorList { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RepositoryCollaboratorList) 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 *RepositoryCollaboratorObservation) DeepCopyInto(out *RepositoryCollaboratorObservation) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.InvitationID != nil { + in, out := &in.InvitationID, &out.InvitationID + *out = new(string) + **out = **in + } + if in.Permission != nil { + in, out := &in.Permission, &out.Permission + *out = new(string) + **out = **in + } + if in.PermissionDiffSuppression != nil { + in, out := &in.PermissionDiffSuppression, &out.PermissionDiffSuppression + *out = new(bool) + **out = **in + } + if in.Repository != nil { + in, out := &in.Repository, &out.Repository + *out = new(string) + **out = **in + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorObservation. +func (in *RepositoryCollaboratorObservation) DeepCopy() *RepositoryCollaboratorObservation { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryCollaboratorParameters) DeepCopyInto(out *RepositoryCollaboratorParameters) { + *out = *in + if in.Permission != nil { + in, out := &in.Permission, &out.Permission + *out = new(string) + **out = **in + } + if in.PermissionDiffSuppression != nil { + in, out := &in.PermissionDiffSuppression, &out.PermissionDiffSuppression + *out = new(bool) + **out = **in + } + if in.Repository != nil { + in, out := &in.Repository, &out.Repository + *out = new(string) + **out = **in + } + if in.RepositoryRef != nil { + in, out := &in.RepositoryRef, &out.RepositoryRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RepositorySelector != nil { + in, out := &in.RepositorySelector, &out.RepositorySelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorParameters. +func (in *RepositoryCollaboratorParameters) DeepCopy() *RepositoryCollaboratorParameters { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryCollaboratorSpec) DeepCopyInto(out *RepositoryCollaboratorSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) + in.InitProvider.DeepCopyInto(&out.InitProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorSpec. +func (in *RepositoryCollaboratorSpec) DeepCopy() *RepositoryCollaboratorSpec { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryCollaboratorStatus) DeepCopyInto(out *RepositoryCollaboratorStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryCollaboratorStatus. +func (in *RepositoryCollaboratorStatus) DeepCopy() *RepositoryCollaboratorStatus { + if in == nil { + return nil + } + out := new(RepositoryCollaboratorStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RepositoryFile) DeepCopyInto(out *RepositoryFile) { *out = *in diff --git a/apis/repo/v1alpha1/zz_generated.managed.go b/apis/repo/v1alpha1/zz_generated.managed.go index 8cf3c03..67d4d4b 100644 --- a/apis/repo/v1alpha1/zz_generated.managed.go +++ b/apis/repo/v1alpha1/zz_generated.managed.go @@ -427,6 +427,66 @@ func (mg *RepositoryAutolinkReference) SetWriteConnectionSecretToReference(r *xp mg.Spec.WriteConnectionSecretToReference = r } +// GetCondition of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this RepositoryFile. func (mg *RepositoryFile) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/repo/v1alpha1/zz_generated.managedlist.go b/apis/repo/v1alpha1/zz_generated.managedlist.go index 6da96bf..473a349 100644 --- a/apis/repo/v1alpha1/zz_generated.managedlist.go +++ b/apis/repo/v1alpha1/zz_generated.managedlist.go @@ -61,6 +61,15 @@ func (l *RepositoryAutolinkReferenceList) GetItems() []resource.Managed { return items } +// GetItems of this RepositoryCollaboratorList. +func (l *RepositoryCollaboratorList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this RepositoryFileList. func (l *RepositoryFileList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/repo/v1alpha1/zz_generated.resolvers.go b/apis/repo/v1alpha1/zz_generated.resolvers.go index 7777166..954fd80 100644 --- a/apis/repo/v1alpha1/zz_generated.resolvers.go +++ b/apis/repo/v1alpha1/zz_generated.resolvers.go @@ -297,6 +297,48 @@ func (mg *RepositoryAutolinkReference) ResolveReferences(ctx context.Context, c return nil } +// ResolveReferences of this RepositoryCollaborator. +func (mg *RepositoryCollaborator) 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.Repository), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RepositoryRef, + Selector: mg.Spec.ForProvider.RepositorySelector, + To: reference.To{ + List: &RepositoryList{}, + Managed: &Repository{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Repository") + } + mg.Spec.ForProvider.Repository = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.RepositoryRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Repository), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RepositoryRef, + Selector: mg.Spec.InitProvider.RepositorySelector, + To: reference.To{ + List: &RepositoryList{}, + Managed: &Repository{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.Repository") + } + mg.Spec.InitProvider.Repository = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.RepositoryRef = rsp.ResolvedReference + + return nil +} + // ResolveReferences of this RepositoryFile. func (mg *RepositoryFile) ResolveReferences(ctx context.Context, c client.Reader) error { r := reference.NewAPIResolver(c, mg) diff --git a/apis/repo/v1alpha1/zz_repositorycollaborator_terraformed.go b/apis/repo/v1alpha1/zz_repositorycollaborator_terraformed.go new file mode 100755 index 0000000..934449c --- /dev/null +++ b/apis/repo/v1alpha1/zz_repositorycollaborator_terraformed.go @@ -0,0 +1,129 @@ +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "dario.cat/mergo" + "github.com/pkg/errors" + + "github.com/crossplane/upjet/pkg/resource" + "github.com/crossplane/upjet/pkg/resource/json" +) + +// GetTerraformResourceType returns Terraform resource type for this RepositoryCollaborator +func (mg *RepositoryCollaborator) GetTerraformResourceType() string { + return "github_repository_collaborator" +} + +// GetConnectionDetailsMapping for this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this RepositoryCollaborator +func (tr *RepositoryCollaborator) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this RepositoryCollaborator +func (tr *RepositoryCollaborator) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// GetInitParameters of this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetInitParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.InitProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// GetInitParameters of this RepositoryCollaborator +func (tr *RepositoryCollaborator) GetMergedParameters(shouldMergeInitProvider bool) (map[string]any, error) { + params, err := tr.GetParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get parameters for resource '%q'", tr.GetName()) + } + if !shouldMergeInitProvider { + return params, nil + } + + initParams, err := tr.GetInitParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get init parameters for resource '%q'", tr.GetName()) + } + + // Note(lsviben): mergo.WithSliceDeepCopy is needed to merge the + // slices from the initProvider to forProvider. As it also sets + // overwrite to true, we need to set it back to false, we don't + // want to overwrite the forProvider fields with the initProvider + // fields. + err = mergo.Merge(¶ms, initParams, mergo.WithSliceDeepCopy, func(c *mergo.Config) { + c.Overwrite = false + }) + if err != nil { + return nil, errors.Wrapf(err, "cannot merge spec.initProvider and spec.forProvider parameters for resource '%q'", tr.GetName()) + } + + return params, nil +} + +// LateInitialize this RepositoryCollaborator using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *RepositoryCollaborator) LateInitialize(attrs []byte) (bool, error) { + params := &RepositoryCollaboratorParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *RepositoryCollaborator) GetTerraformSchemaVersion() int { + return 0 +} diff --git a/apis/repo/v1alpha1/zz_repositorycollaborator_types.go b/apis/repo/v1alpha1/zz_repositorycollaborator_types.go new file mode 100755 index 0000000..85ef9ab --- /dev/null +++ b/apis/repo/v1alpha1/zz_repositorycollaborator_types.go @@ -0,0 +1,166 @@ +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type RepositoryCollaboratorInitParameters struct { + + // The permission of the outside collaborator for the repository. + // Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + // Must be push for personal repositories. Defaults to push. + // The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + Permission *string `json:"permission,omitempty" tf:"permission,omitempty"` + + // Suppress plan diffs for triage and maintain. Defaults to false. + // Suppress plan diffs for triage and maintain. Defaults to 'false'. + PermissionDiffSuppression *bool `json:"permissionDiffSuppression,omitempty" tf:"permission_diff_suppression,omitempty"` + + // The GitHub repository + // The GitHub repository + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-upjet-github/apis/repo/v1alpha1.Repository + Repository *string `json:"repository,omitempty" tf:"repository,omitempty"` + + // Reference to a Repository in repo to populate repository. + // +kubebuilder:validation:Optional + RepositoryRef *v1.Reference `json:"repositoryRef,omitempty" tf:"-"` + + // Selector for a Repository in repo to populate repository. + // +kubebuilder:validation:Optional + RepositorySelector *v1.Selector `json:"repositorySelector,omitempty" tf:"-"` + + // The user to add to the repository as a collaborator. + // The user to add to the repository as a collaborator. + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +type RepositoryCollaboratorObservation struct { + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // ID of the invitation to be used in github_user_invitation_accepter + // ID of the invitation to be used in 'github_user_invitation_accepter' + InvitationID *string `json:"invitationId,omitempty" tf:"invitation_id,omitempty"` + + // The permission of the outside collaborator for the repository. + // Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + // Must be push for personal repositories. Defaults to push. + // The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + Permission *string `json:"permission,omitempty" tf:"permission,omitempty"` + + // Suppress plan diffs for triage and maintain. Defaults to false. + // Suppress plan diffs for triage and maintain. Defaults to 'false'. + PermissionDiffSuppression *bool `json:"permissionDiffSuppression,omitempty" tf:"permission_diff_suppression,omitempty"` + + // The GitHub repository + // The GitHub repository + Repository *string `json:"repository,omitempty" tf:"repository,omitempty"` + + // The user to add to the repository as a collaborator. + // The user to add to the repository as a collaborator. + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +type RepositoryCollaboratorParameters struct { + + // The permission of the outside collaborator for the repository. + // Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + // Must be push for personal repositories. Defaults to push. + // The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + // +kubebuilder:validation:Optional + Permission *string `json:"permission,omitempty" tf:"permission,omitempty"` + + // Suppress plan diffs for triage and maintain. Defaults to false. + // Suppress plan diffs for triage and maintain. Defaults to 'false'. + // +kubebuilder:validation:Optional + PermissionDiffSuppression *bool `json:"permissionDiffSuppression,omitempty" tf:"permission_diff_suppression,omitempty"` + + // The GitHub repository + // The GitHub repository + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-upjet-github/apis/repo/v1alpha1.Repository + // +kubebuilder:validation:Optional + Repository *string `json:"repository,omitempty" tf:"repository,omitempty"` + + // Reference to a Repository in repo to populate repository. + // +kubebuilder:validation:Optional + RepositoryRef *v1.Reference `json:"repositoryRef,omitempty" tf:"-"` + + // Selector for a Repository in repo to populate repository. + // +kubebuilder:validation:Optional + RepositorySelector *v1.Selector `json:"repositorySelector,omitempty" tf:"-"` + + // The user to add to the repository as a collaborator. + // The user to add to the repository as a collaborator. + // +kubebuilder:validation:Optional + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +// RepositoryCollaboratorSpec defines the desired state of RepositoryCollaborator +type RepositoryCollaboratorSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider RepositoryCollaboratorParameters `json:"forProvider"` + // THIS IS A BETA FIELD. It will be honored + // unless the Management Policies feature flag is disabled. + // InitProvider holds the same fields as ForProvider, with the exception + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // required on creation, but we do not desire to update them after creation, + // for example because of an external controller is managing them, like an + // autoscaler. + InitProvider RepositoryCollaboratorInitParameters `json:"initProvider,omitempty"` +} + +// RepositoryCollaboratorStatus defines the observed state of RepositoryCollaborator. +type RepositoryCollaboratorStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider RepositoryCollaboratorObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// RepositoryCollaborator is the Schema for the RepositoryCollaborators API. Provides a GitHub repository collaborator resource. +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,github} +type RepositoryCollaborator struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.username) || (has(self.initProvider) && has(self.initProvider.username))",message="spec.forProvider.username is a required parameter" + Spec RepositoryCollaboratorSpec `json:"spec"` + Status RepositoryCollaboratorStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// RepositoryCollaboratorList contains a list of RepositoryCollaborators +type RepositoryCollaboratorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []RepositoryCollaborator `json:"items"` +} + +// Repository type metadata. +var ( + RepositoryCollaborator_Kind = "RepositoryCollaborator" + RepositoryCollaborator_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: RepositoryCollaborator_Kind}.String() + RepositoryCollaborator_KindAPIVersion = RepositoryCollaborator_Kind + "." + CRDGroupVersion.String() + RepositoryCollaborator_GroupVersionKind = CRDGroupVersion.WithKind(RepositoryCollaborator_Kind) +) + +func init() { + SchemeBuilder.Register(&RepositoryCollaborator{}, &RepositoryCollaboratorList{}) +} diff --git a/examples-generated/repo/v1alpha1/repositorycollaborator.yaml b/examples-generated/repo/v1alpha1/repositorycollaborator.yaml new file mode 100644 index 0000000..d4dda09 --- /dev/null +++ b/examples-generated/repo/v1alpha1/repositorycollaborator.yaml @@ -0,0 +1,15 @@ +apiVersion: repo.github.upbound.io/v1alpha1 +kind: RepositoryCollaborator +metadata: + annotations: + meta.upbound.io/example-id: repo/v1alpha1/repositorycollaborator + labels: + testing.upbound.io/example-name: a_repo_collaborator + name: a-repo-collaborator +spec: + forProvider: + permission: admin + repositorySelector: + matchLabels: + testing.upbound.io/example-name: example + username: SomeUser diff --git a/internal/controller/repo/repositorycollaborator/zz_controller.go b/internal/controller/repo/repositorycollaborator/zz_controller.go new file mode 100755 index 0000000..90c9be9 --- /dev/null +++ b/internal/controller/repo/repositorycollaborator/zz_controller.go @@ -0,0 +1,91 @@ +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package repositorycollaborator + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/metrics" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha1 "github.com/crossplane-contrib/provider-upjet-github/apis/repo/v1alpha1" + features "github.com/crossplane-contrib/provider-upjet-github/internal/features" +) + +// Setup adds a controller that reconciles RepositoryCollaborator managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.RepositoryCollaborator_GroupVersionKind.String()) + var initializers managed.InitializerChain + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.RepositoryCollaborator_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1alpha1.RepositoryCollaborator_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler), tjcontroller.WithStatusUpdates(false)) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter( + tjcontroller.NewTerraformPluginSDKAsyncConnector(mgr.GetClient(), o.OperationTrackerStore, o.SetupFn, o.Provider.Resources["github_repository_collaborator"], + tjcontroller.WithTerraformPluginSDKAsyncLogger(o.Logger), + tjcontroller.WithTerraformPluginSDKAsyncConnectorEventHandler(eventHandler), + tjcontroller.WithTerraformPluginSDKAsyncCallbackProvider(ac), + tjcontroller.WithTerraformPluginSDKAsyncMetricRecorder(metrics.NewMetricRecorder(v1alpha1.RepositoryCollaborator_GroupVersionKind, mgr, o.PollInterval)), + tjcontroller.WithTerraformPluginSDKAsyncManagementPolicies(o.Features.Enabled(features.EnableBetaManagementPolicies)))), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(tjcontroller.NewOperationTrackerFinalizer(o.OperationTrackerStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + if o.MetricOptions != nil { + opts = append(opts, managed.WithMetricRecorder(o.MetricOptions.MRMetrics)) + } + + // register webhooks for the kind v1alpha1.RepositoryCollaborator + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.RepositoryCollaborator{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.RepositoryCollaborator") + } + } + + if o.MetricOptions != nil && o.MetricOptions.MRStateMetrics != nil { + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1alpha1.RepositoryCollaboratorList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return errors.Wrap(err, "cannot register MR state metrics recorder for kind v1alpha1.RepositoryCollaboratorList") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.RepositoryCollaborator_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1alpha1.RepositoryCollaborator{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index f349f9c..7d1b2fd 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -21,6 +21,7 @@ import ( pullrequest "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/pullrequest" repository "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/repository" repositoryautolinkreference "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/repositoryautolinkreference" + repositorycollaborator "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/repositorycollaborator" repositoryfile "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/repositoryfile" repositorywebhook "github.com/crossplane-contrib/provider-upjet-github/internal/controller/repo/repositorywebhook" emugroupmapping "github.com/crossplane-contrib/provider-upjet-github/internal/controller/team/emugroupmapping" @@ -48,6 +49,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { pullrequest.Setup, repository.Setup, repositoryautolinkreference.Setup, + repositorycollaborator.Setup, repositoryfile.Setup, repositorywebhook.Setup, emugroupmapping.Setup, diff --git a/package/crds/repo.github.upbound.io_repositorycollaborators.yaml b/package/crds/repo.github.upbound.io_repositorycollaborators.yaml new file mode 100644 index 0000000..6d3c5c9 --- /dev/null +++ b/package/crds/repo.github.upbound.io_repositorycollaborators.yaml @@ -0,0 +1,551 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: repositorycollaborators.repo.github.upbound.io +spec: + group: repo.github.upbound.io + names: + categories: + - crossplane + - managed + - github + kind: RepositoryCollaborator + listKind: RepositoryCollaboratorList + plural: repositorycollaborators + singular: repositorycollaborator + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: RepositoryCollaborator is the Schema for the RepositoryCollaborators + API. Provides a GitHub repository collaborator resource. + 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: RepositoryCollaboratorSpec defines the desired state of RepositoryCollaborator + 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. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + permission: + description: |- + The permission of the outside collaborator for the repository. + Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + Must be push for personal repositories. Defaults to push. + The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + type: string + permissionDiffSuppression: + description: |- + Suppress plan diffs for triage and maintain. Defaults to false. + Suppress plan diffs for triage and maintain. Defaults to 'false'. + type: boolean + repository: + description: |- + The GitHub repository + The GitHub repository + type: string + repositoryRef: + description: Reference to a Repository in repo to populate repository. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + repositorySelector: + description: Selector for a Repository in repo to populate repository. + 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 + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + username: + description: |- + The user to add to the repository as a collaborator. + The user to add to the repository as a collaborator. + type: string + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + permission: + description: |- + The permission of the outside collaborator for the repository. + Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + Must be push for personal repositories. Defaults to push. + The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + type: string + permissionDiffSuppression: + description: |- + Suppress plan diffs for triage and maintain. Defaults to false. + Suppress plan diffs for triage and maintain. Defaults to 'false'. + type: boolean + repository: + description: |- + The GitHub repository + The GitHub repository + type: string + repositoryRef: + description: Reference to a Repository in repo to populate repository. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + repositorySelector: + description: Selector for a Repository in repo to populate repository. + 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 + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + username: + description: |- + The user to add to the repository as a collaborator. + The user to add to the repository as a collaborator. + type: string + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + 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 + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config 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: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + 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. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + 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 + x-kubernetes-validations: + - message: spec.forProvider.username is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.username) + || (has(self.initProvider) && has(self.initProvider.username))' + status: + description: RepositoryCollaboratorStatus defines the observed state of + RepositoryCollaborator. + properties: + atProvider: + properties: + id: + type: string + invitationId: + description: |- + ID of the invitation to be used in github_user_invitation_accepter + ID of the invitation to be used in 'github_user_invitation_accepter' + type: string + permission: + description: |- + The permission of the outside collaborator for the repository. + Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. + Must be push for personal repositories. Defaults to push. + The permission of the outside collaborator for the repository. Must be one of 'pull', 'push', 'maintain', 'triage' or 'admin' or the name of an existing custom repository role within the organization for organization-owned repositories. Must be 'push' for personal repositories. Defaults to 'push'. + type: string + permissionDiffSuppression: + description: |- + Suppress plan diffs for triage and maintain. Defaults to false. + Suppress plan diffs for triage and maintain. Defaults to 'false'. + type: boolean + repository: + description: |- + The GitHub repository + The GitHub repository + type: string + username: + description: |- + The user to add to the repository as a collaborator. + The user to add to the repository as a collaborator. + 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 + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + type: integer + 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 + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + ObservedGeneration is the latest metadata.generation + which resulted in either a ready state, or stalled due to error + it can not recover from without human intervention. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {}