This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Get dynamic latest CAPEI release #331
Open
josecordaz
wants to merge
1
commit into
master
Choose a base branch
from
dinamic_latest_capei_release
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,6 +351,34 @@ func init() { | |
rootDir = dir | ||
} | ||
|
||
func getLatestCAPEIRelease() (string, error) { | ||
url := "https://api.github.com/repos/weaveworks/wksctl/releases" | ||
|
||
req, err := http.NewRequest("GET", url, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
res, err := http.DefaultClient.Do(req) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
var response []struct { | ||
Name string `json:"name"` | ||
} | ||
|
||
if err := json.NewDecoder(res.Body).Decode(&response); err != nil { | ||
return "", err | ||
} | ||
|
||
if len(response) == 0 { | ||
return "", fmt.Errorf("no releases found") | ||
} | ||
|
||
return response[0].Name, nil | ||
} | ||
|
||
func TestMultimasterSetup(t *testing.T) { | ||
// Set env var NODE_OS to either "centos" or "ubuntu" to choose a node running that OS | ||
// e.g. NODE_OS=centos go test -v test/integration/container/... | ||
|
@@ -376,8 +404,10 @@ func TestMultimasterSetup(t *testing.T) { | |
if shouldRetagPush(t, registryPort) { | ||
run(t, filepath.Join(rootDir, "environments/local-docker-registry/retag_push.sh"), "-p", strconv.Itoa(registryPort)) | ||
} | ||
// FIXME: look this value up more dynamically. | ||
const capeiImage = "weaveworks/cluster-api-existinginfra-controller:v0.2.4" | ||
release, err := getLatestCAPEIRelease() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, though, it seems great! :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want the version that matches the go.mod file - otherwise there is the potential to create the seed node with one version and the remaining nodes with a different version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems interesting. I'm curious in how that could happen. Would |
||
assert.NoError(t, err) | ||
|
||
var capeiImage = fmt.Sprintf("weaveworks/cluster-api-existinginfra-controller:%s", release) | ||
run(t, "docker", "pull", capeiImage) | ||
run(t, "docker", "tag", capeiImage, fmt.Sprintf("localhost:%d/%s", registryPort, capeiImage)) | ||
run(t, "docker", "push", fmt.Sprintf("localhost:%d/%s", registryPort, capeiImage)) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's safe to use
latest
here. That would mean that anywk
binary someone used after CAPEI got updated would end up pulling the new manifest (which could easily be inconsistent w/ the binary in some way) 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrryjcksn You're right. I'll revert this.