Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
[v1aplha2] Introduce v1alpha2 APIs
Browse files Browse the repository at this point in the history
This commit intends to introduce the new
v1alpha2 APIs

Signed-off-by: Varsha Prasad Narsing <[email protected]>
  • Loading branch information
varshaprasad96 committed Oct 10, 2023
1 parent e59d3f5 commit 35e2b19
Show file tree
Hide file tree
Showing 7 changed files with 811 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/bundle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type BundleStatus struct {
//+kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
//+kubebuilder:printcolumn:name=Provisioner,type=string,JSONPath=`.spec.provisionerClassName`,priority=1
//+kubebuilder:printcolumn:name=Resolved Source,type=string,JSONPath=`.status.resolvedSource`,priority=1
// +kubebuilder:storageversion

// Bundle is the Schema for the bundles API
type Bundle struct {
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/bundledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type BundleDeploymentStatus struct {
//+kubebuilder:printcolumn:name=Provisioner,type=string,JSONPath=`.spec.provisionerClassName`,priority=1

// BundleDeployment is the Schema for the bundledeployments API
// +kubebuilder:storageversion
type BundleDeployment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
107 changes: 107 additions & 0 deletions api/v1alpha2/bundledeployment_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
Copyright 2023.
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 v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,shortName={"bd","bds"}
// +kubebuilder:printcolumn:name="Install State",type=string,JSONPath=`.status.conditions[?(.type=="Installed")].reason`
// +kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
//
// BundleDeployment is the Schema for the bundledeployments API
type BundleDeployment struct {
metav1.TypeMeta `json:",inline"`

metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec holds the desired state.
//
// +kubebuilder:validation:Required
Spec BundleDeploymentSpec `json:"spec"`

// Status communicates the observed state
//
// +optional
Status BundleDeploymentStatus `json:"status,omitempty"`
}

// BundleDeploymentSpec defines the desired state of BundleDeployment
type BundleDeploymentSpec struct {
// Sources configures how to pull the bundle content.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems:=1
Sources []BundleDeplopymentSource `json:"sources"`

// Format refers to the bundle type which is being passed through
// the bundle deployment API.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=plain;helm;registry
Format FormatType `json:"format"`

// Paused is used to configure whether we want the
// bundle deployment to reconcile, or remain in the
// last observed state.
//
// +kubebuilder:default:=false
// +optional
Paused bool `json:"paused,omitempty"`

// DefaultNamespace refers to the namespace where
// namespace-scoped objects would be created if not
// explicitly set within the bundle.
//
// +optional
DefaultNamespace string `json:"defaultnamespace,omitempty"`
}

// FormatType refers to the allowed bundle formats that
// are being accepted in the APIs.
type FormatType string

// For more details on how each format looks like,
// refer: https://github.com/operator-framework/rukpak/tree/main/docs/bundles.
const (
FormatPlain = "plain"
FormatRegistryV1 = "registry"
FormatHelm = "helm"
)

// BundleDeploymentStatus defines the observed state of BundleDeployment
type BundleDeploymentStatus struct {
// Conditions is a list of conditions that apply to the BundleDeployment.
//
//+optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// +kubebuilder:object:root=true
//
// BundleDeploymentList contains a list of BundleDeployment
type BundleDeploymentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []BundleDeployment `json:"items"`
}
36 changes: 36 additions & 0 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2023.
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 API Schema definitions for the core v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=core.rukpak.io
package v1alpha2

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

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "core.rukpak.io", Version: "v1alpha2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
104 changes: 104 additions & 0 deletions api/v1alpha2/source_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
Copyright 2023.
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 v1alpha2

import (
corev1 "k8s.io/api/core/v1"
)

// BundleDeploymentSource configures the sources
// from where the bundle content needs to be
// downloaded, and the location to unpack it.
type BundleDeplopymentSource struct {
// Image is the bundle image that backs the content of this bundle.
Image *ImageSource `json:"image,omitempty"`

// Git is the git repository that backs the content of this Bundle.
Git *GitSource `json:"git,omitempty"`

// HTTP is the remote location that backs the content of this Bundle.
HTTP *HTTPSource `json:"http,omitempty"`

// Relative location to place the fetched artifacts
// +optional
Destination string `json:"destination,omitempty"`
}

type ImageSource struct {
// Ref contains the reference to a container image containing Bundle contents.
Ref string `json:"ref"`

// Auth configures the authentication method if necessary.
Auth *Authentication `json:"auth,omitempty"`
}

type GitSource struct {
// Repository is a URL link to the git repository containing the bundle.
// Repository is required and the URL should be parsable by a standard git tool.
Repository string `json:"repository"`

// +kubebuilder:default:=manifests
//
// Directory refers to the location of the bundle within the git repository.
// Directory is optional and if not set defaults to `manifests`.
Directory string `json:"directory,omitempty"`

// Ref configures the git source to clone a specific branch, tag, or commit
// from the specified repo. Ref is required, and exactly one field within Ref
// is required. Setting more than one field or zero fields will result in an
// error.
Ref GitRef `json:"ref"`

// Auth configures the authentication method if necessary.
Auth *Authentication `json:"auth,omitempty"`
}

type GitRef struct {
// Branch refers to the branch to checkout from the repository.
// The Branch should contain the bundle manifests in the specified directory.
Branch string `json:"branch,omitempty"`

// Tag refers to the tag to checkout from the repository.
// The Tag should contain the bundle manifests in the specified directory.
Tag string `json:"tag,omitempty"`

// Commit refers to the commit to checkout from the repository.
// The Commit should contain the bundle manifests in the specified directory.
Commit string `json:"commit,omitempty"`
}

type Authentication struct {
// Secret contains reference to the secret that has authorization information and is in the namespace that the provisioner is deployed.
// The secret is expected to contain `data.username` and `data.password` for the username and password, respectively for http(s) scheme.
// Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret
// For the ssh authorization of the GitSource, the secret is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` for the ssh privatekey and the host entry in the known_hosts file respectively.
// Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets
Secret corev1.LocalObjectReference `json:"secret,omitempty"`

// InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name. If InsecureSkipVerify
// is true, the clone operation will accept any certificate presented by the server and any host name in that
// certificate. In this mode, TLS is susceptible to machine-in-the-middle attacks unless custom verification is
// used. This should be used only for testing.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
}
type HTTPSource struct {
// URL is where the bundle contents is.
URL string `json:"url"`

// Auth configures the authentication method if necessary.
Auth *Authentication `json:"auth,omitempty"`
}
Loading

0 comments on commit 35e2b19

Please sign in to comment.