-
Notifications
You must be signed in to change notification settings - Fork 190
support replication of images across regions for IBMCloud and PowerVS #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1bf9fd3
4cb0425
360b81a
bb30d84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright 2021 RedHat. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package ibmcloud | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var ( | ||
| cmdCopyObject = &cobra.Command{ | ||
| Use: "copy-object", | ||
| Short: "Copy IBMCloud object to a bucket", | ||
| Long: "Copy an IBMCloud object from a bucket in a region to another bucket in a specified region", | ||
| Example: ` ore ibmcloud copy-object --source-name=image.qcow2 \ | ||
| --destination-region=us-south \ | ||
| --destination-bucket=coreos-dev-image-ibmcloud-us-south`, | ||
| RunE: runCopyObject, | ||
|
|
||
| SilenceUsage: true, | ||
| } | ||
|
|
||
| copyCloudObjectStorage string | ||
| sourceBucket string | ||
| sourceName string | ||
| destRegion string | ||
| destBucket string | ||
| ) | ||
|
|
||
| func init() { | ||
| IbmCloud.AddCommand(cmdCopyObject) | ||
| cmdCopyObject.Flags().StringVar(©CloudObjectStorage, "cloud-object-storage", "coreos-dev-image-ibmcloud", "cloud object storage to be used") | ||
| cmdCopyObject.Flags().StringVar(&sourceBucket, "source-bucket", "coreos-dev-image-ibmcloud-us-east", "bucket where object needs to be copied from") | ||
| cmdCopyObject.Flags().StringVar(&sourceName, "source-name", "", "name of object to be copied") | ||
| cmdCopyObject.MarkFlagRequired("source-name") | ||
| cmdCopyObject.Flags().StringVar(&destRegion, "destination-region", "", "region to be copied to") | ||
| cmdCopyObject.MarkFlagRequired("destination-region") | ||
| cmdCopyObject.Flags().StringVar(&destBucket, "destination-bucket", "", "destination bucket to copy to") | ||
| cmdCopyObject.MarkFlagRequired("destination-bucket") | ||
| } | ||
|
|
||
| func runCopyObject(cmd *cobra.Command, args []string) error { | ||
| if err := API.NewS3Client(copyCloudObjectStorage, destRegion); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| bucketExists, err := API.CheckBucketExists(destBucket) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if !bucketExists { | ||
| if err = API.CreateBucket(destBucket); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| if err = API.CopyObject(sourceBucket, sourceName, destBucket); err != nil { | ||
| fmt.Fprintf(os.Stderr, "Couldn't copy objects: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ type Build struct { | |
| FedoraCoreOsParentVersion string `json:"fedora-coreos.parent-version,omitempty"` | ||
| Gcp *Gcp `json:"gcp,omitempty"` | ||
| GitDirty string `json:"coreos-assembler.config-dirty,omitempty"` | ||
| IbmCloud *Cloudartifact `json:"ibmcloud,omitempty"` | ||
| IbmCloud []Cloudartifact `json:"ibmcloud,omitempty"` | ||
| ImageInputChecksum string `json:"coreos-assembler.image-input-checksum,omitempty"` | ||
| InputHasOfTheRpmOstree string `json:"rpm-ostree-inputhash"` | ||
| Koji *Koji `json:"koji,omitempty"` | ||
|
|
@@ -70,7 +70,7 @@ type Build struct { | |
| OverridesActive bool `json:"coreos-assembler.overrides-active,omitempty"` | ||
| PkgdiffAgainstParent PackageSetDifferences `json:"parent-pkgdiff,omitempty"` | ||
| PkgdiffBetweenBuilds PackageSetDifferences `json:"pkgdiff,omitempty"` | ||
| PowerVirtualServer *Cloudartifact `json:"powervs,omitempty"` | ||
| PowerVirtualServer []Cloudartifact `json:"powervs,omitempty"` | ||
| ReleasePayload *Image `json:"release-payload,omitempty"` | ||
| } | ||
|
|
||
|
|
@@ -103,7 +103,8 @@ type BuildArtifacts struct { | |
|
|
||
| type Cloudartifact struct { | ||
| Bucket string `json:"bucket,omitempty"` | ||
| Image string `json:"image"` | ||
| Image string `json:"image,omitempty"` | ||
| Object string `json:"object,omitempty"` | ||
|
Comment on lines
+106
to
+107
Member
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. @jlebon @cgwalters - I suggested @Prashanth684 add an
Member
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. Hmm, feels like we should just get rid of the generic
Member
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. yeah, he previously had something like
Contributor
Author
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. @jlebon thoughts?
Member
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. So let me make sure I understand:
? I mean, it depends how "well-typed" we want to be. Those clearly could use separate types, and then validation would be that much stronger (which means e.g. we don't run the risk of pushing an So overall, I'd lean towards tighter typing, but at the same time I don't think it's a pressing issue (and ideally eventually we stop hardcoding
Member
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.
looks like it, though I will admit we don't use this type for FCOS so I don't know if the
IIUC both of these would populate
I honestly think we need to take a step back and make sure all of our metadata variants make more sense. For now I propose we just go forward with what we have here.
Member
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.
Yup sure, WFM!
Contributor
Author
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. yes so IBMCloud artifacts and PowerVS artifacts would have the same fields as they both use the same cloud and similar object storage buckets. |
||
| Region string `json:"region,omitempty"` | ||
| URL string `json:"url"` | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.