Skip to content

Commit 82369ec

Browse files
authored
read and write the runtime definition to/from the correct file (#124)
* read and write the runtime definition to/from the correct file * use ref for component URLs
1 parent f6ac5d0 commit 82369ec

File tree

6 files changed

+30
-33
lines changed

6 files changed

+30
-33
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.116
1+
VERSION=v0.0.117
22

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

cmd/commands/runtime.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
311311
}
312312
}
313313

314-
err = installComponents(ctx, opts, rt)
314+
err = installComponents(ctx, opts, rt)
315315
if err != nil {
316316
return err
317317
}
@@ -320,11 +320,11 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
320320
fullGsPath := opts.GsCloneOpts.FS.Join(opts.GsCloneOpts.FS.Root(), gsPath)[1:]
321321

322322
if err = RunGitSourceCreate(ctx, &GitSourceCreateOptions{
323-
InsCloneOpts: opts.InsCloneOpts,
324-
GsCloneOpts: opts.GsCloneOpts,
325-
GsName: store.Get().GitSourceName,
326-
RuntimeName: opts.RuntimeName,
327-
FullGsPath: fullGsPath,
323+
InsCloneOpts: opts.InsCloneOpts,
324+
GsCloneOpts: opts.GsCloneOpts,
325+
GsName: store.Get().GitSourceName,
326+
RuntimeName: opts.RuntimeName,
327+
FullGsPath: fullGsPath,
328328
CreateDemoWorkflowTemplate: true,
329329
}); err != nil {
330330
return fmt.Errorf("failed to create `%s`: %w", store.Get().GitSourceName, err)
@@ -335,13 +335,13 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
335335
}
336336
mpCloneOpts.Parse()
337337
if err = RunGitSourceCreate(ctx, &GitSourceCreateOptions{
338-
InsCloneOpts: opts.InsCloneOpts,
339-
GsCloneOpts: mpCloneOpts,
340-
GsName: store.Get().MarketplaceGitSourceName,
341-
RuntimeName: opts.RuntimeName,
342-
FullGsPath: store.Get().MarketplaceRepo,
338+
InsCloneOpts: opts.InsCloneOpts,
339+
GsCloneOpts: mpCloneOpts,
340+
GsName: store.Get().MarketplaceGitSourceName,
341+
RuntimeName: opts.RuntimeName,
342+
FullGsPath: store.Get().MarketplaceRepo,
343343
CreateDemoWorkflowTemplate: false,
344-
Include: "**/workflowTemplate.yaml",
344+
Include: "**/workflowTemplate.yaml",
345345
}); err != nil {
346346
return fmt.Errorf("failed to create `%s`: %w", store.Get().GitSourceName, err)
347347
}
@@ -712,7 +712,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
712712
return err
713713
}
714714

