Skip to content

Commit 3a0077c

Browse files
CR-9610 (#282)
* bump * init * mark runtime components as true * bump * codegen * no ap * added appset label template and gs logic * fixed labels for reporters * tested * bool string refactor * added support for upgrade * codegen * tested gs list * bump autopilot * codegen * trigger ci * trigger ci * calculating flag outside run func * removed dash * removed redundant * setting hard coded true for reporters and changing to trimPrefix
1 parent bdc300d commit 3a0077c

File tree

14 files changed

+84
-37
lines changed

14 files changed

+84
-37
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.258
1+
VERSION=v0.0.259
22

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

cmd/commands/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,4 @@ func askUserIfToProceedWithInsecure(ctx context.Context) error {
585585
}
586586
return nil
587587
}
588+

cmd/commands/git-source.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ package commands
1515

1616
import (
1717
"context"
18+
"encoding/json"
1819
"fmt"
1920
"os"
2021
"strings"
2122
"time"
2223

23-
"encoding/json"
24-
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"
@@ -226,6 +225,8 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
226225
URL: opts.GsCloneOpts.Repo,
227226
}
228227

228+
appDef.IsInternal = util.StringIndexOf(store.Get().CFInternalGitSources, appDef.Name) > -1
229+
229230
if err := appDef.CreateApp(ctx, nil, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFGitSourceType, opts.Include, ""); err != nil {
230231
return fmt.Errorf("failed to create git-source application. Err: %w", err)
231232
}
@@ -434,6 +435,8 @@ func createCronExampleTrigger() (*sensorsv1alpha1.Trigger, error) {
434435
}
435436

436437
func NewGitSourceListCommand() *cobra.Command {
438+
var includeInternal bool
439+
437440
cmd := &cobra.Command{
438441
Use: "list RUNTIME_NAME",
439442
Short: "List all Codefresh git-sources of a given runtime",
@@ -444,13 +447,16 @@ func NewGitSourceListCommand() *cobra.Command {
444447
return fmt.Errorf("must enter runtime name")
445448
}
446449

447-
return RunGitSourceList(cmd.Context(), args[0])
450+
return RunGitSourceList(cmd.Context(), args[0], includeInternal)
448451
},
449452
}
453+
454+
cmd.Flags().BoolVar(&includeInternal, "include-internal", false, "If true, will include the Codefresh internal git-sources")
455+
450456
return cmd
451457
}
452458

