Skip to content

Commit

Permalink
[csc] Increment version
Browse files Browse the repository at this point in the history
This change updates the version of the CSC CRD to prepare for the
pending changes to the CatalogSourceConfig spec. This change includes:
* Creating a new api package called v2 and importing it when
  appropriate.
* Moved code that is shared between different api versions to its own
  package.
* Updated the CSC CRD.
* Adding boilerplate code to generate copyright header.
  • Loading branch information
awgreene committed Jun 12, 2019
1 parent 9ca425c commit 49f564a
Show file tree
Hide file tree
Showing 54 changed files with 422 additions and 276 deletions.
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
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

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.

@@ -1,8 +1,9 @@
package v1
package v2

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"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -53,7 +54,7 @@ type CatalogSourceConfigSpec struct {
// CatalogSourceConfigStatus defines the observed state of CatalogSourceConfig
type CatalogSourceConfigStatus struct {
// Current phase of the CatalogSourceConfig object.
CurrentPhase ObjectPhase `json:"currentPhase,omitempty"`
CurrentPhase shared.ObjectPhase `json:"currentPhase,omitempty"`

// Map of packages (key) and their app registry package version (value)
PackageRepositioryVersions map[string]string `json:"packageRepositioryVersions,omitempty"`
Expand All @@ -79,13 +80,13 @@ func (csc *CatalogSourceConfig) EnsureGVK() {
// RemoveFinalizer removes the operator source finalizer from the
// CatatalogSourceConfig ObjectMeta.
func (csc *CatalogSourceConfig) RemoveFinalizer() {
removeFinalizer(&csc.ObjectMeta, CSCFinalizer)
shared.RemoveFinalizer(&csc.ObjectMeta, CSCFinalizer)
}

// EnsureFinalizer ensures that the CatatalogSourceConfig finalizer is included
// in the ObjectMeta.
func (csc *CatalogSourceConfig) EnsureFinalizer() {
ensureFinalizer(&csc.ObjectMeta, CSCFinalizer)
shared.EnsureFinalizer(&csc.ObjectMeta, CSCFinalizer)
}

func (csc *CatalogSourceConfig) EnsureDisplayName() {
Expand Down

0 comments on commit 49f564a

Please sign in to comment.