Skip to content

Commit

Permalink
Added archiver restore field into kubedbManifest options (#143)
Browse files Browse the repository at this point in the history
Signed-off-by: arnab-baishnab <[email protected]>
  • Loading branch information
arnab-baishnab authored Jan 24, 2025
1 parent ba0f7c7 commit 20ea92f
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 43 deletions.
1 change: 1 addition & 0 deletions apis/addons/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions apis/core/v1alpha1/restoresession_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ type MSSQLServerManifestOptions struct {
// +optional
AuthSecretName string `json:"authSecretName,omitempty"`

// Archiver specifies whether to restore the Archiver manifest or not
// +kubebuilder:default=false
// +optional
Archiver *bool `json:"archiver,omitempty"`

// ArchiverRef specifies the new name and namespace of the Archiver yaml after restore
// +optional
ArchiverRef *kmapi.ObjectReference `json:"archiverRef,omitempty"`

// TLSIssuerRef specifies the name of the IssuerRef used for TLS configurations for both client and server.
// +optional
TLSIssuerRef *core.TypedLocalObjectReference `json:"tlsIssuerRef,omitempty"`
Expand Down Expand Up @@ -241,6 +250,15 @@ type KubeDBManifestOptions struct {
// +optional
AuthSecretName string `json:"authSecretName,omitempty"`

// Archiver specifies whether to restore the Archiver manifest or not
// +kubebuilder:default=false
// +optional
Archiver *bool `json:"archiver,omitempty"`

// ArchiverRef specifies the new name and namespace of the Archiver yaml after restore
// +optional
ArchiverRef *kmapi.ObjectReference `json:"archiverRef,omitempty"`

// ConfigSecret specifies whether to restore the ConfigSecret manifest or not
// +kubebuilder:default=true
// +optional
Expand Down
21 changes: 21 additions & 0 deletions apis/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/storage/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions crds/core.kubestash.com_restoresessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9368,6 +9368,18 @@ spec:
type: object
mariaDB:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9404,6 +9416,18 @@ spec:
type: object
mongoDB:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9440,6 +9464,18 @@ spec:
type: object
msSQLServer:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9468,6 +9504,18 @@ spec:
type: object
mySQL:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9504,6 +9552,18 @@ spec:
type: object
postgres:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9540,6 +9600,18 @@ spec:
type: object
redis:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9604,6 +9676,18 @@ spec:
type: object
singlestore:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down Expand Up @@ -9645,6 +9729,18 @@ spec:
type: object
zooKeeper:
properties:
archiver:
default: false
type: boolean
archiverRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
authSecret:
default: true
type: boolean
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
go.bytebuilders.dev/license-verifier/kubernetes v0.14.4
gocloud.dev v0.40.0
gomodules.xyz/envsubst v0.2.0
gomodules.xyz/go-sh v0.1.0
gomodules.xyz/go-sh v0.1.1-0.20250117070215-e08594acad2a
gomodules.xyz/pointer v0.1.0
gomodules.xyz/x v0.0.17
k8s.io/api v0.30.3
Expand Down Expand Up @@ -174,5 +174,3 @@ require (
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace gomodules.xyz/go-sh v0.1.0 => github.com/anisurrahman75/go-sh v0.0.0-20241030063656-336ab30e016a
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcP
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/anisurrahman75/go-sh v0.0.0-20241030063656-336ab30e016a h1:vds1Kj0c/3uTud2/W66GorqmFhPcqHteeSX+6uD3+gc=
github.com/anisurrahman75/go-sh v0.0.0-20241030063656-336ab30e016a/go.mod h1:N8IrjNiYppUI/rxENYrWD6FOrSxSyEZnIekPEWM7LP0=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/PuerkitoBio/purell v1.2.1 h1:QsZ4TjvwiMpat6gBCBxEQI0rcS9ehtkKtSpiUnd9N28=
Expand Down Expand Up @@ -440,6 +436,8 @@ golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUO
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gomodules.xyz/envsubst v0.2.0 h1:piG4OcpUa/Mu7LxSo+2Ye8JH7pXXWM2XuCD8Ic7Hdwc=
gomodules.xyz/envsubst v0.2.0/go.mod h1:eB1KRKtXx6RSpl+WYxE8gFE7DhNJCoorHzSij7X3AQo=
gomodules.xyz/go-sh v0.1.1-0.20250117070215-e08594acad2a h1:Pz5BeoJLbzDpkeVu/YUmfOpaJVq/CoQuZUFl0G5WnVM=
gomodules.xyz/go-sh v0.1.1-0.20250117070215-e08594acad2a/go.mod h1:N8IrjNiYppUI/rxENYrWD6FOrSxSyEZnIekPEWM7LP0=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gomodules.xyz/mergo v0.3.13 h1:q6cL/MMXZH/MrR2+yjSihFFq6UifXqjwaqI48B6cMEM=
Expand Down
43 changes: 43 additions & 0 deletions vendor/gomodules.xyz/go-sh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ These are some of its features:
* pipe command
* shell build-in commands echo & test
* timeout support
* run multiple concurrent leaf commands using a single pipe input

Examples are important:

Expand Down Expand Up @@ -80,6 +81,48 @@ By default, pipeline returns error only if the last command exit with a non-zero

By default, pipelines's std-error is set to last command's std-error. However, you can also combine std-errors of all commands into pipeline's std-error using `session.PipeStdErrors = true`.

By default, pipeline returns error only if the last command exit with a non-zero status. However, you can also enable `pipefail` option like `bash`. In that case, pipeline returns error if any of the commands fail and for multiple failed commands, it returns the error of rightmost failed command.

session := sh.NewSession()
session.PipeFail = true
session.Command("cat", "unknown-file").Command("echo").Run()


Designing a Command Chain to Run Multiple Concurrent Leaf Commands Using a Single Pipe Input.

Features be like:
* **Input Sharing**: All leaf commands take the same input from a pipe.
* **Separate Environments**: Each leaf command runs with its own environment variables.
* **Output Aggregation**: Outputs from all commands are combined into a single result.
* **Error Handling**: Errors are collected and included in the output (e.g., shell or variable).
* **Timeouts**: Each command has same timeout and will apply simultaneously.

Below is an example of multiple concurrent leaf commands using a single pipe input

s := sh.NewSession()
s.ShowCMD = true
s.Command("echo", "hello world").LeafCommand("xargs").LeafCommand("xargs")
s.Run()

Below is an example of each leaf command runs with its own environment variables

s := sh.NewSession()
s.ShowCMD = true
var args1,args2 []interface{}

mp := make(map[string]string)
mp["COMPANY_NAME"] = "APPSCODE"
args1 = append(args1, "COMPANY_NAME")
args1 = append(args1, mp)
s.LeafCommand("printenv", args1...)

mp["COMPANY_NAME"] = "GOOGLE"
args2 = append(args2, "COMPANY_NAME")
args2 = append(args2, mp)
s.LeafCommand("printenv", args2...)

s.Run()

for more information, it better to see docs.
[![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/gomodules.xyz/go-sh)

Expand Down
Loading

0 comments on commit 20ea92f

Please sign in to comment.