Skip to content

Commit

Permalink
release v1.4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
contabo committed Apr 2, 2024
1 parent 113a5ea commit 9fcb042
Show file tree
Hide file tree
Showing 31 changed files with 9,467 additions and 12,824 deletions.
18 changes: 15 additions & 3 deletions cmd/objects/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ func PutObject(localPath string, isDir bool, s3Prefix string, s3Client *minio.Cl
log.Fatal(fmt.Sprintf("Could not read file properties %v. Got error %v", localPath, err))
}

_, err = s3Client.FPutObject(context.Background(), createObjectBucketName, objectStat.Name(), s3Path, minio.PutObjectOptions{ContentType: "application/octet-stream"})
var minioOptions minio.PutObjectOptions
minioOptions.ContentType = "application/octet-stream"

if(createObjectVerbose) {
minioOptions.Progress = util.ShowUploadDetails(objectStat.Size())
}

_, err = s3Client.FPutObject(context.Background(), createObjectBucketName, objectStat.Name(), s3Path, minioOptions)

if err != nil {
if s.Contains(err.Error(), "API rate limit exceeded") { // retry in case of rate limit exceeded eror
time.Sleep(1000 * time.Millisecond)
_, err = s3Client.FPutObject(context.Background(), createObjectBucketName, objectStat.Name(), s3Path, minio.PutObjectOptions{ContentType: "application/octet-stream"})
_, err = s3Client.FPutObject(context.Background(), createObjectBucketName, objectStat.Name(), s3Path, minioOptions)

if err != nil {
log.Fatal(fmt.Sprintf("Could not create object file %v. Got error %v", s3Path, err))
Expand Down Expand Up @@ -103,7 +110,7 @@ var objectCreateCmd = &cobra.Command{
Use: "object",
Short: "Creates a S3 object.",
Long: `Creates a S3 object in the given bucket.`,
Example: `cntb create object --storageId f2db70cc-68ce-42fa-a27c-cec87b363619 --bucket bucket123 --prefix prefix1/ --path path1 `,
Example: `cntb create object --storageId f2db70cc-68ce-42fa-a27c-cec87b363619 --bucket bucket123 --prefix prefix1/ --path path1 --verbose`,
Run: func(cmd *cobra.Command, args []string) {
// get object storage
ApiRetrieveObjectStorageRequest := client.ApiClient().
Expand Down Expand Up @@ -186,6 +193,9 @@ var objectCreateCmd = &cobra.Command{
viper.BindPFlag("path", cmd.Flags().Lookup("path"))
createObjectPath = viper.GetString("path")

viper.BindPFlag("verbose", cmd.Flags().Lookup("verbose"))
createObjectVerbose = viper.GetBool("verbose")

if contaboCmd.InputFile == "" {
// arguments required
if createObjectObjectStorageId == "" {
Expand Down Expand Up @@ -214,4 +224,6 @@ func init() {
objectCreateCmd.Flags().StringVarP(&createObjectBucketName, "bucket", "b", "", `Bucket where the object will be created.`)
objectCreateCmd.Flags().StringVar(&createObjectPrefix, "prefix", "", `Prefix to be added to the stored object.`)
objectCreateCmd.Flags().StringVar(&createObjectPath, "path", "", `file or folder where the object will be stored.`)
objectCreateCmd.Flags().BoolVar(&createObjectVerbose, "verbose", false, `verbose mode to show uploading details.`)

}
1 change: 1 addition & 0 deletions cmd/objects/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var (
createObjectBucketName string
createObjectPrefix string
createObjectPath string
createObjectVerbose bool
)

// list
Expand Down
17 changes: 16 additions & 1 deletion cmd/util/customFunctions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package util

import "encoding/json"
import (
"encoding/json"
"time"

"github.com/cheggaaa/pb"
)

func StructToMap(obj interface{}) (newMap map[string]interface{}, err error) {
data, err := json.Marshal(obj) // Convert to a json string
Expand All @@ -10,3 +15,13 @@ func StructToMap(obj interface{}) (newMap map[string]interface{}, err error) {
err = json.Unmarshal(data, &newMap) // Convert to a map
return
}

func ShowUploadDetails(fileSize int64) *pb.ProgressBar{
progress := pb.New64(fileSize)
progress.Start()
progress.SetRefreshRate(time.Second)
progress.SetUnits(pb.U_BYTES)
progress.Prefix("Uploading")

return progress
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toolchain go1.22.0
require (
contabo.com/cli/cntb/openapi v0.0.0-00010101000000-000000000000
github.com/PaesslerAG/jsonpath v0.1.1
github.com/cheggaaa/pb v1.0.29
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/hprose/hprose-go v0.0.0-20161031134501-83de97da5004
github.com/minio/minio-go/v7 v7.0.68
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cheggaaa/pb v1.0.29 h1:FckUN5ngEk2LpvuG0fw1GEFx6LtyY2pWI/Z2QgCnEYo=
github.com/cheggaaa/pb v1.0.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand All @@ -86,6 +88,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
Expand Down Expand Up @@ -234,12 +237,15 @@ github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaW
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down
12 changes: 0 additions & 12 deletions openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ api_tag_assignments.go
api_tag_assignments_audits.go
api_tags.go
api_tags_audits.go
api_tickets.go
api_users.go
api_users_audits.go
client.go
Expand Down Expand Up @@ -158,10 +157,8 @@ docs/ListSnapshotResponse.md
docs/ListSnapshotsAuditResponse.md
docs/ListTagAuditsResponse.md
docs/ListTagResponse.md
docs/ListTicketMetadataResponse.md
docs/ListUserAuditResponse.md
docs/ListUserResponse.md
docs/MetadataType.md
docs/MinimumRequirements.md
docs/ObjectStorageAuditResponse.md
docs/ObjectStorageResponse.md
Expand Down Expand Up @@ -210,10 +207,6 @@ docs/TagAuditResponse.md
docs/TagResponse.md
docs/TagsApi.md
docs/TagsAuditsApi.md
docs/TicketCreateRequest.md
docs/TicketCreateResponse.md
docs/TicketResponse.md
docs/TicketsApi.md
docs/UnassignInstancePrivateNetworkResponse.md
docs/UpdateCustomImageRequest.md
docs/UpdateCustomImageResponse.md
Expand Down Expand Up @@ -365,10 +358,8 @@ model_list_snapshot_response.go
model_list_snapshots_audit_response.go
model_list_tag_audits_response.go
model_list_tag_response.go
model_list_ticket_metadata_response.go
model_list_user_audit_response.go
model_list_user_response.go
model_metadata_type.go
model_minimum_requirements.go
model_object_storage_audit_response.go
model_object_storage_response.go
Expand Down Expand Up @@ -403,9 +394,6 @@ model_snapshots_audit_response.go
model_tag_assignment_self_links.go
model_tag_audit_response.go
model_tag_response.go
model_ticket_create_request.go
model_ticket_create_response.go
model_ticket_response.go
model_unassign_instance_private_network_response.go
model_update_custom_image_request.go
model_update_custom_image_response.go
Expand Down
7 changes: 0 additions & 7 deletions openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ Class | Method | HTTP request | Description
*TagsApi* | [**RetrieveTagList**](docs/TagsApi.md#retrievetaglist) | **Get** /v1/tags | List tags
*TagsApi* | [**UpdateTag**](docs/TagsApi.md#updatetag) | **Patch** /v1/tags/{tagId} | Update specific tag by id
*TagsAuditsApi* | [**RetrieveTagAuditsList**](docs/TagsAuditsApi.md#retrievetagauditslist) | **Get** /v1/tags/audits | List history about your assignments (audit)
*TicketsApi* | [**CreateSupportTicket**](docs/TicketsApi.md#createsupportticket) | **Post** /v1/tickets | Create a new support ticket
*TicketsApi* | [**RetrieveTicketMetadata**](docs/TicketsApi.md#retrieveticketmetadata) | **Get** /v1/tickets/metadata | Retrieve ticket metadata
*UsersApi* | [**CreateUser**](docs/UsersApi.md#createuser) | **Post** /v1/users | Create a new user
*UsersApi* | [**DeleteUser**](docs/UsersApi.md#deleteuser) | **Delete** /v1/users/{userId} | Delete existing user by id
*UsersApi* | [**GenerateClientSecret**](docs/UsersApi.md#generateclientsecret) | **Put** /v1/users/client/secret | Generate new client secret
Expand Down Expand Up @@ -503,10 +501,8 @@ Class | Method | HTTP request | Description
- [ListSnapshotsAuditResponse](docs/ListSnapshotsAuditResponse.md)
- [ListTagAuditsResponse](docs/ListTagAuditsResponse.md)
- [ListTagResponse](docs/ListTagResponse.md)
- [ListTicketMetadataResponse](docs/ListTicketMetadataResponse.md)
- [ListUserAuditResponse](docs/ListUserAuditResponse.md)
- [ListUserResponse](docs/ListUserResponse.md)
- [MetadataType](docs/MetadataType.md)
- [MinimumRequirements](docs/MinimumRequirements.md)
- [ObjectStorageAuditResponse](docs/ObjectStorageAuditResponse.md)
- [ObjectStorageResponse](docs/ObjectStorageResponse.md)
Expand Down Expand Up @@ -541,9 +537,6 @@ Class | Method | HTTP request | Description
- [TagAssignmentSelfLinks](docs/TagAssignmentSelfLinks.md)
- [TagAuditResponse](docs/TagAuditResponse.md)
- [TagResponse](docs/TagResponse.md)
- [TicketCreateRequest](docs/TicketCreateRequest.md)
- [TicketCreateResponse](docs/TicketCreateResponse.md)
- [TicketResponse](docs/TicketResponse.md)
- [UnassignInstancePrivateNetworkResponse](docs/UnassignInstancePrivateNetworkResponse.md)
- [UpdateCustomImageRequest](docs/UpdateCustomImageRequest.md)
- [UpdateCustomImageResponse](docs/UpdateCustomImageResponse.md)
Expand Down
Loading

0 comments on commit 9fcb042

Please sign in to comment.