Skip to content

Commit

Permalink
Store metadata for packagerevisions in CRs (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortent authored Oct 14, 2022
1 parent 82f5a72 commit 212b668
Show file tree
Hide file tree
Showing 38 changed files with 1,548 additions and 207 deletions.
15 changes: 15 additions & 0 deletions porch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ PORCH = $(BUILDDIR)/porch
run-local: porch
KUBECONFIG=$(KUBECONFIG) kubectl apply -f deployments/local/localconfig.yaml
KUBECONFIG=$(KUBECONFIG) kubectl apply -f api/porchconfig/v1alpha1/
KUBECONFIG=$(KUBECONFIG) kubectl apply -f internal/api/porchinternal/v1alpha1/
$(PORCH) \
--secure-port 9443 \
--standalone-debug-mode \
Expand Down Expand Up @@ -253,3 +254,17 @@ deploy-no-sa: deployment-config-no-sa

.PHONY: push-and-deploy-no-sa
push-and-deploy-no-sa: push-images deploy-no-sa

.PHONY: run-in-kind
run-in-kind:
IMAGE_REPO=porch-kind make build-images
kind load docker-image porch-kind/porch-server:${IMAGE_TAG}
kind load docker-image porch-kind/porch-controllers:${IMAGE_TAG}
kind load docker-image porch-kind/porch-function-runner:${IMAGE_TAG}
kind load docker-image porch-kind/porch-wrapper-server:${IMAGE_TAG}
kind load docker-image porch-kind/test-git-server:${IMAGE_TAG}
IMAGE_REPO=porch-kind make deployment-config
kubectl apply --wait --recursive --filename ./.build/deploy
kubectl rollout status deployment function-runner --namespace porch-system
kubectl rollout status deployment porch-controllers --namespace porch-system
kubectl rollout status deployment porch-server --namespace porch-system
14 changes: 7 additions & 7 deletions porch/api/generated/clientset/versioned/fake/register.go

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

14 changes: 7 additions & 7 deletions porch/api/generated/clientset/versioned/scheme/register.go

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

1 change: 1 addition & 0 deletions porch/build/Dockerfile.porch
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ COPY pkg pkg
COPY porch/api porch/api
COPY porch/cmd porch/cmd
COPY porch/pkg porch/pkg
COPY porch/internal porch/internal
COPY porch/controllers porch/controllers
COPY porch/func porch/func

Expand Down
3 changes: 3 additions & 0 deletions porch/deployments/porch/5-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ rules:
- apiGroups: ["config.porch.kpt.dev"]
resources: ["repositories", "repositories/status"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: ["config.porch.kpt.dev"]
resources: ["packagerevs", "packagerevs/status"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Needed for priority and fairness
- apiGroups: ["flowcontrol.apiserver.k8s.io"]
resources: ["flowschemas", "prioritylevelconfigurations"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2022 Google LLC
#
# 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.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: packagerevs.config.porch.kpt.dev
spec:
group: config.porch.kpt.dev
names:
kind: PackageRev
listKind: PackageRevList
plural: packagerevs
singular: packagerev
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: PackageRev
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PackageRevSpec defines the desired state of PackageRev
type: object
status:
description: PackageRevStatus defines the observed state of PackageRev
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
61 changes: 61 additions & 0 deletions porch/internal/api/porchinternal/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2022 Google LLC
//
// 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 v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=config.porch.kpt.dev
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

//go:generate go run sigs.k8s.io/controller-tools/cmd/[email protected] object object:headerFile="../../../../scripts/boilerplate.go.txt" crd:crdVersions=v1 output:crd:artifacts:config=. paths=./...

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "config.porch.kpt.dev", Version: "v1alpha1"}

// We removed SchemeBuilder to keep our dependencies small

KindRepository = KindInfo{
Resource: GroupVersion.WithResource("packagerev"),
objects: []runtime.Object{&PackageRev{}, &PackageRevList{}},
}

AllKinds = []KindInfo{KindRepository}
)

//+kubebuilder:object:generate=false

// KindInfo holds type meta-information
type KindInfo struct {
Resource schema.GroupVersionResource
objects []runtime.Object
}

// GroupResource returns the GroupResource for the kind
func (k *KindInfo) GroupResource() schema.GroupResource {
return k.Resource.GroupResource()
}

func AddToScheme(scheme *runtime.Scheme) error {
for _, kind := range AllKinds {
scheme.AddKnownTypes(GroupVersion, kind.objects...)
}
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
49 changes: 49 additions & 0 deletions porch/internal/api/porchinternal/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2022 Google LLC
//
// 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

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:path=packagerevs,singular=packagerev

// PackageRev
type PackageRev struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PackageRevSpec `json:"spec,omitempty"`
Status PackageRevStatus `json:"status,omitempty"`
}

// PackageRevSpec defines the desired state of PackageRev
type PackageRevSpec struct {
}

// PackageRevStatus defines the observed state of PackageRev
type PackageRevStatus struct {
}

//+kubebuilder:object:root=true

// PackageRevList contains a list of PackageRev
type PackageRevList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PackageRev `json:"items"`
}
113 changes: 113 additions & 0 deletions porch/internal/api/porchinternal/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 212b668

Please sign in to comment.