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 Aug 29, 2023
1 parent e59d3f5 commit 02d4696
Show file tree
Hide file tree
Showing 7 changed files with 907 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/bundle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type GitSource struct {
Auth Authorization `json:"auth,omitempty"`
}

// +kubebuilder:storageversion

type ConfigMapSource struct {
// ConfigMap is a reference to a configmap in the rukpak system namespace
ConfigMap corev1.LocalObjectReference `json:"configMap"`
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
60 changes: 60 additions & 0 deletions api/v1alpha2/bundledeployment_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
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"}
// BundleDeployment is the Schema for the bundledeployments API
type BundleDeployment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BundleDeploymentSpec `json:"spec"`
Status BundleDeploymentStatus `json:"status,omitempty"`
}

// BundleDeploymentSpec defines the desired state of BundleDeployment
type BundleDeploymentSpec struct {
// Source 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 string `json:"format"`
}

// BundleDeploymentStatus defines the observed state of BundleDeployment
type BundleDeploymentStatus struct {
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
)
131 changes: 131 additions & 0 deletions api/v1alpha2/source_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
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"
)

type BundleDeplopymentSource struct {
// Kind of source being passed
// +kubebuilder:validation:type=string
Kind string `json:"kind"`
// 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"`
// ConfigMaps is a list of config map references and their relative
// directory paths that represent a bundle filesystem.
ConfigMaps []ConfigMapSource `json:"configMaps,omitempty"`
// Upload is a source that enables this Bundle's content to be uploaded
// via Rukpak's bundle upload service. This source type is primarily useful
// with bundle development workflows because it enables bundle developers
// to inject a local bundle directly into the cluster.
Upload *UploadSource `json:"upload,omitempty"`
// HTTP is the remote location that backs the content of this Bundle.
HTTP *HTTPSource `json:"http,omitempty"`
// Helm chart defines the location from where to fetch the helm chart
HelmChart *HelmChartSource `json:"helmchart,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.
ImageRef string `json:"imageref"`
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
ImagePullSecretName string `json:"pullSecret,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.
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 authorization method if necessary.
Auth Authorization `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 Authorization 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 UploadSource struct{}

type ConfigMapSource struct {
// ConfigMap is a reference to a configmap in the rukpak system namespace
ConfigMap corev1.LocalObjectReference `json:"configMap"`
// Path is the relative directory path within the bundle where the files
// from the configmap will be present when the bundle is unpacked.
Path string `json:"path,omitempty"`
}

type HTTPSource struct {
// URL is where the bundle contents is.
URL string `json:"url"`
// Auth configures the authorization method if necessary.
Auth Authorization `json:"auth,omitempty"`
}

type HelmChartSource struct {
// Name of the helm chart to pull
Name string `json:"name"`
// +optional
Version string `json:"version,omitempty"`
Repository *HelmChartSourceRepo `json:"repository,omitempty"`
}

type HelmChartSourceRepo struct {
// Path to the location of local chart archive.
Path string `json:"path,omitempty"`
// Repository url where helm chart is localed.
// If path and URL are specified, path would be used to add the helm repo.
URL string `json:"url,omitempty"`
// +optional
// Auth configures the authorization method if necessary.
Auth Authorization `json:"auth,omitempty"`
}
Loading

0 comments on commit 02d4696

Please sign in to comment.