Skip to content

Commit 0b6c556

Browse files
CR-11153 setting up shared configurations (#381)
* setUpSharedConfigsRepo * wip * --shared-config-repo * wip * wip * generate isc namespace * small fix * transferring creating isc to app-proxy adjustment * add --create-isc flag * small changes * indentation * change commit message * isc wip * removed stuff * - add flag to runtime upgrade command - bump go-sdk - codegen * - rename function setIscRepo - bump app-proxy - bump go-sdk * bump version
1 parent 472887e commit 0b6c556

File tree

10 files changed

+54
-23
lines changed

10 files changed

+54
-23
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.362
1+
VERSION=v0.0.363
22

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

cmd/commands/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,12 @@ func askUserIfToProceedWithInsecure(ctx context.Context) error {
591591

592592
return nil
593593
}
594+
595+
func setIscRepo(ctx context.Context, suggestedSharedConfigRepo string) (string, error) {
596+
setIscRepoResponse, err := cfConfig.NewClient().V2().Runtime().SetSharedConfigRepo(ctx, suggestedSharedConfigRepo)
597+
if err != nil {
598+
return "", fmt.Errorf("failed to set shared config repo. Error: %w", err)
599+
}
600+
601+
return setIscRepoResponse, nil
602+
}

cmd/commands/runtime.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type (
101101
KubeFactory kube.Factory
102102
CommonConfig *runtime.CommonConfig
103103
NamespaceLabels map[string]string
104+
SuggestedSharedConfigRepo string
104105
versionStr string
105106
kubeContext string
106107
kubeconfig string
@@ -121,11 +122,12 @@ type (
121122
}
122123

123124
RuntimeUpgradeOptions struct {
124-
RuntimeName string
125-
Version *semver.Version
126-
CloneOpts *git.CloneOptions
127-
CommonConfig *runtime.CommonConfig
128-
DisableTelemetry bool
125+
RuntimeName string
126+
Version *semver.Version
127+
CloneOpts *git.CloneOptions
128+
CommonConfig *runtime.CommonConfig
129+
SuggestedSharedConfigRepo string
130+
DisableTelemetry bool
129131
}
130132

131133
gvr struct {
@@ -257,6 +259,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
257259
cmd.Flags().StringVar(&installationOpts.InternalIngressHost, "internal-ingress-host", "", "The internal ingress host (by default the external ingress will be used for both internal and external traffic)")
258260
cmd.Flags().StringVar(&installationOpts.GitIntegrationRegistrationOpts.Token, "personal-git-token", "", "The Personal git token for your user")
259261
cmd.Flags().StringVar(&installationOpts.versionStr, "version", "", "The runtime version to install (default: latest)")
262+
cmd.Flags().StringVar(&installationOpts.SuggestedSharedConfigRepo, "shared-config-repo", "", "URL to the shared configurations repo. (default: <installation-repo> or the existing one for this account)")
260263
cmd.Flags().BoolVar(&installationOpts.InstallDemoResources, "demo-resources", true, "Installs demo resources (default: true)")
261264
cmd.Flags().BoolVar(&installationOpts.SkipClusterChecks, "skip-cluster-checks", false, "Skips the cluster's checks")
262265
cmd.Flags().BoolVar(&installationOpts.DisableRollback, "disable-rollback", false, "If true, will not perform installation rollback after a failed installation")
@@ -376,6 +379,14 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
376379
}
377380
}
378381

382+
if opts.SuggestedSharedConfigRepo != "" {
383+
sharedConfigRepo, err := setIscRepo(cmd.Context(), opts.SuggestedSharedConfigRepo)
384+
if err != nil {
385+
return fmt.Errorf("failed to ensure shared config repo: %w", err)
386+
}
387+
log.G(cmd.Context()).Info("using repo '%s' as shared config repo for this account", sharedConfigRepo)
388+
}
389+
379390
opts.Insecure = true // installs argo-cd in insecure mode, we need this so that the eventsource can talk to the argocd-server with http
380391
opts.CommonConfig = &runtime.CommonConfig{CodefreshBaseURL: cfConfig.GetCurrentContext().URL}
381392

@@ -436,6 +447,14 @@ func runtimeUpgradeCommandPreRunHandler(cmd *cobra.Command, args []string, opts
436447
return err
437448
}
438449

450+
if opts.SuggestedSharedConfigRepo != "" {
451+
sharedConfigRepo, err := setIscRepo(cmd.Context(), opts.SuggestedSharedConfigRepo)
452+
if err != nil {
453+
return fmt.Errorf("failed to ensure shared config repo for account: %w", err)
454+
}
455+
log.G(cmd.Context()).Info("using repo '%s' as shared config repo for this account", sharedConfigRepo)
456+
}
457+
439458
return nil
440459
}
441460

