-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Drew Mullen <mullen.drew@gmail.com>
- Loading branch information
1 parent
0215a25
commit ad586a2
Showing
11 changed files
with
1,944 additions
and
2 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package batch | ||
|
||
const ( | ||
JobDefinitionStatusInactive string = "INACTIVE" | ||
JobDefinitionStatusActive string = "ACTIVE" | ||
) | ||
|
||
func JobDefinitionStatus_Values() []string { | ||
return []string{ | ||
JobDefinitionStatusInactive, | ||
JobDefinitionStatusActive, | ||
} | ||
} |
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,54 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package batch | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/batch" | ||
"github.com/aws/aws-sdk-go-v2/service/batch/types" | ||
"github.com/hashicorp/terraform-provider-aws/internal/tfresource" | ||
) | ||
|
||
func FindJobDefinitionV2ByARN(ctx context.Context, conn *batch.Client, arn string) (*types.JobDefinition, error) { | ||
input := &batch.DescribeJobDefinitionsInput{ | ||
JobDefinitions: []string{arn}, | ||
} | ||
|
||
out, err := conn.DescribeJobDefinitions(ctx, input) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if out == nil || len(out.JobDefinitions) == 0 { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
if count := len(out.JobDefinitions); count > 1 { | ||
return nil, tfresource.NewTooManyResultsError(count, input) | ||
} | ||
|
||
return &out.JobDefinitions[0], nil | ||
} | ||
|
||
func ListJobDefinitionsV2ByNameWithStatus(ctx context.Context, conn *batch.Client, input *batch.DescribeJobDefinitionsInput) ([]types.JobDefinition, error) { | ||
var out []types.JobDefinition | ||
|
||
pages := batch.NewDescribeJobDefinitionsPaginator(conn, input) | ||
for pages.HasMorePages() { | ||
page, err := pages.NextPage(ctx) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
out = append(out, page.JobDefinitions...) | ||
} | ||
|
||
if out == nil || len(out) == 0 { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
return out, nil | ||
} |
Oops, something went wrong.