Skip to content

fix git-source edit command #239

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

Merged
merged 3 commits into from
Feb 3, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.0.220
VERSION=v0.0.221

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
26 changes: 16 additions & 10 deletions cmd/commands/git-source.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ type (
ingressHost string
ingressClass string
}

dirConfig struct {
application.Config
Exclude string `json:"exclude"`
Include string `json:"include"`
}
)

func NewGitSourceCommand() *cobra.Command {
Expand Down Expand Up @@ -258,7 +264,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
}

func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
err := createDemoWorkflowTemplate(opts.gsFs, opts.runtimeName)
err := createDemoWorkflowTemplate(opts.gsFs)
if err != nil {
return fmt.Errorf("failed to create demo workflowTemplate: %w", err)
}
Expand All @@ -278,7 +284,7 @@ func createCronExamplePipeline(opts *gitSourceCronExampleOptions) error {
return fmt.Errorf("failed to create cron example trigger. Error: %w", err)
}

sensor, err := createCronExampleSensor(triggers, opts.runtimeName)
sensor, err := createCronExampleSensor(triggers)
if err != nil {
return fmt.Errorf("failed to create cron example sensor. Error: %w", err)
}
Expand Down Expand Up @@ -311,7 +317,7 @@ func createCronExampleEventSource() *eventsourcev1alpha1.EventSource {
}
}

func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger, runtimeName string) (*sensorsv1alpha1.Sensor, error) {
func createCronExampleSensor(triggers []sensorsv1alpha1.Trigger) (*sensorsv1alpha1.Sensor, error) {
dependencies := []sensorsv1alpha1.EventDependency{
{
Name: store.Get().CronExampleDependencyName,
Expand Down Expand Up @@ -585,20 +591,20 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
if err != nil {
return fmt.Errorf("failed to clone the installation repo, attemptint to edit git-source %s. Err: %w", opts.GsName, err)
}

c := &application.Config{}
err = fs.ReadJson(fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config.json"), c)
c := &dirConfig{}
fileName := fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config_dir.json")
err = fs.ReadJson(fileName, c)
if err != nil {
return fmt.Errorf("failed to read the config.json of git-source: %s. Err: %w", opts.GsName, err)
return fmt.Errorf("failed to read the %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
}

c.SrcPath = opts.GsCloneOpts.Path()
c.SrcRepoURL = opts.GsCloneOpts.URL()
c.SrcTargetRevision = opts.GsCloneOpts.Revision()

err = fs.WriteJson(fs.Join(apstore.Default.AppsDir, opts.GsName, opts.RuntimeName, "config.json"), c)
err = fs.WriteJson(fileName, c)
if err != nil {
return fmt.Errorf("failed to write the updated config.json of git-source: %s. Err: %w", opts.GsName, err)
return fmt.Errorf("failed to write the updated %s of git-source: %s. Err: %w", fileName, opts.GsName, err)
}

log.G(ctx).Info("Pushing updated GitSource to the installation repo")
Expand All @@ -609,7 +615,7 @@ func RunGitSourceEdit(ctx context.Context, opts *GitSourceEditOptions) error {
return nil
}

func createDemoWorkflowTemplate(gsFs fs.FS, runtimeName string) error {
func createDemoWorkflowTemplate(gsFs fs.FS) error {
wfTemplate := &wfv1alpha1.WorkflowTemplate{
TypeMeta: metav1.TypeMeta{
Kind: wf.WorkflowTemplateKind,
Expand Down
4 changes: 4 additions & 0 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
return err
}

if opts.GsCloneOpts.Auth.Username == "" {
opts.GsCloneOpts.Auth.Username = opts.InsCloneOpts.Auth.Username
}

if opts.GsCloneOpts.Auth.Password == "" {
opts.GsCloneOpts.Auth.Password = opts.InsCloneOpts.Auth.Password
}
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.220/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.221/cf-linux-amd64.tar.gz | tar zx

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

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.220/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.221/cf-darwin-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
2 changes: 1 addition & 1 deletion manifests/runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: '{{ namespace }}'
spec:
defVersion: 1.0.0
version: 0.0.220
version: 0.0.221
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
components:
- name: events
Expand Down