453-
func RunGitSourceList(ctx context.Context, runtimeName string) error {
459+
func RunGitSourceList(ctx context.Context, runtimeName string, includeInternal bool) error {
454460
isRuntimeExists := checkExistingRuntimes(ctx, runtimeName)
455461
if isRuntimeExists == nil {
456462
return fmt.Errorf("there is no runtime by the name: %s", runtimeName)
@@ -474,6 +480,11 @@ func RunGitSourceList(ctx context.Context, runtimeName string) error {
474480

475481
for _, gs := range gitSources {
476482
name := gs.Metadata.Name
483+
nameWithoutRuntimePrefix := strings.TrimPrefix(name, fmt.Sprintf("%s-", runtimeName))
484+
if util.StringIndexOf(store.Get().CFInternalGitSources, nameWithoutRuntimePrefix) > -1 && !includeInternal {
485+
continue
486+
}
487+
477488
repoURL := "N/A"
478489
path := "N/A"
479490
healthStatus := "N/A"

cmd/commands/runtime.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type (
124124
reporterName string
125125
gvr []gvr
126126
saName string
127+
IsInternal bool
127128
}
128129

129130
summaryLogLevels string
@@ -590,7 +591,11 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
590591
KubeContextName: opts.kubeContext,
591592
Timeout: store.Get().WaitTimeout,
592593
ArgoCDLabels: map[string]string{
593-
store.Get().LabelKeyCFType: store.Get().CFComponentType,
594+
store.Get().LabelKeyCFType: store.Get().CFComponentType,
595+
store.Get().LabelKeyCFInternal: "true",
596+
},
597+
BootstrapAppsLabels: map[string]string{
598+
store.Get().LabelKeyCFInternal: "true",
594599
},
595600
})
596601
handleCliStep(reporter.InstallStepBootstrapRepo, "Bootstrapping repository", err, true)
@@ -602,7 +607,8 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
602607
CloneOpts: opts.InsCloneOpts,
603608
ProjectName: opts.RuntimeName,
604609
Labels: map[string]string{
605-
store.Get().LabelKeyCFType: fmt.Sprintf("{{ labels.%s }}", util.EscapeAppsetFieldName(store.Get().LabelKeyCFType)),
610+
store.Get().LabelKeyCFType: fmt.Sprintf("{{ labels.%s }}", util.EscapeAppsetFieldName(store.Get().LabelKeyCFType)),
611+
store.Get().LabelKeyCFInternal: fmt.Sprintf("{{ labels.%s }}", util.EscapeAppsetFieldName(store.Get().LabelKeyCFInternal)),
606612
},
607613
})
608614
handleCliStep(reporter.InstallStepCreateProject, "Creating Project", err, true)
@@ -691,6 +697,7 @@ func createRuntimeComponents(ctx context.Context, opts *RuntimeInstallOptions, r
691697
for _, component := range rt.Spec.Components {
692698
infoStr := fmt.Sprintf("Creating component \"%s\"", component.Name)
693699
log.G(ctx).Infof(infoStr)
700+
component.IsInternal = true
694701
err = component.CreateApp(ctx, opts.KubeFactory, opts.InsCloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", "")
695702
if err != nil {
696703
err = util.DecorateErrorWithDocsLink(fmt.Errorf("failed to create \"%s\" application: %w", component.Name, err))
@@ -820,6 +827,7 @@ you can try to create it manually by running:
820827

821828
func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *runtime.Runtime) error {
822829
var err error
830+
823831
if opts.IngressHost != "" && !store.Get().SkipIngress {
824832
if err = createWorkflowsIngress(ctx, opts, rt); err != nil {
825833
return fmt.Errorf("failed to patch Argo-Workflows ingress: %w", err)
@@ -844,7 +852,8 @@ func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *run
844852
version: "v1alpha1",
845853
},
846854
},
847-
saName: store.Get().CodefreshSA,
855+
saName: store.Get().CodefreshSA,
856+
IsInternal: true,
848857
}); err != nil {
849858
return fmt.Errorf("failed to create workflows-reporter: %w", err)
850859
}
@@ -868,7 +877,8 @@ func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *run
868877
version: "v1alpha1",
869878
},
870879
},
871-
saName: store.Get().RolloutReporterServiceAccount,
880+
saName: store.Get().RolloutReporterServiceAccount,
881+
IsInternal: true,
872882
}); err != nil {
873883
return fmt.Errorf("failed to create rollout-reporter: %w", err)
874884
}
@@ -1476,6 +1486,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
14761486

