Skip to content

Commit

Permalink
Merge pull request #322 from ecordell/v0.4.0
Browse files Browse the repository at this point in the history
cut 0.4.0
  • Loading branch information
ecordell authored Apr 27, 2018
2 parents 93cb59f + 2921caf commit 9fbba12
Show file tree
Hide file tree
Showing 64 changed files with 3,483 additions and 529 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ local jobs = {
'sanity-checks': baseJob.sanityCheck {
stage: 'sanity',
script: [
"make vendor",
"make verify-catalog",
"make verify-codegen",
],
Expand Down
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ e2e_tests:
- export KUBECONFIG=./kubeconfig
- kubectl create secret docker-registry coreos-pull-secret --docker-server quay.io --docker-username $DOCKER_USER --docker-password $DOCKER_PASS --docker-email [email protected] --namespace=e2e-${CI_COMMIT_REF_SLUG}-${SHA8}
|| true
- 'kubectl -n e2e-${CI_COMMIT_REF_SLUG}-${SHA8} patch serviceaccount default -p ''{"imagePullSecrets": [{"name": "coreos-pull-secret"}]}'''
- 'kubectl -n e2e-${CI_COMMIT_REF_SLUG}-${SHA8} patch serviceaccount default -p ''{"imagePullSecrets": [{"name": "coreos-pull-secret"}]}'' || true'
- kubectl -n e2e-${CI_COMMIT_REF_SLUG}-${SHA8} create rolebinding e2e-admin-rb --clusterrole=cluster-admin --serviceaccount=e2e-${CI_COMMIT_REF_SLUG}-${SHA8}:default --namespace=e2e-${CI_COMMIT_REF_SLUG}-${SHA8}
|| true
- charttmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'charttmpdir'`;mkdir -p ${charttmpdir};pushd e2e/chart/templates;filenames=$(ls *.yaml);popd;for f in ${filenames};do helm template --set namespace=e2e-${CI_COMMIT_REF_SLUG}-${SHA8}
Expand All @@ -235,6 +235,7 @@ sanity-checks:
- cd $GOPATH/src/github.com/coreos/alm
image: quay.io/coreos/alm-ci:base
script:
- make vendor
- make verify-catalog
- make verify-codegen
stage: sanity
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci/base_jobs.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ local appr = utils.appr;
"$DOCKER_USER",
"$DOCKER_PASS") +
[
'kubectl -n %s patch serviceaccount default -p %s' % [_vars.namespace, std.escapeStringBash(_vars.patch)],
'kubectl -n %s patch serviceaccount default -p %s || true' % [_vars.namespace, std.escapeStringBash(_vars.patch)],
] +
[
'kubectl -n %s create rolebinding e2e-admin-rb --clusterrole=cluster-admin --serviceaccount=%s:default --namespace=%s || true' % [_vars.namespace, _vars.namespace, _vars.namespace],
Expand Down
5 changes: 0 additions & 5 deletions catalog_resources/chargeback.package.yaml

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions catalog_resources/components/chargeback.package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! package-manifest: ../../catalog_resources/components/chargeback.v0.5.1.clusterserviceversion.yaml
packageName: chargeback
channels:
- name: alpha
currentCSV: chargeback-helm-operator.v0.5.1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions catalog_resources/etcd.package.yaml

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions catalog_resources/ocs/etcd.package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! package-manifest: ../../catalog_resources/ocs/etcdoperator.v0.9.2.clusterserviceversion.yaml
packageName: etcd
channels:
- name: alpha
currentCSV: etcdoperator.v0.9.2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions catalog_resources/ocs/prometheus.package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! package-manifest: ../../catalog_resources/ocs/prometheusoperator.0.15.0.clusterserviceversion.yaml
packageName: prometheus
channels:
- name: alpha
currentCSV: prometheusoperator.0.15.0
File renamed without changes.
5 changes: 5 additions & 0 deletions catalog_resources/ocs/vault.package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! package-manifest: ../../catalog_resources/ocs/vaultoperator.0.1.9.clusterserviceversion.yaml
packageName: vault
channels:
- name: alpha
currentCSV: vault-operator.0.1.9
File renamed without changes.
5 changes: 0 additions & 5 deletions catalog_resources/prometheus.package.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions catalog_resources/vault.package.yaml

This file was deleted.

32 changes: 1 addition & 31 deletions cmd/catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import (
"strings"
"time"

log "github.com/sirupsen/logrus"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/coreos/alm/pkg/api/apis/catalogsource/v1alpha1"
"github.com/coreos/alm/pkg/api/client"
"github.com/coreos/alm/pkg/controller/operators/catalog"
"github.com/coreos/alm/pkg/lib/signals"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -55,31 +50,6 @@ func main() {
})
go http.ListenAndServe(":8080", nil)

// Create an instance of a client for accessing ALM types
crClient, err := client.NewClient(*kubeConfigPath)
if err != nil {
log.Fatalf("failed to bootstrap initial OCS catalog: %s", err)
}
_, err = crClient.CatalogsourceV1alpha1().CatalogSources(*catalogNamespace).Create(&v1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: "tectonic-ocs",
Namespace: *catalogNamespace,
},
Spec: v1alpha1.CatalogSourceSpec{
Name: "tectonic-ocs",
DisplayName: "Tectonic Open Cloud Services",
Publisher: "CoreOS, Inc.",
SourceType: "internal",
ConfigMap: "tectonic-ocs",
Secrets: []string{
"coreos-pull-secret",
},
},
})
if err != nil && !k8serrors.IsAlreadyExists(err) {
log.Fatalf("failed to bootstrap initial OCS catalog: %s", err)
}

// Create a new instance of the operator.
catalogOperator, err := catalog.NewOperator(*kubeConfigPath, *wakeupInterval, *catalogNamespace, strings.Split(*watchedNamespaces, ",")...)
if err != nil {
Expand Down
57 changes: 36 additions & 21 deletions deploy/catalog_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ func (s BySemverDir) Less(i, j int) bool {
return semverA.LessThan(*semverB)
}

// LoadedCatalog wraps an in mem catalog with version metadata
type LoadedCatalog struct {
Registry *registry.InMem
Name string
Version string
}

// loadCatalogFromFile loads an in memory catalog from a file path. Only used for testing.
func loadCatalogFromFile(path string) (*registry.InMem, error) {
func loadCatalogFromFile(path string) (*LoadedCatalog, error) {
loader := registry.ConfigMapCatalogResourceLoader{
Catalog: registry.NewInMem(),
}
Expand All @@ -53,7 +60,10 @@ func loadCatalogFromFile(path string) (*registry.InMem, error) {
if err != nil {
return nil, err
}
return loader.Catalog, nil
return &LoadedCatalog{
Registry: loader.Catalog,
Name: currentConfigMap.Name,
}, nil
}

func TestCatalogVersions(t *testing.T) {
Expand All @@ -75,8 +85,8 @@ func TestCatalogVersions(t *testing.T) {
// versions before this don't contain the catalog
oldestVersion := semver.New("0.2.1")

// collect catalog configmaps
catalogConfigMaps := []string{}
// load all available catalogs
catalogNameVersions := map[string][]*LoadedCatalog{}
for _, versioned := range versionDirs {

// ignore old versions that don't have the catalog
Expand All @@ -90,28 +100,33 @@ func TestCatalogVersions(t *testing.T) {
require.NoError(t, err)
for _, f := range manifestFiles {
if strings.HasSuffix(f.Name(), "configmap.yaml") {
catalogConfigMaps = append(catalogConfigMaps, path.Join(manifestDir, versioned.Name(), f.Name()))
loadedCatalog, err := loadCatalogFromFile(path.Join(manifestDir, versioned.Name(), f.Name()))
require.NoError(t, err)
loadedCatalog.Version = semverDirName.String()
if _, ok := catalogNameVersions[loadedCatalog.Name]; !ok {
catalogNameVersions[loadedCatalog.Name] = []*LoadedCatalog{}
}
catalogNameVersions[loadedCatalog.Name] = append(catalogNameVersions[loadedCatalog.Name], loadedCatalog)
}
}
}

// ensure services in <version> that have a `replaces` field replace something in <version - 1>
for i := 0; i < len(catalogConfigMaps)-1; i++ {
t.Logf("comparing %s and %s", catalogConfigMaps[i], catalogConfigMaps[i+1])

currentCatalog, err := loadCatalogFromFile(catalogConfigMaps[i])
require.NoError(t, err)

nextCatalog, err := loadCatalogFromFile(catalogConfigMaps[i+1])
require.NoError(t, err)

nextServices, err := nextCatalog.ListServices()
require.NoError(t, err)
for _, csv := range nextServices {
if csv.Spec.Replaces != "" {
oldCSV, err := currentCatalog.FindCSVByName(csv.Spec.Replaces)
require.NoError(t, err)
require.NotNil(t, oldCSV)
for catalogName, catalogVersions := range catalogNameVersions {
for i := 0; i < len(catalogVersions)-1; i++ {
currentCatalog := catalogVersions[i]
nextCatalog := catalogVersions[i+1]

t.Logf("comparing %s version %s to %s", catalogName, currentCatalog.Version, nextCatalog.Version)

nextServices, err := nextCatalog.Registry.ListServices()
require.NoError(t, err)
for _, csv := range nextServices {
if csv.Spec.Replaces != "" {
oldCSV, err := currentCatalog.Registry.FindCSVByName(csv.Spec.Replaces)
require.NoError(t, err)
require.NotNil(t, oldCSV)
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion deploy/chart/templates/07-subscription.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ spec:
required:
- source
- name
- startingCSV
properties:
source:
type: string
Expand Down
Loading

0 comments on commit 9fbba12

Please sign in to comment.