Skip to content

Commit

Permalink
move apis from v1beta1 to v1alpha1; move apis tree to repo root
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Jun 6, 2023
1 parent 6fd0a81 commit 5555a7b
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 128 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ kind create cluster
$ kubectl apply -f https://github.com/operator-framework/catalogd/config/crd/bases/
$ kubectl apply -f https://github.com/operator-framework/catalogd/config/
$ kubectl create ns test
$ kubectl apply -f config/samples/core_v1beta1_catalog.yaml
$ kubectl apply -f config/samples/core_v1alpha1_catalog.yaml
$ kubectl get catalog -n test
NAME AGE
Expand Down Expand Up @@ -111,5 +111,5 @@ kubectl apply -f config/
```
- Create the sample Catalog (this will trigger the reconciliation loop):
```sh
kubectl apply -f config/samples/core_v1beta1_catalog.yaml
kubectl apply -f config/samples/core_v1alpha1_catalog.yaml
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package v1alpha1

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta1 contains API Schema definitions for the core v1alpha1 API group
// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=catalogd.operatorframework.io
package v1beta1
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "catalogd.operatorframework.io", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: "catalogd.operatorframework.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/doc.go → api/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ limitations under the License.
//
// +domain=operatorframework.io

package apis
package api
4 changes: 2 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (

"github.com/operator-framework/catalogd/internal/source"
"github.com/operator-framework/catalogd/internal/version"
"github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
corecontrollers "github.com/operator-framework/catalogd/pkg/controllers/core"
"github.com/operator-framework/catalogd/pkg/profile"
//+kubebuilder:scaffold:imports
"github.com/operator-framework/catalogd/api/core/v1alpha1"
)

