generated from pulumi/pulumi-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new enum value BIN_MV to Bin enum in command.proto and updated corresponding Go file. * Added arg function to builder struct A new method 'arg' has been added to the builder struct. This method appends a given string value to the 'args' slice of the builder instance. * Updated error messages in rm command The error messages in the Create, Update, and Delete methods of the rm command were previously prefixed with "wget". This has been corrected to prefix them with "rm" instead. * Added support for mv command in binPath function The binPath function now includes a case for the 'mv' command. This allows the system to return "mv" when this particular binary is requested, expanding the range of commands supported by our provisioner service. * Added 'mv' command functionality A new file, mv.go, has been added to the cmd package. This file includes the implementation of a 'mv' command with various options such as backup, destination, directory, force and more. The MvArgs struct is defined to hold these options. Two methods Cmd() and ExpectedFiles() are implemented on this struct. The Mv type is also introduced with Create(), Update(), and Delete() methods implementing respective interfaces from infer package. Finally, the newly created 'mv' command is registered in provider.go by adding it to the list of inferred resources. * WIP adding test * Regen SDKs * Refactor proto schema and add moved files * Fix compilation errors * Added property value matcher in tests A new GomegaMatcher, 'havePropertyValue', has been added to the testing suite. This matcher checks if a given property has a specific value. Currently, it only supports string values. The implementation includes methods for matching, failure messages and negated failure messages. * Added test for file move operation A new test case has been added to the service tests. This test checks the functionality of moving a file from one location to another. It creates a temporary directory and a file within it, moves the file to a new location within the same directory, and then verifies that the move was successful by checking various conditions such as exit code, stdout content, created files list, moved files map and existence of old/new files. The temporary directory is cleaned up after each test run. * Added file movement tracking in service creation The service creation function now tracks not only the files it creates, but also those it moves. This is done by creating a map of source and destination paths for moved files. The existence of these paths is checked and logged before they are added to the map. The response from the create function now includes this map of moved files along with previously returned created files list. * Updated argument handling in builder Enhanced the 'arg' function within the builder struct to only append non-empty strings to the 'args' slice. This prevents unnecessary empty string entries, improving efficiency and cleanliness of code. * Refactored test hooks in lifecycle tests The hooks within the lifecycle tests have been restructured for better readability and maintainability. The changes include: - Moved some hook functions to more appropriate locations within the code. - Added new checks in certain hook functions to validate output properties and file contents. - Removed redundant hook functions that were performing similar checks. * Struct initializer * Regen SDKs
- Loading branch information
1 parent
77e047f
commit 83b9513
Showing
28 changed files
with
2,057 additions
and
247 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,112 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path" | ||
|
||
"github.com/pulumi/pulumi-go-provider/infer" | ||
pb "github.com/unmango/pulumi-baremetal/gen/go/unmango/baremetal/v1alpha1" | ||
) | ||
|
||
type MvArgs struct { | ||
Backup string `pulumi:"backup,optional"` | ||
Destination string `pulumi:"destination,optional"` | ||
Directory string `pulumi:"directory,optional"` | ||
Force bool `pulumi:"force,optional"` | ||
Help bool `pulumi:"help,optional"` | ||
NoClobber bool `pulumi:"noClobber,optional"` | ||
NoTargetDirectory bool `pulumi:"noTargetDirectory,optional"` | ||
Source []string `pulumi:"source"` | ||
StripTrailingSlashes bool `pulumi:"stripTrailingSlashes,optional"` | ||
Suffix string `pulumi:"suffix,optional"` | ||
TargetDirectory string `pulumi:"targetDirectory,optional"` | ||
Update bool `pulumi:"update,optional"` | ||
Verbose bool `pulumi:"verbose,optional"` | ||
Version bool `pulumi:"version,optional"` | ||
} | ||
|
||
// Cmd implements CommandArgs. | ||
func (m MvArgs) Cmd() *pb.Command { | ||
b := builder{m.Source} | ||
b.opv(m.Backup, "--backup") | ||
b.op(m.Force, "--force") | ||
b.op(m.NoClobber, "--no-clobber") | ||
b.op(m.StripTrailingSlashes, "--strip-trailing-slashes") | ||
b.opv(m.Suffix, "--suffix") | ||
b.op(m.Update, "--update") | ||
b.op(m.Verbose, "--verbose") | ||
b.op(m.Version, "--version") | ||
|
||
b.opv(m.TargetDirectory, "--target-directory") | ||
b.op(m.NoTargetDirectory, "--no-target-directory") | ||
|
||
b.arg(m.Destination) | ||
b.arg(m.Directory) | ||
|
||
return &pb.Command{ | ||
Bin: pb.Bin_BIN_MV, | ||
Args: b.args, | ||
} | ||
} | ||
|
||
// ExpectedFiles implements CommandArgs. | ||
func (m MvArgs) ExpectedFiles() []string { | ||
files := []string{} | ||
|
||
mvSrc := func(d string) { | ||
for _, f := range m.Source { | ||
t := path.Join(d, path.Base(f)) | ||
files = append(files, t) | ||
} | ||
} | ||
|
||
if m.Destination != "" { | ||
files = append(files, m.Destination) | ||
} else if m.Directory != "" { | ||
mvSrc(m.Directory) | ||
} else if m.TargetDirectory != "" { | ||
mvSrc(m.TargetDirectory) | ||
} | ||
|
||
return files | ||
} | ||
|
||
var _ CommandArgs = MvArgs{} | ||
|
||
type Mv struct{} | ||
|
||
type MvState = CommandState[MvArgs] | ||
|
||
// Create implements infer.CustomCreate. | ||
func (Mv) Create(ctx context.Context, name string, inputs MvArgs, preview bool) (id string, output MvState, err error) { | ||
state := MvState{} | ||
if err := state.Create(ctx, inputs, preview); err != nil { | ||
return name, state, fmt.Errorf("mv: %w", err) | ||
} | ||
|
||
return name, state, nil | ||
} | ||
|
||
// Update implements infer.CustomUpdate. | ||
func (Mv) Update(ctx context.Context, id string, olds MvState, news MvArgs, preview bool) (MvState, error) { | ||
state, err := olds.Update(ctx, news, preview) | ||
if err != nil { | ||
return olds, fmt.Errorf("mv: %w", err) | ||
} | ||
|
||
return state, nil | ||
} | ||
|
||
// Delete implements infer.CustomDelete. | ||
func (Mv) Delete(ctx context.Context, id string, props MvState) error { | ||
if err := props.Delete(ctx); err != nil { | ||
return fmt.Errorf("mv: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
var _ = (infer.CustomCreate[MvArgs, MvState])((*Mv)(nil)) | ||
var _ = (infer.CustomUpdate[MvArgs, MvState])((*Mv)(nil)) | ||
var _ = (infer.CustomDelete[MvState])((*Mv)(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
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
Oops, something went wrong.