Skip to content

Commit

Permalink
add --without-download to update-stemcell
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Linsley <[email protected]>
  • Loading branch information
dlinsley committed Jun 5, 2024
1 parent ff8d61a commit 81a933d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
20 changes: 12 additions & 8 deletions internal/commands/update_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ type UpdateStemcell struct {
Options struct {
flags.Standard

Version string `short:"v" long:"version" required:"true" description:"desired version of stemcell"`
ReleasesDir string `short:"rd" long:"releases-directory" default:"releases" description:"path to a directory to download releases into"`
Version string `short:"v" long:"version" required:"true" description:"desired version of stemcell"`
ReleasesDir string `short:"rd" long:"releases-directory" default:"releases" description:"path to a directory to download releases into"`
WithoutDownload bool `long:"without-download" description:"updates stemcell releases without downloading releases"`
}
FS billy.Filesystem
MultiReleaseSourceProvider MultiReleaseSourceProvider
Expand Down Expand Up @@ -90,14 +91,17 @@ func (update UpdateStemcell) Execute(args []string) error {
update.Logger.Printf("No change for release %q\n", rel.Name)
continue
}
lock := &kilnfileLock.Releases[i]

local, err := releaseSource.DownloadRelease(update.Options.ReleasesDir, remote)
if err != nil {
return fmt.Errorf("while downloading release %q, encountered error: %w", rel.Name, err)
if update.Options.WithoutDownload {
lock.SHA1 = remote.SHA1
} else {
local, err := releaseSource.DownloadRelease(update.Options.ReleasesDir, remote)
if err != nil {
return fmt.Errorf("while downloading release %q, encountered error: %w", rel.Name, err)
}
lock.SHA1 = local.Lock.SHA1
}

lock := &kilnfileLock.Releases[i]
lock.SHA1 = local.Lock.SHA1
lock.RemotePath = remote.RemotePath
lock.RemoteSource = remote.RemoteSource
}
Expand Down
13 changes: 10 additions & 3 deletions internal/component/artifactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,20 @@ func (ars *ArtifactoryReleaseSource) GetMatchedRelease(spec cargo.BOSHReleaseTar
default:
return cargo.BOSHReleaseTarballLock{}, fmt.Errorf("unexpected http status: %s", http.StatusText(response.StatusCode))
}

return cargo.BOSHReleaseTarballLock{
matchedRelease := cargo.BOSHReleaseTarballLock{
Name: spec.Name,
Version: spec.Version,
RemotePath: remotePath,
RemoteSource: ars.ID,
}, nil
}

matchedRelease.SHA1, err = ars.getFileSHA1(matchedRelease)
if err != nil {
return cargo.BOSHReleaseTarballLock{}, err
}

return matchedRelease, nil
}

// FindReleaseVersion may use any of the fields on Requirement to return the best matching
Expand Down
1 change: 1 addition & 0 deletions internal/component/artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var _ = Describe("interacting with BOSH releases on Artifactory", func() {
// StemcellVersion: "9.9",
RemotePath: "bosh-releases/smoothie/9.9/mango/mango-2.3.4-smoothie-9.9.tgz",
RemoteSource: "some-mango-tree",
SHA1: "some-sha",
}))
})

Expand Down

0 comments on commit 81a933d

Please sign in to comment.