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

WIP: PoC: Use rukpak unpacker #94

Closed
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
38 changes: 15 additions & 23 deletions api/core/v1alpha1/catalog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ limitations under the License.
package v1alpha1

import (
"github.com/operator-framework/rukpak/pkg/source"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// TODO: The source types, reason, etc. are all copy/pasted from the rukpak
// repository. We should look into whether it is possible to share these.

type SourceType string

//
// repository. We should look into whether it is possible to share these.
const (
SourceTypeImage SourceType = "image"

TypeUnpacked = "Unpacked"

ReasonUnpackPending = "UnpackPending"
Expand Down Expand Up @@ -71,31 +68,26 @@ type CatalogSpec struct {
Source CatalogSource `json:"source"`
}

// CatalogSource contains the sourcing information for a Catalog
type CatalogSource struct {
// Type defines the source type for this catalog.
Type source.SourceType `json:"type"`

Image *source.ImageSource `json:"image,omitempty"`
Git *source.GitSource `json:"git,omitempty"`
ConfigMaps []source.ConfigMapSource `json:"configMaps,omitempty"`
HTTP *source.HTTPSource `json:"http,omitempty"`
}

// CatalogStatus defines the observed state of Catalog
type CatalogStatus struct {
// Conditions store the status conditions of the Catalog instances
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`

ResolvedSource *CatalogSource `json:"resolvedSource,omitempty"`
ResolvedSource *source.Source `json:"resolvedSource,omitempty"`
Phase string `json:"phase,omitempty"`
}

// CatalogSource contains the sourcing information for a Catalog
type CatalogSource struct {
// Type defines the kind of Catalog content being sourced.
Type SourceType `json:"type"`
// Image is the catalog image that backs the content of this catalog.
Image *ImageSource `json:"image,omitempty"`
}

// ImageSource contains information required for sourcing a Catalog from an OCI image
type ImageSource struct {
// Ref contains the reference to a container image containing Catalog contents.
Ref string `json:"ref"`
// PullSecret contains the name of the image pull secret in the namespace that catalogd is deployed.
PullSecret string `json:"pullSecret,omitempty"`
}

func init() {
SchemeBuilder.Register(&Catalog{}, &CatalogList{})
}
35 changes: 18 additions & 17 deletions api/core/v1alpha1/zz_generated.deepcopy.go

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

30 changes: 27 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"

"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -32,11 +33,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/operator-framework/catalogd/internal/source"
"github.com/operator-framework/catalogd/internal/version"
corecontrollers "github.com/operator-framework/catalogd/pkg/controllers/core"
"github.com/operator-framework/catalogd/pkg/features"
"github.com/operator-framework/catalogd/pkg/profile"
"github.com/operator-framework/rukpak/pkg/source"
"github.com/spf13/pflag"

//+kubebuilder:scaffold:imports
Expand Down Expand Up @@ -105,12 +106,35 @@ func main() {
os.Exit(1)
}

unpacker, err := source.NewDefaultUnpacker(mgr, sysNs, unpackImage)
kubeClient, err := kubernetes.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "unable to create unpacker")
setupLog.Error(err, "unable to setup kube client")
os.Exit(1)
}

unpacker := source.NewUnpacker(map[source.SourceType]source.Unpacker{
source.SourceTypeImage: source.NewImageUnpacker(
mgr.GetClient(),
kubeClient,
source.WithPodNamespace(sysNs),
source.WithFieldManager("catalogd-core"),
source.WithUnpackImage(unpackImage),
source.WithDir("/configs"),
),
source.SourceTypeGit: source.NewGitUnpacker(
mgr.GetClient(),
source.WithGitSecretNamespace(sysNs),
),
source.SourceTypeConfigMaps: source.NewConfigMapUnpacker(
mgr.GetClient(),
source.WithConfigMapNamespace(sysNs),
),
source.SourceTypeHTTP: source.NewHTTPUnpacker(
mgr.GetClient(),
source.WithHTTPSecretNamespace(sysNs),
),
})

if err = (&corecontrollers.CatalogReconciler{
Client: mgr.GetClient(),
Unpacker: unpacker,
Expand Down
Loading