Skip to content

Commit

Permalink
Merge pull request #102 from Scalr/fix/SCALRCORE-25897
Browse files Browse the repository at this point in the history
SCALRCORE-25897: Remove ReadBySemanticVersion && make validString && …
  • Loading branch information
emocharnik committed Apr 21, 2023
2 parents a0d9790 + 4914e45 commit 39bde2c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/
.idea/
covprofile
31 changes: 0 additions & 31 deletions module_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ type ModuleVersions interface {
List(ctx context.Context, options ModuleVersionListOptions) (*ModuleVersionList, error)
// Read a module version by its ID.
Read(ctx context.Context, moduleVersionID string) (*ModuleVersion, error)
// ReadBySemanticVersion read module version by module and semantic version
ReadBySemanticVersion(ctx context.Context, moduleId string, version string) (*ModuleVersion, error)
}

// moduleVersions implements ModuleVersions.
Expand Down Expand Up @@ -105,32 +103,3 @@ func (s *moduleVersions) List(ctx context.Context, options ModuleVersionListOpti

return mv, nil
}

func (s *moduleVersions) ReadBySemanticVersion(ctx context.Context, moduleID string, version string) (*ModuleVersion, error) {
if !validStringID(&moduleID) {
return nil, errors.New("invalid value for module id")
}

v := &version
if !validString(v) {
return nil, errors.New("invalid value for version")
}

req, err := s.client.newRequest("GET", "module-versions", &ModuleVersionListOptions{Module: moduleID, Version: v})
if err != nil {
return nil, err
}

mvl := &ModuleVersionList{}
err = s.client.do(ctx, req, mvl)
if err != nil {
return nil, err
}
if len(mvl.Items) != 1 {
return nil, ResourceNotFoundError{
Message: fmt.Sprintf("ModuleVersion with Module ID '%v' and version '%v' not found.", moduleID, version),
}
}

return mvl.Items[0], nil
}

0 comments on commit 39bde2c

Please sign in to comment.