-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ec): ability to upgrade the cluster
- Loading branch information
Showing
8 changed files
with
476 additions
and
47 deletions.
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
SHELL:=/bin/bash | ||
SCHEMAHERO_TAG ?= 0.17.9 | ||
DOCKER_BUILD_ARGS ?= | ||
|
||
build_schema: | ||
docker build --pull --build-arg SCHEMAHERO_TAG=${SCHEMAHERO_TAG} -f deploy/Dockerfile -t ${IMAGE} . | ||
docker build --pull --build-arg SCHEMAHERO_TAG=${SCHEMAHERO_TAG} ${DOCKER_BUILD_ARGS} -f deploy/Dockerfile -t ${IMAGE} . | ||
docker push ${IMAGE} |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package embeddedcluster | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"go.uber.org/multierr" | ||
"oras.land/oras-go/v2" | ||
"oras.land/oras-go/v2/content/file" | ||
"oras.land/oras-go/v2/registry" | ||
"oras.land/oras-go/v2/registry/remote" | ||
) | ||
|
||
type pullArtifactOptions struct { | ||
client remote.Client | ||
} | ||
|
||
// pullArtifact fetches an artifact from the registry pointed by 'from'. The artifact | ||
// is stored in a temporary directory and the path to this directory is returned. | ||
// Callers are responsible for removing the temporary directory when it is no longer | ||
// needed. In case of error, the temporary directory is removed here. | ||
func pullArtifact(ctx context.Context, srcRepo, dstDir string, opts pullArtifactOptions) error { | ||
imgref, err := registry.ParseReference(srcRepo) | ||
if err != nil { | ||
return fmt.Errorf("parse image reference: %w", err) | ||
} | ||
|
||
repo, err := remote.NewRepository(srcRepo) | ||
if err != nil { | ||
return fmt.Errorf("create repository: %w", err) | ||
} | ||
|
||
fs, err := file.New(dstDir) | ||
if err != nil { | ||
return fmt.Errorf("create file store: %w", err) | ||
} | ||
defer fs.Close() | ||
|
||
if opts.client != nil { | ||
repo.Client = opts.client | ||
} | ||
|
||
tag := imgref.Reference | ||
_, tlserr := oras.Copy(ctx, repo, tag, fs, tag, oras.DefaultCopyOptions) | ||
if tlserr == nil { | ||
return nil | ||
} | ||
|
||
// if we fail to fetch the artifact using https we gonna try once more using plain | ||
// http as some versions of the registry were deployed without tls. | ||
repo.PlainHTTP = true | ||
if _, err := oras.Copy(ctx, repo, tag, fs, tag, oras.DefaultCopyOptions); err != nil { | ||
err = multierr.Combine(tlserr, err) | ||
return fmt.Errorf("fetch artifacts with or without tls: %w", err) | ||
} | ||
return nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package embeddedcluster | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func x_Test_pullArtifact(t *testing.T) { | ||
type args struct { | ||
ctx context.Context | ||
srcRepo string | ||
opts pullArtifactOptions | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "test1", | ||
args: args{ | ||
ctx: context.Background(), | ||
srcRepo: "ttl.sh/ethan/embedded-cluster-operator-bin:24h", | ||
opts: pullArtifactOptions{}, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
tmpdir := t.TempDir() | ||
t.Log(tmpdir) | ||
if err := pullArtifact(tt.args.ctx, tt.args.srcRepo, tmpdir, tt.args.opts); (err != nil) != tt.wantErr { | ||
t.Errorf("pullArtifact() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.