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

[csc] Update CSC version from v1 to v2 #203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,7 +15,14 @@ spec:
shortNames:
- csc
scope: Namespaced
version: v1
version: v2
versions:
- name: v2
served: true
storage: true
- name: v1
served: true
storage: false
additionalPrinterColumns:
- name: Status
type: string
Expand Down
9 changes: 8 additions & 1 deletion deploy/upstream/02_catalogsourceconfig.crd.yaml
Expand Up @@ -15,7 +15,14 @@ spec:
shortNames:
- csc
scope: Namespaced
version: v1
version: v2
versions:
- name: v2
served: true
storage: true
- name: v1
served: true
storage: false
additionalPrinterColumns:
- name: Status
type: string
Expand Down
15 changes: 15 additions & 0 deletions hack/boilerplate.go.txt
@@ -0,0 +1,15 @@
/*
Copyright The Kubernetes Authors.

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.
*/
9 changes: 8 additions & 1 deletion manifests/02_catalogsourceconfig.crd.yaml
Expand Up @@ -15,7 +15,14 @@ spec:
shortNames:
- csc
scope: Namespaced
version: v1
version: v2
versions:
- name: v2
served: true
storage: true
- name: v1
served: true
storage: false
additionalPrinterColumns:
- name: Status
type: string
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/addtoscheme_operators_v1.go
@@ -1,10 +1,10 @@
package apis

import (
marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1"
"github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, marketplace.SchemeBuilder.AddToScheme)
AddToSchemes = append(AddToSchemes, v1.SchemeBuilder.AddToScheme)
}
10 changes: 10 additions & 0 deletions pkg/apis/addtoscheme_operators_v2.go
@@ -0,0 +1,10 @@
package apis

import (
"github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, v2.SchemeBuilder.AddToScheme)
}
4 changes: 4 additions & 0 deletions pkg/apis/operators/shared/doc.go
@@ -0,0 +1,4 @@
// Package shared contains structs used by various API groups
// +k8s:deepcopy-gen=package,register
// +groupName=operators.coreos.com
package shared
@@ -1,4 +1,4 @@
package v1
package shared

// NewPhase returns a Phase object with the given name and message
func NewPhase(name string, message string) *Phase {
Expand Down
@@ -1,4 +1,4 @@
package v1
package shared
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming you did a git mv and git decided the file was new. Was that the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It decided to create / delete the phase_type after adding the generated deepcopy functions.


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

Expand Down
@@ -1,4 +1,4 @@
package v1
package shared

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -7,7 +7,7 @@ import (
// EnsureFinalizer ensures that the object's finalizer is included
// in the ObjectMeta Finalizers slice. If it already exists, no state change occurs.
// If it doesn't, the finalizer is appended to the slice.
func ensureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) {
func EnsureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) {
// First check if the finalizer is already included in the object.
for _, finalizer := range objectMeta.Finalizers {
if finalizer == expectedFinalizer {
Expand All @@ -22,7 +22,7 @@ func ensureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) {
}

// RemoveFinalizer removes the finalizer from the object's ObjectMeta.
func removeFinalizer(objectMeta *metav1.ObjectMeta, deletingFinalizer string) {
func RemoveFinalizer(objectMeta *metav1.ObjectMeta, deletingFinalizer string) {
outFinalizers := make([]string, 0)
for _, finalizer := range objectMeta.Finalizers {
if finalizer == deletingFinalizer {
Expand Down
56 changes: 56 additions & 0 deletions pkg/apis/operators/shared/zz_generated.deepcopy.go

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

7 changes: 4 additions & 3 deletions pkg/apis/operators/v1/operatorsource_types.go
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"strings"

"github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand Down Expand Up @@ -74,7 +75,7 @@ type OperatorSourceAuthorizationToken struct {
// OperatorSourceStatus defines the observed state of OperatorSource
type OperatorSourceStatus struct {
// Current phase of the OperatorSource object
CurrentPhase ObjectPhase `json:"currentPhase,omitempty"`
CurrentPhase shared.ObjectPhase `json:"currentPhase,omitempty"`

// Packages is a comma separated list of package(s) each of which has been
// downloaded and processed by Marketplace operator from the specified
Expand Down Expand Up @@ -123,14 +124,14 @@ func (s *OperatorSourceSpec) IsEqual(other *OperatorSourceSpec) bool {
// RemoveFinalizer removes the operator source finalizer from the
// OperatorSource ObjectMeta.
func (s *OperatorSource) RemoveFinalizer() {
removeFinalizer(&s.ObjectMeta, OpSrcFinalizer)
shared.RemoveFinalizer(&s.ObjectMeta, OpSrcFinalizer)
}

// EnsureFinalizer ensures that the operator source finalizer is included
// in the ObjectMeta Finalizers slice. If it already exists, no state change occurs.
// If it doesn't, the finalizer is appended to the slice.
func (s *OperatorSource) EnsureFinalizer() {
ensureFinalizer(&s.ObjectMeta, OpSrcFinalizer)
shared.EnsureFinalizer(&s.ObjectMeta, OpSrcFinalizer)
}

func init() {
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/operators/v1/register.go
Expand Up @@ -17,6 +17,5 @@ var (
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}

OperatorSourceKind = "OperatorSource"
CatalogSourceConfigKind = "CatalogSourceConfig"
OperatorSourceKind = "OperatorSource"
)
136 changes: 0 additions & 136 deletions pkg/apis/operators/v1/zz_generated.deepcopy.go

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