Skip to content

Commit

Permalink
Fix runtime (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Jul 25, 2021
1 parent 3cc2033 commit 46a7c5d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.0.32
VERSION=v0.0.33
OUT_DIR=dist
YEAR?=$(shell date +"%Y")

Expand Down
28 changes: 14 additions & 14 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"os"
"time"

"github.com/codefresh-io/cli-v2/pkg/cdUtils"
"github.com/codefresh-io/cli-v2/pkg/eventUtils"
"github.com/codefresh-io/cli-v2/pkg/log"
"github.com/codefresh-io/cli-v2/pkg/runtime"
"github.com/codefresh-io/cli-v2/pkg/store"
"github.com/codefresh-io/cli-v2/pkg/util"
cdutil "github.com/codefresh-io/cli-v2/pkg/util/cd"
eventsutil "github.com/codefresh-io/cli-v2/pkg/util/events"

"github.com/Masterminds/semver/v3"
appset "github.com/argoproj-labs/applicationset/api/v1alpha1"
Expand Down Expand Up @@ -523,8 +523,8 @@ func updateProject(repofs fs.FS, runtimeName string) error {
project.ObjectMeta.Labels = make(map[string]string)
}

appset.Spec.Template.Labels[store.Get().LabelKeyCFType] = "component"
project.ObjectMeta.Labels[store.Get().LabelKeyCFType] = "runtime"
appset.Spec.Template.Labels[store.Get().LabelKeyCFType] = store.Get().CFComponentType
project.ObjectMeta.Labels[store.Get().LabelKeyCFType] = store.Get().CFRuntimeType
return repofs.WriteYamls(projPath, project, appset)
}

Expand Down Expand Up @@ -611,18 +611,18 @@ func createRBAC(repofs fs.FS, path, runtimeName string) error {
}