14771487
for _, component := range newComponents {
14781488
log.G(ctx).Infof("Installing new component \"%s\"", component.Name)
1489+
component.IsInternal = true
14791490
err = component.CreateApp(ctx, nil, opts.CloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", "")
14801491
if err != nil {
14811492
err = fmt.Errorf("failed to create \"%s\" application: %w", component.Name, err)
@@ -1651,9 +1662,10 @@ func createEventsReporter(ctx context.Context, cloneOpts *git.CloneOptions, opts
16511662

16521663
resPath := cloneOpts.FS.Join(apstore.Default.AppsDir, store.Get().EventsReporterName, opts.RuntimeName, "resources")
16531664
appDef := &runtime.AppDef{
1654-
Name: store.Get().EventsReporterName,
1655-
Type: application.AppTypeDirectory,
1656-
URL: cloneOpts.URL() + "/" + resPath,
1665+
Name: store.Get().EventsReporterName,
1666+
Type: application.AppTypeDirectory,
1667+
URL: cloneOpts.URL() + "/" + resPath,
1668+
IsInternal: true,
16571669
}
16581670
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
16591671
return err
@@ -1681,9 +1693,10 @@ func createEventsReporter(ctx context.Context, cloneOpts *git.CloneOptions, opts
16811693
func createReporter(ctx context.Context, cloneOpts *git.CloneOptions, opts *RuntimeInstallOptions, reporterCreateOpts reporterCreateOptions) error {
16821694
resPath := cloneOpts.FS.Join(apstore.Default.AppsDir, reporterCreateOpts.reporterName, opts.RuntimeName, "resources")
16831695
appDef := &runtime.AppDef{
1684-
Name: reporterCreateOpts.reporterName,
1685-
Type: application.AppTypeDirectory,
1686-
URL: cloneOpts.URL() + "/" + resPath,
1696+
Name: reporterCreateOpts.reporterName,
1697+
Type: application.AppTypeDirectory,
1698+
URL: cloneOpts.URL() + "/" + resPath,
1699+
IsInternal: reporterCreateOpts.IsInternal,
16871700
}
16881701
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
16891702
return err

docs/commands/cli-v2_git-source_edit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ cli-v2 git-source edit RUNTIME_NAME GITSOURCE_NAME [flags]
1919
```
2020
--git-src-git-token string Your git provider api token [GIT_SRC_GIT_TOKEN]
2121
--git-src-git-user string Your git provider user name [GIT_SRC_GIT_USER] (not required in GitHub)
22-
--git-src-provider string The git provider, one of: gitea|github|gitlab
22+
--git-src-provider string The git provider, one of: azure|gitea|github|gitlab
2323
--git-src-repo string Repository URL [GIT_SRC_GIT_REPO]
2424
-t, --git-token string Your git provider api token [GIT_TOKEN]
2525
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
2626
-h, --help help for edit
27-
--provider string The git provider, one of: gitea|github|gitlab
27+
--provider string The git provider, one of: azure|gitea|github|gitlab
2828
--repo string Repository URL [GIT_REPO]
2929
```
3030

docs/commands/cli-v2_git-source_list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ cli-v2 git-source list my-runtime
1515
### Options
1616

1717
```
18-
-h, --help help for list
18+
-h, --help help for list
19+
--include-internal If true, will include the Codefresh internal git-sources
1920
```
2021

2122
### Options inherited from parent commands

docs/commands/cli-v2_runtime_install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cli-v2 runtime install [runtime_name] [flags]
3939
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
4040
-n, --namespace string If present, the namespace scope for this CLI request
4141
--personal-git-token string The Personal git token for your user
42-
--provider string The git provider, one of: gitea|github|gitlab
42+
--provider string The git provider, one of: azure|gitea|github|gitlab
4343
--provider-api-url string Git provider API url
4444
--repo string Repository URL [GIT_REPO]
4545
--skip-cluster-checks Skips the cluster's checks

docs/releases/release_notes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
### Installed Applications:
22

3-
- Argo CD [v2.1.10](https://github.com/argoproj/argo-cd/releases/tag/v2.1.10)
4-
- Argo CD ApplicationSet Controller [v0.2.0](https://github.com/argoproj-labs/applicationset/releases/tag/v0.2.0)
5-
- Argo Events [v1.5.5](https://github.com/argoproj/argo-events/releases/tag/v1.5.5)
6-
- Argo Rollouts [v1.1.0](https://github.com/argoproj/argo-rollouts/releases/tag/v1.1.0)
7-
- Argo Workflows [v3.2.6](https://github.com/argoproj/argo-workflows/releases/tag/v3.2.6)
3+
- Argo CD [v2.1.10](https://github.com/argoproj/argo-cd/releases/tag/v2.1.10)
4+
- Argo CD ApplicationSet Controller [v0.2.0](https://github.com/argoproj-labs/applicationset/releases/tag/v0.2.0)
5+
- Argo Events [v1.5.5](https://github.com/argoproj/argo-events/releases/tag/v1.5.5)
6+
- Argo Rollouts [v1.1.0](https://github.com/argoproj/argo-rollouts/releases/tag/v1.1.0)
7+
- Argo Workflows [v3.2.6](https://github.com/argoproj/argo-workflows/releases/tag/v3.2.6)
88

99
### Using brew:
1010

@@ -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.258/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.259/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.258/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.259/cf-darwin-amd64.tar.gz | tar zx
4040

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

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.16
55
require (
66
github.com/Masterminds/semver/v3 v3.1.1
77
github.com/argoproj-labs/applicationset v0.2.0
8-
github.com/argoproj-labs/argocd-autopilot v0.2.27
8+
github.com/argoproj-labs/argocd-autopilot v0.2.30
99
github.com/argoproj/argo-cd/v2 v2.1.9
1010
github.com/argoproj/argo-events v1.4.0
1111
github.com/argoproj/argo-workflows/v3 v3.1.6
@@ -17,7 +17,7 @@ require (
1717
github.com/go-git/go-billy/v5 v5.3.1
1818
github.com/go-git/go-git/v5 v5.4.1
1919
github.com/gobuffalo/packr v1.30.1
20-
github.com/google/uuid v1.1.2
20+
github.com/google/uuid v1.3.0
2121
github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc
2222
github.com/manifoldco/promptui v0.8.0
2323
github.com/mattn/go-colorable v0.1.12 // indirect

go.sum

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ github.com/ardielle/ardielle-go v1.5.2/go.mod h1:I4hy1n795cUhaVt/ojz83SNVCYIGsAF
172172
github.com/ardielle/ardielle-tools v1.5.4/go.mod h1:oZN+JRMnqGiIhrzkRN9l26Cej9dEx4jeNG6A+AdkShk=
173173
github.com/argoproj-labs/applicationset v0.2.0 h1:yq3u88VtH9bXAl8DkIzBi0Q5FCe/ExZHlnGHDxxsyY4=
174174
github.com/argoproj-labs/applicationset v0.2.0/go.mod h1:vElTdgajynEAIRuQMqQwYWSWTbdgrQPW6zDsxNPs+NE=
175-
github.com/argoproj-labs/argocd-autopilot v0.2.27 h1:mENBxlfLV1waksrScxPlWEoIg9b2M7cizU++LBW5mrg=
176-
github.com/argoproj-labs/argocd-autopilot v0.2.27/go.mod h1:GjkycwSEKpDJaxHMz0gfIclRIdmHiSW7p9U2mR+We6Q=
175+
github.com/argoproj-labs/argocd-autopilot v0.2.30 h1:tSn4DqW3J1iMzfmkcjyhFlsfEM0RVhAfsRfdQG8Xg5E=
176+
github.com/argoproj-labs/argocd-autopilot v0.2.30/go.mod h1:d9H2xQ1DZt8jw5aFMp2JWpi9OhmXfQ+ZDd9z4k3N2+4=
177177
github.com/argoproj/argo-cd/v2 v2.1.0-rc2/go.mod h1:a21F1IEszRrCLvXXYc1sML3mjlMN3pp6rpDxy+7E0os=
178178
github.com/argoproj/argo-cd/v2 v2.1.0/go.mod h1:/e8fSyHanaAHLR5YsIIWfCGujTN452K6L7DaYep5KRU=
179179
github.com/argoproj/argo-cd/v2 v2.1.9 h1:D9YnPQq4xDec2Awm8ANjioEuRfJcjtdlrsQRmVR7l1s=
@@ -665,8 +665,9 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU
665665
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
666666
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
667667
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
668-
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
669668
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
669+
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
670+
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
670671
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
671672
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
672673
github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg=
@@ -931,6 +932,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
931932
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
932933
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
933934
github.com/mholt/certmagic v0.6.2-0.20190624175158-6a42ef9fe8c2/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY=
935+
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5 h1:YH424zrwLTlyHSH/GzLMJeu5zhYVZSx5RQxGKm1h96s=
936+
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5/go.mod h1:PoGiBqKSQK1vIfQ+yVaFcGjDySHvym6FM1cNYnwzbrY=
934937
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
935938
github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
936939
github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=

0 commit comments

Comments
 (0)