Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/project - Ongoing #2

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build generate
// +build generate

/*
Expand Down
4 changes: 2 additions & 2 deletions apis/harbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ package apis
import (
"k8s.io/apimachinery/pkg/runtime"

samplev1alpha1 "github.com/crossplane/provider-harbor/apis/sample/v1alpha1"
projectv1alpha1 "github.com/crossplane/provider-harbor/apis/project/v1alpha1"
harborv1alpha1 "github.com/crossplane/provider-harbor/apis/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes,
harborv1alpha1.SchemeBuilder.AddToScheme,
samplev1alpha1.SchemeBuilder.AddToScheme,
projectv1alpha1.SchemeBuilder.AddToScheme,
)
}

Expand Down
18 changes: 18 additions & 0 deletions apis/project/project.go
Original file line number Diff line number Diff line change
@@ -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 project contains group project API versions
package project
17 changes: 17 additions & 0 deletions apis/project/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
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
40 changes: 40 additions & 0 deletions apis/project/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2020 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 the v1alpha1 group Sample resources of the harbor provider.
// +kubebuilder:object:generate=true
// +groupName=project.harbor.crossplane.io
// +versionName=v1alpha1
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

// Package type metadata.
const (
Group = "project.harbor.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}
)
105 changes: 105 additions & 0 deletions apis/project/v1alpha1/project_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
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"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

type ProjectMetadata struct {
AutoScan *string `json:"autoScan,omitempty"`
EnableContentTrust *string `json:"enableContentTrust,omitempty"`
EnableContentTrustCosign *string `json:"enableContentTrustCosign,omitempty"`
PreventVul *string `json:"preventVul,omitempty"`
Public string `json:"public,omitempty"`
RetentionID *string `json:"retentionID,omitempty"`
ReuseSysCVEAllowlist *string `json:"reuseSysCVEAllowlist,omitempty"`
Severity *string `json:"severity,omitempty"`
}

// ProjectParameters are the configurable fields of a Project.
type ProjectParameters struct {
CurrentUserRoleID int64 `json:"currentUserRoleID,omitempty"`
CurrentUserRoleIds []int32 `json:"currentUserRoleIds"`
Deleted *bool `json:"deleted,omitempty"`
Metadata *ProjectMetadata `json:"metadata,omitempty"`
OwnerID *int32 `json:"ownerID,omitempty"`
OwnerName *string `json:"ownerName,omitempty"`
ProjectID *int32 `json:"projectID,omitempty"`
RegistryID *int64 `json:"registryID,omitempty"`
RepoCount int64 `json:"repoCount"`
Togglable *bool `json:"togglable,omitempty"`
}

// ProjectObservation are the observable fields of a Project.
type ProjectObservation struct {
State string `json:"state,omitempty"`
}

// A ProjectSpec defines the desired state of a Project.
type ProjectSpec struct {
xpv1.ResourceSpec `json:",inline"`
ForProvider ProjectParameters `json:"forProvider"`
}

// A ProjectStatus represents the observed state of a Project.
type ProjectStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider ProjectObservation `json:"atProvider,omitempty"`
}

// +kubebuilder:object:root=true

// A Project is an example API type.
// +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:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,harbor}
type Project struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ProjectSpec `json:"spec"`
Status ProjectStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// ProjectList contains a list of Project
type ProjectList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Project `json:"items"`
}

// Project type metadata.
var (
ProjectKind = reflect.TypeOf(Project{}).Name()
ProjectGroupKind = schema.GroupKind{Group: Group, Kind: ProjectKind}.String()
ProjectKindAPIVersion = ProjectKind + "." + SchemeGroupVersion.String()
ProjectGroupVersionKind = SchemeGroupVersion.WithKind(ProjectKind)
)

func init() {
SchemeBuilder.Register(&Project{}, &ProjectList{})
}
Loading
Loading