715-
curRt, err := runtime.Load(fs, fs.Join(apstore.Default.BootsrtrapDir, store.Get().RuntimeFilename))
715+
curRt, err := runtime.Load(fs, fs.Join(apstore.Default.BootsrtrapDir, opts.RuntimeName+".yaml"))
716716
if err != nil {
717717
return fmt.Errorf("failed to load current runtime definition: %w", err)
718718
}
@@ -846,7 +846,7 @@ func createEventsReporter(ctx context.Context, cloneOpts *git.CloneOptions, opts
846846
Type: application.AppTypeDirectory,
847847
URL: cloneOpts.URL() + "/" + resPath,
848848
}
849-
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType,"", ""); err != nil {
849+
if err := appDef.CreateApp(ctx, opts.KubeFactory, cloneOpts, opts.RuntimeName, store.Get().CFComponentType, "", ""); err != nil {
850850
return err
851851
}
852852

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cf version
2020
### Linux
2121
```bash
2222
# download and extract the binary
23-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.116/cf-linux-amd64.tar.gz | tar zx
23+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.117/cf-linux-amd64.tar.gz | tar zx
2424

2525
# move the binary to your $PATH
2626
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -32,7 +32,7 @@ cf version
3232
### Mac
3333
```bash
3434
# download and extract the binary
35-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.116/cf-darwin-amd64.tar.gz | tar zx
35+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.117/cf-darwin-amd64.tar.gz | tar zx
3636

3737
# move the binary to your $PATH
3838
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.0
8-
version: 0.0.116
8+
version: 0.0.117
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/runtime/runtime.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,27 @@ func Download(version *semver.Version, name string) (*Runtime, error) {
113113
runtime.Name = name
114114
runtime.Namespace = name
115115
runtime.Spec.devMode = devMode
116-
for _, component := range runtime.Spec.Components {
117-
component.URL = runtime.Spec.fullURL(component.URL)
116+
for i := range runtime.Spec.Components {
117+
runtime.Spec.Components[i].URL = runtime.Spec.fullURL(runtime.Spec.Components[i].URL)
118118
}
119+
119120
return runtime, nil
120121
}
121122

122123
func Load(fs fs.FS, filename string) (*Runtime, error) {
123124
cm := &v1.ConfigMap{}
124125
if err := fs.ReadYamls(filename, cm); err != nil {
125-
return nil, err
126+
return nil, fmt.Errorf("failed to load runtime from '%s': %w", filename, err)
126127
}
127128

128129
data := cm.Data["runtime"]
129130
runtime := &Runtime{}
130131
if err := yaml.Unmarshal([]byte(data), runtime); err != nil {
131-
return nil, err
132+
return nil, fmt.Errorf("failed to unmarshal runtime from '%s': %w", filename, err)
132133
}
133134

134-
for _, component := range runtime.Spec.Components {
135-
component.URL = runtime.Spec.fullURL(component.URL)
135+
for i := range runtime.Spec.Components {
136+
runtime.Spec.Components[i].URL = runtime.Spec.fullURL(runtime.Spec.Components[i].URL)
136137
}
137138

138139
return runtime, nil
@@ -141,7 +142,7 @@ func Load(fs fs.FS, filename string) (*Runtime, error) {
141142
func (r *Runtime) Save(fs fs.FS, filename string, config *CommonConfig) error {
142143
runtimeData, err := yaml.Marshal(r)
143144
if err != nil {
144-
return err
145+
return fmt.Errorf("failed to marshal runtime: %w", err)
145146
}
146147

147148
cm := v1.ConfigMap{
@@ -172,7 +173,7 @@ func (r *Runtime) Upgrade(fs fs.FS, newRt *Runtime, config *CommonConfig) ([]App
172173
return nil, err
173174
}
174175

175-
if err := newRt.Save(fs, fs.Join(apstore.Default.BootsrtrapDir, store.Get().RuntimeFilename), config); err != nil {
176+
if err := newRt.Save(fs, fs.Join(apstore.Default.BootsrtrapDir, r.Name+".yaml"), config); err != nil {
176177
return nil, fmt.Errorf("failed to save runtime definition: %w", err)
177178
}
178179

@@ -250,9 +251,8 @@ func (a *AppDef) CreateApp(ctx context.Context, f kube.Factory, cloneOpts *git.C
250251
Labels: map[string]string{
251252
util.EscapeAppsetFieldName(store.Get().LabelKeyCFType): cfType,
252253
},
253-
Exclude: exclude ,
254+
Exclude: exclude,
254255
Include: include,
255-
256256
},
257257
KubeFactory: f,
258258
Timeout: timeout,

pkg/store/store.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type Version struct {
4444
}
4545

4646
type Store struct {
47-
4847
ArgoCDServerName string
4948
ArgoCDTokenKey string
5049
ArgoCDTokenSecret string
@@ -76,10 +75,9 @@ type Store struct {
7675
IngressPath string
7776
LabelKeyCFType string
7877
MarketplaceGitSourceName string
79-
MarketplaceRepo string
78+
MarketplaceRepo string
8079
MaxDefVersion *semver.Version
8180
RuntimeDefURL string
82-
RuntimeFilename string
8381
Version Version
8482
WaitTimeout time.Duration
8583
WorkflowName string
@@ -147,9 +145,8 @@ func init() {
147145
s.LabelKeyCFType = "codefresh.io/entity"
148146
s.MaxDefVersion = semver.MustParse(maxDefVersion)
149147
s.RuntimeDefURL = RuntimeDefURL
150-
s.RuntimeFilename = "runtime.yaml"
151148
s.MarketplaceGitSourceName = "marketplace-git-source"
152-
s.MarketplaceRepo = "https://github.com/codefresh-io/2.0-marketplace.git/"
149+
s.MarketplaceRepo = "https://github.com/codefresh-io/2.0-marketplace.git/"
153150
s.WaitTimeout = 8 * time.Minute
154151
s.WorkflowName = "workflow"
155152
s.WorkflowReporterName = "workflow-reporter"

0 commit comments

Comments
 (0)