Skip to content

Commit 163553a

Browse files
rev-CR-10299 (#358)
* Revert "CR-10299 (#344)" This reverts commit b6724e2. * bump
1 parent b6724e2 commit 163553a

File tree

6 files changed

+64
-141
lines changed

6 files changed

+64
-141
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.317
1+
VERSION=v0.0.318
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/git-source.go

Lines changed: 50 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strings"
2222
"time"
2323

24-
"github.com/Masterminds/semver/v3"
2524
apcmd "github.com/argoproj-labs/argocd-autopilot/cmd/commands"
2625
"github.com/argoproj-labs/argocd-autopilot/pkg/application"
2726
"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
@@ -40,8 +39,8 @@ import (
4039
"github.com/codefresh-io/cli-v2/pkg/store"
4140
"github.com/codefresh-io/cli-v2/pkg/util"
4241
apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
43-
eventsutil "github.com/codefresh-io/cli-v2/pkg/util/events"
4442
ingressutil "github.com/codefresh-io/cli-v2/pkg/util/ingress"
43+
eventsutil "github.com/codefresh-io/cli-v2/pkg/util/events"
4544
wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
4645
billyUtils "github.com/go-git/go-billy/v5/util"
4746
"github.com/juju/ansiterm"
@@ -104,8 +103,6 @@ type (
104103
}
105104
)
106105

107-
var versionOfGitSourceByAppProxyRefactor = semver.MustParse("0.0.317")
108-
109106
func NewGitSourceCommand() *cobra.Command {
110107
cmd := &cobra.Command{
111108
Use: "git-source",
@@ -208,56 +205,37 @@ func NewGitSourceCreateCommand() *cobra.Command {
208205
}
209206

210207
func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error {
211-
version, err := getRuntimeVersion(ctx, opts.RuntimeName)
208+
// upsert git-source repo
209+
210+
gsRepo, gsFs, err := opts.GsCloneOpts.GetRepo(ctx)
212211
if err != nil {
213-
return err
212+
return fmt.Errorf("failed to clone git-source repo: %w", err)
214213
}
215214

216-
if !version.LessThan(versionOfGitSourceByAppProxyRefactor) {
217-
appProxy, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
218-
if err != nil {
219-
return err
220-
}
221-
222-
appSpecifier := opts.GsCloneOpts.Repo
223-
isInternal := util.StringIndexOf(store.Get().CFInternalGitSources, opts.GsName) > -1
224-
225-
err = appProxy.AppProxyGitSources().Create(ctx, opts.GsName, appSpecifier, opts.RuntimeName, opts.RuntimeName, isInternal)
226-
if err != nil {
227-
return fmt.Errorf("failed to create git-source: %w", err)
215+
if opts.CreateDemoResources {
216+
if err := createDemoResources(ctx, opts, gsRepo, gsFs); err != nil {
217+
return fmt.Errorf("failed to create git-source demo resources: %w", err)
228218
}
229219
} else {
230-
log.G(ctx).Infof("runtime \"%s\" is using a depracated git-source api. Versions %s and up use the app-proxy for this command", opts.RuntimeName, minAddClusterSupportedVersion)
231-
// upsert git-source repo
232-
gsRepo, gsFs, err := opts.GsCloneOpts.GetRepo(ctx)
233-
if err != nil {
234-
return fmt.Errorf("failed to clone git-source repo: %w", err)
235-
}
236-
237-
if opts.CreateDemoResources {
238-
if err := createDemoResources(ctx, opts, gsRepo, gsFs); err != nil {
239-
return fmt.Errorf("failed to create git-source demo resources: %w", err)
240-
}
241-
} else {
242-
if err := createPlaceholderIfNeeded(ctx, opts, gsRepo, gsFs); err != nil {
243-
return fmt.Errorf("failed to create a git-source placeholder: %w", err)
244-
}
220+
if err := createPlaceholderIfNeeded(ctx, opts, gsRepo, gsFs); err != nil {
221+
return fmt.Errorf("failed to create a git-source placeholder: %w", err)
245222
}
223+
}
246224

247-
appDef := &runtime.AppDef{
248-
Name: opts.GsName,
249-
Type: application.AppTypeDirectory,
250-
URL: opts.GsCloneOpts.Repo,
251-
}
225+
appDef := &runtime.AppDef{
226+
Name: opts.GsName,
227+
Type: application.AppTypeDirectory,
228+
URL: opts.GsCloneOpts.Repo,
229+
}
252230

253-
appDef.IsInternal = util.StringIndexOf(store.Get().CFInternalGitSources, appDef.Name) > -1
231+
appDef.IsInternal = util.StringIndexOf(store.Get().CFInternalGitSources, appDef.Name) > -1
254232

255-
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType, opts.Include, ""); err != nil {
256-
return fmt.Errorf("failed to create git-source application. Err: %w", err)
257-
}
233+
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType, opts.Include, ""); err != nil {
234+
return fmt.Errorf("failed to create git-source application. Err: %w", err)
258235
}
259236

260237
log.G(ctx).Infof("Successfully created git-source: \"%s\"", opts.GsName)
238+
261239
return nil
262240
}
263241

@@ -390,7 +368,7 @@ func createCronExampleEventSource() *eventsourcev1alpha1.EventSource {
390368
Name: store.Get().CronExampleEventSourceName,
391369
},
392370
Spec: eventsourcev1alpha1.EventSourceSpec{
393-
Template: tpl,
371+
Template: tpl,
394372
EventBusName: store.Get().EventBusName,
395373
Calendar: map[string]eventsourcev1alpha1.CalendarEventSource{
396374
store.Get().CronExampleEventName: {
@@ -412,7 +390,7 @@ func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger) (*sensorsv1alph
412390

413391
tpl := &sensorsv1alpha1.Template{
414392
ServiceAccountName: "argo-server",
415-
Container: &corev1.Container{},
393+
Container: &corev1.Container{},
416394
}
417395

418396
if store.Get().SetDefaultResources {
@@ -429,7 +407,7 @@ func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger) (*sensorsv1alph
429407
},
430408
Spec: sensorsv1alpha1.SensorSpec{
431409
EventBusName: "codefresh-eventbus",
432-
Template: tpl,
410+
Template: tpl,
433411
Dependencies: dependencies,
434412
Triggers: triggers,
435413
},
@@ -602,36 +580,19 @@ func NewGitSourceDeleteCommand() *cobra.Command {
602580
}
603581

604582
func RunGitSourceDelete(ctx context.Context, opts *GitSourceDeleteOptions) error {
605-
version, err := getRuntimeVersion(ctx, opts.RuntimeName)
606-
if err != nil {
607-
return err
608-
}
609-
610-
if !version.LessThan(versionOfGitSourceByAppProxyRefactor) {
611-
appProxy, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
612-
if err != nil {
613-
return err
614-
}
615-
616-
err = appProxy.AppProxyGitSources().Delete(ctx, opts.GsName)
617-
if err != nil {
618-
return fmt.Errorf("failed to delete git-source: %w", err)
619-
}
620-
} else {
621-
log.G(ctx).Infof("runtime \"%s\" is using a depracated git-source api. Versions %s and up use the app-proxy for this command", opts.RuntimeName, minAddClusterSupportedVersion)
622-
err = apcmd.RunAppDelete(ctx, &apcmd.AppDeleteOptions{
623-
CloneOpts: opts.InsCloneOpts,
624-
ProjectName: opts.RuntimeName,
625-
AppName: opts.GsName,
626-
Global: false,
627-
})
583+
err := apcmd.RunAppDelete(ctx, &apcmd.AppDeleteOptions{
584+
CloneOpts: opts.InsCloneOpts,
585+
ProjectName: opts.RuntimeName,
586+
AppName: opts.GsName,
587+
Global: false,
588+
})
628589

629-
if err != nil {
630-
return fmt.Errorf("failed to delete the git-source %s. Err: %w", opts.GsName, err)
631-
}
590+
if err != nil {
591+
return fmt.Errorf("failed to delete the git-source %s. Err: %w", opts.GsName, err)
632592
}
633593

634594
log.G(ctx).Infof("Successfully deleted the git-source: %s", opts.GsName)
595+
635596
return nil
636597
}
637598

@@ -701,53 +662,29 @@ func NewGitSourceEditCommand() *cobra.Command {
701662
func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
702663
repo, fs, err := opts.InsCloneOpts.GetRepo(ctx)
703664
if err != nil {
704-
return err
665+
return fmt.Errorf("failed to clone the installation repo, attemptint to edit git-source %s. Err: %w", opts.GsName, err)
705666
}
706-
707-
version, err := getRuntimeVersion(ctx, opts.RuntimeName)
667+
c := &dirConfig{}
668+
fileName := fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config_dir.json")
669+
err = fs.ReadJson(fileName, c)
708670
if err != nil {
709-
return err
671+
return fmt.Errorf("failed to read the %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
710672
}
711673

712-
if !version.LessThan(versionOfGitSourceByAppProxyRefactor) {
713-
appProxy, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
714-
if err != nil {
715-
return err
716-
}
717-
718-
err = appProxy.AppProxyGitSources().Edit(ctx, opts.GsName, opts.GsCloneOpts.Repo)
719-
if err != nil {
720-
return fmt.Errorf("failed to edit git-source: %w", err)
721-
}
722-
} else {
723-
log.G(ctx).Infof("runtime \"%s\" is using a depracated git-source api. Versions %s and up use the app-proxy for this command", opts.RuntimeName, minAddClusterSupportedVersion)
724-
725-
if err != nil {
726-
return fmt.Errorf("failed to clone the installation repo, attemptint to edit git-source %s. Err: %w", opts.GsName, err)
727-
}
728-
c := &dirConfig{}
729-
fileName := fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config_dir.json")
730-
err = fs.ReadJson(fileName, c)
731-
if err != nil {
732-
return fmt.Errorf("failed to read the %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
733-
}
734-
735-
c.Config.SrcPath = opts.GsCloneOpts.Path()
736-
c.Config.SrcRepoURL = opts.GsCloneOpts.URL()
737-
c.Config.SrcTargetRevision = opts.GsCloneOpts.Revision()
674+
c.Config.SrcPath = opts.GsCloneOpts.Path()
675+
c.Config.SrcRepoURL = opts.GsCloneOpts.URL()
676+
c.Config.SrcTargetRevision = opts.GsCloneOpts.Revision()
738677

739-
err = fs.WriteJson(fileName, c)
740-
if err != nil {
741-
return fmt.Errorf("failed to write the updated %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
742-
}
678+
err = fs.WriteJson(fileName, c)
679+
if err != nil {
680+
return fmt.Errorf("failed to write the updated %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
681+
}
743682

744-
log.G(ctx).Info("Pushing updated GitSource to the installation repo")
745-
if err := apu.PushWithMessage(ctx, repo, fmt.Sprintf("Persisted an updated git-source \"%s\"", opts.GsName)); err != nil {
746-
return fmt.Errorf("failed to persist the updated git-source: %s. Err: %w", opts.GsName, err)
747-
}
683+
log.G(ctx).Info("Pushing updated GitSource to the installation repo")
684+
if err := apu.PushWithMessage(ctx, repo, fmt.Sprintf("Persisted an updated git-source \"%s\"", opts.GsName)); err != nil {
685+
return fmt.Errorf("failed to persist the updated git-source: %s. Err: %w", opts.GsName, err)
748686
}
749687

750-
log.G(ctx).Infof("Successfully created git-source: \"%s\"", opts.GsName)
751688
return nil
752689
}
753690

@@ -908,7 +845,7 @@ func createGithubExampleEventSource(repoURL string, ingressHost string, runtimeN
908845
},
909846
Spec: eventsourcev1alpha1.EventSourceSpec{
910847
EventBusName: store.Get().EventBusName,
911-
Template: tpl,
848+
Template: tpl,
912849
Service: &eventsourcev1alpha1.Service{
913850
Ports: []corev1.ServicePort{
914851
{
@@ -1022,7 +959,7 @@ func createGithubExampleSensor() *sensorsv1alpha1.Sensor {
1022959
}
1023960

1024961
tpl := &sensorsv1alpha1.Template{
1025-
Container: &corev1.Container{},
962+
Container: &corev1.Container{},
1026963
ServiceAccountName: store.Get().WorkflowTriggerServiceAccount,
1027964
}
1028965

@@ -1040,7 +977,7 @@ func createGithubExampleSensor() *sensorsv1alpha1.Sensor {
1040977
},
1041978
Spec: sensorsv1alpha1.SensorSpec{
1042979
EventBusName: store.Get().EventBusName,
1043-
Template: tpl,
980+
Template: tpl,
1044981
Dependencies: dependencies,
1045982
Triggers: triggers,
1046983
},
@@ -1220,16 +1157,3 @@ func unMarshalCustomObject(obj interface{}) (map[string]interface{}, error) {
12201157
}
12211158
return crd, nil
12221159
}
1223-
1224-
func getRuntimeVersion(ctx context.Context, runtimeName string) (*semver.Version, error) {
1225-
rt, err := cfConfig.NewClient().V2().Runtime().Get(ctx, runtimeName)
1226-
if err != nil {
1227-
return nil, err
1228-
}
1229-
1230-
if rt.RuntimeVersion == nil {
1231-
return nil, fmt.Errorf("runtime \"%s\" has no version", runtimeName)
1232-
}
1233-
1234-
return semver.MustParse(*rt.RuntimeVersion), nil
1235-
}

cmd/commands/runtime.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
291291
var err error
292292
handleCliStep(reporter.InstallPhasePreCheckStart, "Starting pre checks", nil, true, false)
293293

294-
opts.Version, err = getVersionIfExists(opts.versionStr)
294+
opts.Version, err = getVersionIfExists(opts)
295295
handleCliStep(reporter.InstallStepPreCheckValidateRuntimeVersion, "Validating runtime version", err, true, false)
296296
if err != nil {
297297
return err
@@ -2357,19 +2357,19 @@ func validateRuntimeName(runtime string) error {
23572357
return err
23582358
}
23592359

2360+
func getVersionIfExists(opts *RuntimeInstallOptions) (*semver.Version, error) {
2361+
if opts.versionStr != "" {
2362+
log.G().Infof("vesionStr: %s", opts.versionStr)
2363+
return semver.NewVersion(opts.versionStr)
2364+
}
2365+
2366+
return nil, nil
2367+
}
2368+
23602369
func initializeGitSourceCloneOpts(opts *RuntimeInstallOptions) {
23612370
opts.GsCloneOpts.Provider = opts.InsCloneOpts.Provider
23622371
opts.GsCloneOpts.Auth = opts.InsCloneOpts.Auth
23632372
opts.GsCloneOpts.Progress = opts.InsCloneOpts.Progress
23642373
host, orgRepo, _, _, _, suffix, _ := aputil.ParseGitUrl(opts.InsCloneOpts.Repo)
23652374
opts.GsCloneOpts.Repo = host + orgRepo + "_git-source" + suffix + "/resources" + "_" + opts.RuntimeName
23662375
}
2367-
2368-
func getVersionIfExists(versionStr string) (*semver.Version, error) {
2369-
if versionStr != "" {
2370-
log.G().Infof("vesionStr: %s", versionStr)
2371-
return semver.NewVersion(versionStr)
2372-
}
2373-
2374-
return nil, nil
2375-
}

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.317/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.318/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.317/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.318/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.1
8-
version: 0.0.317
8+
version: 0.0.318
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/store/store.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ type Store struct {
140140
SccName string
141141
CFInternalGitSources []string
142142
CFInternalReporters []string
143-
VersionOfGitSourceAppProxyRefactor string
144143
}
145144

146145
// Get returns the global store

0 commit comments

Comments
 (0)