var (
Expand All @@ -48,7 +48,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(v1beta1.AddToScheme(scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
singular: bundlemetadata
scope: Cluster
versions:
- name: v1beta1
- name: v1alpha1
schema:
openAPIV3Schema:
description: BundleMetadata is the Schema for the bundlemetadata API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
singular: catalog
scope: Cluster
versions:
- name: v1beta1
- name: v1alpha1
schema:
openAPIV3Schema:
description: Catalog is the Schema for the Catalogs API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
singular: package
scope: Cluster
versions:
- name: v1beta1
- name: v1alpha1
schema:
openAPIV3Schema:
description: Package is the Schema for the packages API
Expand Down
9 changes: 9 additions & 0 deletions config/samples/core_v1alpha1_catalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
metadata:
name: operatorhubio
spec:
source:
type: image
image:
ref: quay.io/operatorhubio/catalog:latest
9 changes: 0 additions & 9 deletions config/samples/core_v1beta1_catalog.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions hack/scripts/generate-asciidemo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function run() {
typeline 'kubectl get crds -A'

typeline -x "# create a catalog"
typeline "kubectl apply -f config/samples/core_v1beta1_catalog.yaml" # or other
typeline "kubectl apply -f config/samples/core_v1alpha1_catalog.yaml" # or other
typeline "kubectl get catalog -A" # shows catalog-sample
typeline -x "# waiting for catalog to report ready status"
typeline "kubectl wait --for=condition=Ready catalog/catalog-sample --timeout=1h"
Expand All @@ -43,4 +43,3 @@ function run() {
}

run

18 changes: 9 additions & 9 deletions internal/source/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1"
)

type Image struct {
Expand All @@ -33,9 +33,9 @@ type Image struct {

const imageCatalogUnpackContainerName = "catalog"

func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*Result, error) {
if catalog.Spec.Source.Type != catalogdv1beta1.SourceTypeImage {
panic(fmt.Sprintf("source type %q is unable to handle specified catalog source type %q", catalogdv1beta1.SourceTypeImage, catalog.Spec.Source.Type))
func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Catalog) (*Result, error) {
if catalog.Spec.Source.Type != catalogdv1alpha1.SourceTypeImage {
panic(fmt.Sprintf("source type %q is unable to handle specified catalog source type %q", catalogdv1alpha1.SourceTypeImage, catalog.Spec.Source.Type))
}
if catalog.Spec.Source.Image == nil {
return nil, fmt.Errorf("catalog source image configuration is unset")
Expand Down Expand Up @@ -63,7 +63,7 @@ func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*
}
}

func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1beta1.Catalog, pod *corev1.Pod) (controllerutil.OperationResult, error) {
func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1alpha1.Catalog, pod *corev1.Pod) (controllerutil.OperationResult, error) {
existingPod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: i.PodNamespace, Name: catalog.Name}}
if err := i.Client.Get(ctx, client.ObjectKeyFromObject(existingPod), existingPod); client.IgnoreNotFound(err) != nil {
return controllerutil.OperationResultNone, err
Expand Down Expand Up @@ -98,7 +98,7 @@ func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1beta1.Ca
return controllerutil.OperationResultUpdated, nil
}

func (i *Image) getDesiredPodApplyConfig(catalog *catalogdv1beta1.Catalog) *applyconfigurationcorev1.PodApplyConfiguration {
func (i *Image) getDesiredPodApplyConfig(catalog *catalogdv1alpha1.Catalog) *applyconfigurationcorev1.PodApplyConfiguration {
// TODO: Address unpacker pod allowing root users for image sources
//
// In our current implementation, we are creating a pod that uses the image
Expand Down Expand Up @@ -202,9 +202,9 @@ func (i *Image) succeededPodResult(ctx context.Context, pod *corev1.Pod) (*Resul
return nil, fmt.Errorf("get catalog image digest: %v", err)
}

resolvedSource := &catalogdv1beta1.CatalogSource{
Type: catalogdv1beta1.SourceTypeImage,
Image: &catalogdv1beta1.ImageSource{Ref: digest},
resolvedSource := &catalogdv1alpha1.CatalogSource{
Type: catalogdv1alpha1.SourceTypeImage,
Image: &catalogdv1alpha1.ImageSource{Ref: digest},
}

message := fmt.Sprintf("successfully unpacked the catalog image %q", digest)
Expand Down
16 changes: 8 additions & 8 deletions internal/source/unpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/cluster"

catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1"
)

// TODO: This package is almost entirely copy/pasted from rukpak. We should look
Expand All @@ -32,7 +32,7 @@ import (
// specifications. A source should treat a catalog root directory as an opaque
// file tree and delegate catalog format concerns to catalog parsers.
type Unpacker interface {
Unpack(context.Context, *catalogdv1beta1.Catalog) (*Result, error)
Unpack(context.Context, *catalogdv1alpha1.Catalog) (*Result, error)
}

// Result conveys progress information about unpacking catalog content.
Expand All @@ -49,7 +49,7 @@ type Result struct {
// For example, resolved image sources should reference a container image
// digest rather than an image tag, and git sources should reference a
// commit hash rather than a branch or tag.
ResolvedSource *catalogdv1beta1.CatalogSource
ResolvedSource *catalogdv1alpha1.CatalogSource

// State is the current state of unpacking the catalog content.
State State
Expand All @@ -76,16 +76,16 @@ const (
)

type unpacker struct {
sources map[catalogdv1beta1.SourceType]Unpacker
sources map[catalogdv1alpha1.SourceType]Unpacker
}

// NewUnpacker returns a new composite Source that unpacks catalogs using the source
// mapping provided by the configured sources.
func NewUnpacker(sources map[catalogdv1beta1.SourceType]Unpacker) Unpacker {
func NewUnpacker(sources map[catalogdv1alpha1.SourceType]Unpacker) Unpacker {
return &unpacker{sources: sources}
}

func (s *unpacker) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*Result, error) {
func (s *unpacker) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Catalog) (*Result, error) {
source, ok := s.sources[catalog.Spec.Source.Type]
if !ok {
return nil, fmt.Errorf("source type %q not supported", catalog.Spec.Source.Type)
Expand All @@ -104,8 +104,8 @@ func NewDefaultUnpacker(systemNsCluster cluster.Cluster, namespace, unpackImage
if err != nil {
return nil, err
}
return NewUnpacker(map[catalogdv1beta1.SourceType]Unpacker{
catalogdv1beta1.SourceTypeImage: &Image{
return NewUnpacker(map[catalogdv1alpha1.SourceType]Unpacker{
catalogdv1alpha1.SourceTypeImage: &Image{
Client: systemNsCluster.GetClient(),
KubeClient: kubeClient,
PodNamespace: namespace,
Expand Down
Loading

0 comments on commit 5555a7b

Please sign in to comment.