@@ -934,7 +953,7 @@ func createGitSources(ctx context.Context, opts *RuntimeInstallOptions) error {
934953
func createGitIntegration(ctx context.Context, opts *RuntimeInstallOptions) error {
935954
appProxyClient, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
936955
if err != nil {
937-
return fmt.Errorf("failed to build app-proxy client: %w", err)
956+
return fmt.Errorf("failed to build app-proxy client while creating git integration: %w", err)
938957
}
939958

940959
err = addDefaultGitIntegration(ctx, appProxyClient, opts.RuntimeName, opts.GitIntegrationCreationOpts)
@@ -955,7 +974,7 @@ func createGitIntegration(ctx context.Context, opts *RuntimeInstallOptions) erro
955974
func removeGitIntegrations(ctx context.Context, opts *RuntimeUninstallOptions) error {
956975
appProxyClient, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
957976
if err != nil {
958-
return fmt.Errorf("failed to build app-proxy client: %w", err)
977+
return fmt.Errorf("failed to build app-proxy client while removing git integration: %w", err)
959978
}
960979

961980
integrations, err := appProxyClient.GitIntegrations().List(ctx)
@@ -1769,6 +1788,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
17691788
}
17701789

17711790
cmd.Flags().StringVar(&versionStr, "version", "", "The runtime version to upgrade to, defaults to latest")
1791+
cmd.Flags().StringVar(&opts.SuggestedSharedConfigRepo, "shared-config-repo", "", "URL to the shared configurations repo. (default: <installation-repo> or the existing one for this account)")
17721792
cmd.Flags().BoolVar(&opts.DisableTelemetry, "disable-telemetry", false, "If true, will disable analytics reporting for the upgrade process")
17731793
cmd.Flags().BoolVar(&store.Get().SetDefaultResources, "set-default-resources", false, "If true, will set default requests and limits on all of the runtime components")
17741794
opts.CloneOpts = apu.AddCloneFlags(cmd, &apu.CloneFlagsOptions{CloneForWrite: true})

docs/commands/cli-v2_runtime_install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ cli-v2 runtime install [runtime_name] [flags]
4949
--provider-api-url string Git provider API url
5050
--repo string Repository URL [GIT_REPO]
5151
--set-default-resources If true, will set default requests and limits on all of the runtime components
52+
--shared-config-repo string URL to the shared configurations repo. (default: <installation-repo> or the existing one for this account)
5253
--skip-cluster-checks Skips the cluster's checks
5354
--skip-ingress Skips the creation of ingress resources
5455
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist

docs/commands/cli-v2_runtime_upgrade.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ cli-v2 runtime upgrade [RUNTIME_NAME] [flags]
2828
### Options
2929

3030
```
31-
--disable-telemetry If true, will disable analytics reporting for the upgrade process
32-
-t, --git-token string Your git provider api token [GIT_TOKEN]
33-
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
34-
-h, --help help for upgrade
35-
--repo string Repository URL [GIT_REPO]
36-
--set-default-resources If true, will set default requests and limits on all of the runtime components
37-
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
38-
--version string The runtime version to upgrade to, defaults to latest
31+
--disable-telemetry If true, will disable analytics reporting for the upgrade process
32+
-t, --git-token string Your git provider api token [GIT_TOKEN]
33+
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
34+
-h, --help help for upgrade
35+
--repo string Repository URL [GIT_REPO]
36+
--set-default-resources If true, will set default requests and limits on all of the runtime components
37+
--shared-config-repo string URL to the shared configurations repo. (default: <installation-repo> or the existing one for this account)
38+
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
39+
--version string The runtime version to upgrade to, defaults to latest
3940
```
4041

4142
### Options inherited from parent commands

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.362/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.363/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.362/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.363/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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/argoproj/argo-events v0.17.1-0.20220327045437-70eaafe9afec
1111
github.com/argoproj/argo-workflows/v3 v3.3.1
1212
github.com/briandowns/spinner v1.18.1
13-
github.com/codefresh-io/go-sdk v0.43.9
13+
github.com/codefresh-io/go-sdk v0.43.10
1414
github.com/fatih/color v1.13.0
1515
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
1616
github.com/go-git/go-billy/v5 v5.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h
254254
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
255255
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
256256
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
257-
github.com/codefresh-io/go-sdk v0.43.9 h1:GemYddo4rDqB+qykq6AO5e4/N/FBCqLYI4BBTlX6EYo=
258-
github.com/codefresh-io/go-sdk v0.43.9/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg=
257+
github.com/codefresh-io/go-sdk v0.43.10 h1:SJbc1kOrgvesllkdMZsMFYWOmrFMIyi0d10jslIOIus=
258+
github.com/codefresh-io/go-sdk v0.43.10/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg=
259259
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
260260
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE=
261261
github.com/container-storage-interface/spec v1.5.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=

manifests/app-proxy/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Kustomization
33
images:
44
- name: quay.io/codefresh/cap-app-proxy
55
newName: quay.io/codefresh/cap-app-proxy
6-
newTag: 1.1274.0
6+
newTag: 1.1280.0
77
resources:
88
- app-proxy.deploy.yaml
99
- app-proxy.svc.yaml

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.362
8+
version: 0.0.363
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)