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

[v1alpha2] Introduce v1alpha2 APIs #713

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
19 changes: 10 additions & 9 deletions api/v1alpha1/bundle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ type BundleStatus struct {
ContentURL string `json:"contentURL,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name=Type,type=string,JSONPath=`.spec.source.type`
//+kubebuilder:printcolumn:name=Phase,type=string,JSONPath=`.status.phase`
//+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:object:root=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name=Type,type=string,JSONPath=`.spec.source.type`
// +kubebuilder:printcolumn:name=Phase,type=string,JSONPath=`.status.phase`
// +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
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
//
// Bundle is the Schema for the bundles API
type Bundle struct {
metav1.TypeMeta `json:",inline"`
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 @@ -74,6 +74,7 @@ type BundleDeploymentStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster,shortName={"bd","bds"}
// +kubebuilder:storageversion
//+kubebuilder:printcolumn:name="Active Bundle",type=string,JSONPath=`.status.activeBundle`
//+kubebuilder:printcolumn:name="Install State",type=string,JSONPath=`.status.conditions[?(.type=="Installed")].reason`
//+kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
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
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
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"`
}
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved

// 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 {
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
// 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"`

// Directory refers to the location of the bundle within the git repository.
// Directory is optional and if not set defaults to `manifests`.
//
// +kubebuilder:default:=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.
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
// 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
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
varshaprasad96 marked this conversation as resolved.
Show resolved Hide resolved
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