Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frewilhelm committed Feb 7, 2025
1 parent db59c21 commit 2458ab5
Show file tree
Hide file tree
Showing 24 changed files with 572 additions and 564 deletions.
3 changes: 0 additions & 3 deletions api/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ type ComponentStatus struct {
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// TODO: Remove
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`

// Component specifies the concrete version of the component that was
// fetched after based on the semver constraints during the last successful
// reconciliation.
Expand Down
9 changes: 7 additions & 2 deletions api/v1alpha1/configuredresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/fluxcd/pkg/apis/meta"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -92,8 +93,8 @@ type ConfiguredResourceStatus struct {

// The configuration reconcile loop generates an artifact, which contains the
// ConfiguredResourceSpec.Target ConfigurationReference after configuration.
// It is filled once the Artifact is created and the configuration completed.
ArtifactRef *ObjectKey `json:"artifactRef,omitempty"`
// It is filled once the Snapshot is created and the configuration completed.
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// Digest contains a technical identifier for the artifact. This technical identifier
// can be used to track changes on the ArtifactRef as it is a combination of the origin
Expand All @@ -113,6 +114,10 @@ type ConfiguredResource struct {
Status ConfiguredResourceStatus `json:"status,omitempty"`
}

func (in *ConfiguredResource) GetSnapshotName() string {
return in.Status.SnapshotRef.Name
}

// +kubebuilder:object:root=true

// ConfiguredResourceList contains a list of ConfiguredResource.
Expand Down
9 changes: 7 additions & 2 deletions api/v1alpha1/localizedresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1alpha1
import (
"fmt"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -73,6 +74,10 @@ func (in *LocalizedResource) SetTarget(v *ConfigurationReference) {
v.DeepCopyInto(&in.Spec.Target)
}

func (in *LocalizedResource) GetSnapshotName() string {
return in.Status.SnapshotRef.Name
}

type LocalizedResourceSpec struct {
// Target that is to be localized
Target ConfigurationReference `json:"target"`
Expand All @@ -91,8 +96,8 @@ type LocalizedResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// The LocalizedResource reports an ArtifactRef which contains the content of the Resource after Localization
ArtifactRef *ObjectKey `json:"artifactRef,omitempty"`
// The LocalizedResource reports an SnapshotRef which contains the content of the Resource after Localization
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// The LocalizedResource reports a ConfiguredResourceRef which contains a reference to the ConfiguredResource
// that is responsible for generating the ArtifactRef.
Expand Down
3 changes: 0 additions & 3 deletions api/v1alpha1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ type ResourceStatus struct {
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// TODO: Remove
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`

// +optional
Resource *ResourceInfo `json:"resource,omitempty"`

Expand Down
14 changes: 2 additions & 12 deletions api/v1alpha1/zz_generated.deepcopy.go

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

45 changes: 14 additions & 31 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import (
"crypto/tls"
"flag"
"os"
"time"

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

"github.com/fluxcd/pkg/runtime/events"
"github.com/openfluxcd/controller-manager/server"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -68,20 +66,18 @@ func init() {
// +kubebuilder:scaffold:scheme
}

//nolint:funlen,maintidx // this is the main function
//nolint:funlen // this is the main function
func main() {
var (
metricsAddr string
enableLeaderElection bool
probeAddr string
secureMetrics bool
enableHTTP2 bool
artifactRetentionTTL = 60 * time.Second
artifactRetentionRecords = 2
storagePath string
storageAddr string
storageAdvAddr string
eventsAddr string
metricsAddr string
enableLeaderElection bool
probeAddr string
secureMetrics bool
enableHTTP2 bool
storagePath string
storageAddr string
storageAdvAddr string
eventsAddr string
)
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metric endpoint binds to. "+
"Use the port :8080. If not set, it will be 0 in order to disable the metrics server")
Expand Down Expand Up @@ -172,14 +168,6 @@ func main() {
os.Exit(1)
}

// TODO: Replace
storage, artifactServer, err := server.NewArtifactStore(mgr.GetClient(), mgr.GetScheme(),
storagePath, storageAddr, storageAdvAddr, artifactRetentionTTL, artifactRetentionRecords)
if err != nil {
setupLog.Error(err, "unable to initialize storage")
os.Exit(1)
}

// TODO: Adjust hardcode with CLI param
registry, err := snapshotRegistry.NewRegistry("ocm-k8s-toolkit-zot-registry.ocm-k8s-toolkit-system.svc.cluster.local:5000")
registry.PlainHTTP = true
Expand Down Expand Up @@ -212,7 +200,6 @@ func main() {
EventRecorder: eventsRecorder,
},
Registry: registry,
Storage: storage,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Resource")
os.Exit(1)
Expand All @@ -224,8 +211,8 @@ func main() {
Scheme: mgr.GetScheme(),
EventRecorder: eventsRecorder,
},
Storage: storage,
LocalizationClient: locclient.NewClientWithLocalStorage(mgr.GetClient(), storage, mgr.GetScheme()),
Registry: registry,
LocalizationClient: locclient.NewClientWithRegistry(mgr.GetClient(), registry, mgr.GetScheme()),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LocalizedResource")
os.Exit(1)
Expand All @@ -237,8 +224,8 @@ func main() {
Scheme: mgr.GetScheme(),
EventRecorder: eventsRecorder,
},
Storage: storage,
ConfigClient: cfgclient.NewClientWithLocalStorage(mgr.GetClient(), storage, mgr.GetScheme()),
Registry: registry,
ConfigClient: cfgclient.NewClientWithRegistry(mgr.GetClient(), registry, mgr.GetScheme()),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ConfiguredResource")
os.Exit(1)
Expand Down Expand Up @@ -282,10 +269,6 @@ func main() {
// entire process will terminate if we lose leadership, so we don't need
// to handle that.
<-mgr.Elected()

if err := artifactServer.Start(ctx); err != nil {
setupLog.Error(err, "unable to start artifact server")
}
}()

setupLog.Info("starting manager")
Expand Down
16 changes: 0 additions & 16 deletions config/crd/bases/delivery.ocm.software_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,6 @@ spec:
status:
description: ComponentStatus defines the observed state of Component.
properties:
artifactRef:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
component:
description: |-
Component specifies the concrete version of the component that was
Expand Down
30 changes: 17 additions & 13 deletions config/crd/bases/delivery.ocm.software_configuredresources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,6 @@ spec:
status:
description: ConfiguredResourceStatus defines the observed state of ConfiguredResource.
properties:
artifactRef:
description: |-
The configuration reconcile loop generates an artifact, which contains the
ConfiguredResourceSpec.Target ConfigurationReference after configuration.
It is filled once the Artifact is created and the configuration completed.
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
conditions:
items:
description: Condition contains details for one aspect of the current
Expand Down Expand Up @@ -177,6 +164,23 @@ spec:
observedGeneration:
format: int64
type: integer
snapshotRef:
description: |-
The configuration reconcile loop generates an artifact, which contains the
ConfiguredResourceSpec.Target ConfigurationReference after configuration.
It is filled once the Snapshot is created and the configuration completed.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
type: object
type: object
served: true
Expand Down
26 changes: 15 additions & 11 deletions config/crd/bases/delivery.ocm.software_localizedresources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ spec:
type: object
status:
properties:
artifactRef:
description: The LocalizedResource reports an ArtifactRef which contains
the content of the Resource after Localization
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
conditions:
items:
description: Condition contains details for one aspect of the current
Expand Down Expand Up @@ -196,6 +185,21 @@ spec:
observedGeneration:
format: int64
type: integer
snapshotRef:
description: The LocalizedResource reports an SnapshotRef which contains
the content of the Resource after Localization
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
type: object
type: object
served: true
Expand Down
16 changes: 0 additions & 16 deletions config/crd/bases/delivery.ocm.software_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ spec:
status:
description: ResourceStatus defines the observed state of Resource.
properties:
artifactRef:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
conditions:
description: Conditions holds the conditions for the Resource.
items:
Expand Down
Loading

0 comments on commit 2458ab5

Please sign in to comment.