-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: panic using project_verisoning_strategy without donorpackage #859
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3c9d60c
fix: panic using project_verisoning_strategy without donorpackage
mjhilton ca79b7d
fix: update to v4 artifact GHAs
mjhilton ec403e3
fix: project_versioning_strategy incorrect validation
mjhilton 0093255
docs: update for project_versioning_strategy changes
mjhilton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -2,15 +2,18 @@ package schemas | |
|
||
import ( | ||
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" | ||
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator" | ||
datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/path" | ||
"github.com/hashicorp/terraform-plugin-framework/resource" | ||
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
type ProjectVersioningStrategySchema struct{} | ||
|
||
var _ EntitySchema = ProjectVersioningStrategySchema{} | ||
var _ EntitySchemaWithResourceValidators = ProjectVersioningStrategySchema{} | ||
|
||
const ProjectVersioningStrategyResourceName = "project_versioning_strategy" | ||
|
||
|
@@ -24,7 +27,7 @@ func (p ProjectVersioningStrategySchema) GetResourceSchema() resourceSchema.Sche | |
Build(), | ||
"space_id": util.ResourceString(). | ||
Description("Space ID of the associated project."). | ||
Required(). | ||
Optional(). | ||
Build(), | ||
"donor_package_step_id": util.ResourceString(). | ||
Description("The associated donor package step ID."). | ||
|
@@ -35,34 +38,51 @@ func (p ProjectVersioningStrategySchema) GetResourceSchema() resourceSchema.Sche | |
Computed(). | ||
Build(), | ||
"donor_package": resourceSchema.SingleNestedAttribute{ | ||
Required: true, | ||
Optional: true, | ||
Description: "Donor Packages.", | ||
Attributes: map[string]resourceSchema.Attribute{ | ||
"deployment_action": util.ResourceString(). | ||
Description("Deployment action."). | ||
Optional(). | ||
Required(). | ||
Build(), | ||
"package_reference": util.ResourceString(). | ||
Description("Package reference."). | ||
Optional(). | ||
Required(). | ||
Build(), | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (p ProjectVersioningStrategySchema) GetResourceConfigValidators() []resource.ConfigValidator { | ||
return []resource.ConfigValidator{ | ||
resourcevalidator.RequiredTogether( | ||
path.MatchRoot("donor_package"), | ||
path.MatchRoot("donor_package_step_id"), | ||
), | ||
resourcevalidator.Conflicting( | ||
path.MatchRoot("template"), | ||
path.MatchRoot("donor_package"), | ||
), | ||
resourcevalidator.Conflicting( | ||
path.MatchRoot("template"), | ||
path.MatchRoot("donor_package_step_id"), | ||
), | ||
} | ||
} | ||
Comment on lines
+58
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🆒 |
||
|
||
func (p ProjectVersioningStrategySchema) GetDatasourceSchema() datasourceSchema.Schema { | ||
// no datasource required, returned as part of project datasource | ||
return datasourceSchema.Schema{} | ||
} | ||
|
||
type ProjectVersioningStrategyModel struct { | ||
ProjectID types.String `tfsdk:"project_id"` | ||
SpaceID types.String `tfsdk:"space_id"` | ||
DonorPackageStepID types.String `tfsdk:"donor_package_step_id"` | ||
Template types.String `tfsdk:"template"` | ||
DonorPackage DonorPackageModel `tfsdk:"donor_package"` | ||
ProjectID types.String `tfsdk:"project_id"` | ||
SpaceID types.String `tfsdk:"space_id"` | ||
DonorPackageStepID types.String `tfsdk:"donor_package_step_id"` | ||
Template types.String `tfsdk:"template"` | ||
DonorPackage *DonorPackageModel `tfsdk:"donor_package"` | ||
} | ||
|
||
type DonorPackageModel struct { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing you do this to match the above line over != nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, consistency of... polarity?... of the check, so that it's easy to scan down and understand. I would've preferred an
IsNull()
method, but it doesn't exist on theDonorPackage
struct versus the String above.