func createEventSource(repofs fs.FS, path, namespace string) error {
eventSource := eventUtils.CreateEventSource(&eventUtils.CreateEventSourceOptions{
eventSource := eventsutil.CreateEventSource(&eventsutil.CreateEventSourceOptions{
Name: store.Get().ComponentsReporterName,
Namespace: namespace,
ServiceAccountName: store.Get().ComponentsReporterSA,
EventBusName: store.Get().EventBusName,
Resource: map[string]eventUtils.CreateResourceEventSourceOptions{
Resource: map[string]eventsutil.CreateResourceEventSourceOptions{
"components": {
Group: "argoproj.io",
Version: "v1alpha1",
Resource: "applications",
Namespace: namespace,
Selectors: []eventUtils.CreateSelectorOptions{
Selectors: []eventsutil.CreateSelectorOptions{
{
Key: store.Get().LabelKeyCFType,
Operation: "==",
Expand All @@ -635,7 +635,7 @@ func createEventSource(repofs fs.FS, path, namespace string) error {
Version: "v1alpha1",
Resource: "appprojects",
Namespace: namespace,
Selectors: []eventUtils.CreateSelectorOptions{
Selectors: []eventsutil.CreateSelectorOptions{
{
Key: store.Get().LabelKeyCFType,
Operation: "==",
Expand All @@ -649,7 +649,7 @@ func createEventSource(repofs fs.FS, path, namespace string) error {
}

func createSensor(repofs fs.FS, name, path, namespace, eventSourceName string) error {
sensor := eventUtils.CreateSensor(&eventUtils.CreateSensorOptions{
sensor := eventsutil.CreateSensor(&eventsutil.CreateSensorOptions{
Name: name,
Namespace: namespace,
EventSourceName: eventSourceName,
Expand Down Expand Up @@ -716,19 +716,19 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon
resPath := insFs.Join(apstore.Default.AppsDir, gsName, runtimeName, "resources")
eventSourceName := gsName + "-event-source"
gsSyncName := gsName + "-synchronize"
selectors := []eventUtils.CreateSelectorOptions{
selectors := []eventsutil.CreateSelectorOptions{
{
Key: "app.kubernetes.io/instance",
Operation: "==",
Value: gsSyncName,
},
}
eventSource := eventUtils.CreateEventSource(&eventUtils.CreateEventSourceOptions{
eventSource := eventsutil.CreateEventSource(&eventsutil.CreateEventSourceOptions{
Name: eventSourceName,
Namespace: runtimeName,
ServiceAccountName: store.Get().ComponentsReporterSA,
EventBusName: store.Get().EventBusName,
Resource: map[string]eventUtils.CreateResourceEventSourceOptions{
Resource: map[string]eventsutil.CreateResourceEventSourceOptions{
// "clusterWorkflowTemplate": {
// Group: "argoproj.io",
// Version: "v1alpha1",
Expand Down Expand Up @@ -805,7 +805,7 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon
return err
}

sensor := eventUtils.CreateSensor(&eventUtils.CreateSensorOptions{
sensor := eventsutil.CreateSensor(&eventsutil.CreateSensorOptions{
Name: gsName + "-sensor",
Namespace: runtimeName,
EventSourceName: eventSourceName,
Expand All @@ -829,7 +829,7 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon

gsPath := gsCloneOpts.FS.Join(apstore.Default.AppsDir, gsName, runtimeName)
fullGsPath := gsCloneOpts.FS.Join(gsCloneOpts.FS.Root(), gsPath)[1:]
syncApp := cdUtils.CreateApp(&cdUtils.CreateAppOptions{
syncApp := cdutil.CreateApp(&cdutil.CreateAppOptions{
Name: gsSyncName,
Namespace: runtimeName,
Project: runtimeName,
Expand Down
2 changes: 1 addition & 1 deletion docs/releases/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Installed Applications:
* Argo CD [v2.0.4](https://github.com/argoproj/argo-cd/releases/tag/v2.0.4)
* Argo CD [v2.0.5](https://github.com/argoproj/argo-cd/releases/tag/v2.0.5)
* Argo CD ApplicationSet Controller [2c62537a8e5a](https://github.com/argoproj-labs/applicationset/commit/2c62537a8e5a3d5aecad87b843870789b74bdf89)
* Argo Events [v1.4.0](https://github.com/argoproj/argo-events/releases/tag/v1.4.0)
* Argo Rollouts [v1.0.2](https://github.com/argoproj/argo-rollouts/releases/tag/v1.0.2)
Expand Down
2 changes: 1 addition & 1 deletion manifests/argo-cd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://raw.githubusercontent.com/argoproj/argo-cd/v2.0.4/manifests/install.yaml
- https://raw.githubusercontent.com/argoproj/argo-cd/v2.0.5/manifests/install.yaml
- https://raw.githubusercontent.com/argoproj-labs/applicationset/master/manifests/install.yaml?ref=2c62537a8e5a # TODO: switch to the next release when available

# will be effective on argo-cd 2.1
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (r *Runtime) Save(fs fs.FS, filename string) error {
Namespace: r.Namespace,
Labels: map[string]string{
apstore.Default.LabelKeyAppManagedBy: store.Get().BinaryName,
store.Get().LabelKeyCFType: "runtimeDef",
store.Get().LabelKeyCFType: store.Get().CFRuntimeDefType,
},
},
Data: map[string]string{
Expand Down
4 changes: 3 additions & 1 deletion pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Version struct {
type Store struct {
BinaryName string
CFComponentType string
CFRuntimeDefType string
CFRuntimeType string
CFTokenSecret string
CFTokenSecretKey string
Expand All @@ -71,6 +72,7 @@ func Get() *Store {
func init() {
s.BinaryName = binaryName
s.CFComponentType = "component"
s.CFRuntimeDefType = "runtimeDef"
s.CFRuntimeType = "runtime"
s.CFTokenSecret = "codefresh-token"
s.CFTokenSecretKey = "token"
Expand All @@ -80,7 +82,7 @@ func init() {
s.EventBusName = "codefresh-eventbus"
s.EventReportingEndpoint = "/argo/api/events"
s.GitSourceName = "default-git-source"
s.LabelKeyCFType = "codefresh.io/type"
s.LabelKeyCFType = "codefresh.io/entity"
s.MaxDefVersion = semver.MustParse(maxDefVersion)
s.RuntimeDefURL = RuntimeDefURL
s.RuntimeFilename = "runtime.yaml"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cdUtils/cdUtils.go → pkg/util/cd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package cdUtils
package util

import (
"fmt"
Expand Down Expand Up @@ -56,7 +56,7 @@ func CreateApp(opts *CreateAppOptions) *cdv1alpha1.Application {
},
Labels: map[string]string{
apstore.Default.LabelKeyAppManagedBy: store.Get().BinaryName,
"app.kubernetes.io/name": opts.Name,
"app.kubernetes.io/name": opts.Name,
},
Finalizers: []string{
"resources-finalizer.argocd.argoproj.io",
Expand Down
4 changes: 2 additions & 2 deletions pkg/eventUtils/eventUtils.go → pkg/util/events/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package eventUtils
package util

import (
"github.com/codefresh-io/cli-v2/pkg/store"
Expand Down Expand Up @@ -215,7 +215,7 @@ func CreateTrigger(opts *CreateTriggerOptions) *sensorsv1alpha1.Trigger {
DependencyName: opts.DependencyName,
DataKey: "body",
},
Dest: "data",
Dest: "data.object",
},
},
},
Expand Down

0 comments on commit 46a7c5d

Please sign in to comment.