Skip to content

Commit

Permalink
chore: terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Kulube committed Aug 23, 2023
1 parent 5c102b9 commit ec9f35e
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 162 deletions.
24 changes: 4 additions & 20 deletions projectv1/project_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ type ProjectConfigCanonical struct {
Setting *ProjectConfigSetting `json:"setting,omitempty"`

// The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.
ID *string `json:"id,omitempty"`
ConfigID *string `json:"config_id,omitempty"`

// The unique ID.
ProjectID *string `json:"project_id,omitempty"`
Expand All @@ -2606,14 +2606,6 @@ type ProjectConfigCanonical struct {
// The flag that indicates whether a configuration update is available.
UpdateAvailable *bool `json:"update_available,omitempty"`

// A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time
// format as specified by RFC 3339.
CreatedAt *strfmt.DateTime `json:"created_at,omitempty"`

// A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time
// format as specified by RFC 3339.
UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty"`

// The last approved metadata of the configuration.
LastApproved *ProjectConfigMetadataLastApproved `json:"last_approved,omitempty"`

Expand Down Expand Up @@ -2709,7 +2701,7 @@ func UnmarshalProjectConfigCanonical(m map[string]json.RawMessage, result interf
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "id", &obj.ID)
err = core.UnmarshalPrimitive(m, "config_id", &obj.ConfigID)
if err != nil {
return
}
Expand Down Expand Up @@ -2737,14 +2729,6 @@ func UnmarshalProjectConfigCanonical(m map[string]json.RawMessage, result interf
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt)
if err != nil {
return
}
err = core.UnmarshalModel(m, "last_approved", &obj.LastApproved, UnmarshalProjectConfigMetadataLastApproved)
if err != nil {
return
Expand Down Expand Up @@ -2881,7 +2865,7 @@ func UnmarshalProjectConfigCanonicalDefinition(m map[string]json.RawMessage, res
// ProjectConfigCollectionMemberTerraform : The configuration metadata.
type ProjectConfigCollectionMemberTerraform struct {
// The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.
ID *string `json:"id,omitempty"`
ConfigID *string `json:"config_id,omitempty"`

// The unique ID.
ProjectID *string `json:"project_id,omitempty"`
Expand Down Expand Up @@ -2943,7 +2927,7 @@ const (
// UnmarshalProjectConfigCollectionMemberTerraform unmarshals an instance of ProjectConfigCollectionMemberTerraform from the specified map of raw messages.
func UnmarshalProjectConfigCollectionMemberTerraform(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(ProjectConfigCollectionMemberTerraform)
err = core.UnmarshalPrimitive(m, "id", &obj.ID)
err = core.UnmarshalPrimitive(m, "config_id", &obj.ConfigID)
if err != nil {
return
}
Expand Down
104 changes: 50 additions & 54 deletions projectv1/project_v1_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
config map[string]string

// Variables to hold link values
configIdLink string
projectIdLink string
)

Expand Down Expand Up @@ -139,48 +138,6 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
projectIdLink = *projectCanonical.ID
fmt.Fprintf(GinkgoWriter, "Saved projectIdLink value: %v\n", projectIdLink)
})
It(`CreateConfig request example`, func() {
fmt.Println("\nCreateConfig() result:")
// begin-create_config

inputVariableModel := &projectv1.InputVariable{
}
inputVariableModel.SetProperty("account_id", core.StringPtr(`$configs[].name["account-stage"].input.account_id`))
inputVariableModel.SetProperty("resource_group", core.StringPtr("stage"))
inputVariableModel.SetProperty("access_tags", core.StringPtr(`["env:stage"]`))
inputVariableModel.SetProperty("logdna_name", core.StringPtr("Name of the LogDNA stage service instance"))
inputVariableModel.SetProperty("sysdig_name", core.StringPtr("Name of the SysDig stage service instance"))

projectConfigSettingModel := &projectv1.ProjectConfigSetting{
}
projectConfigSettingModel.SetProperty("IBMCLOUD_TOOLCHAIN_ENDPOINT", core.StringPtr("https://api.us-south.devops.dev.cloud.ibm.com"))

createConfigOptions := projectService.NewCreateConfigOptions(
projectIdLink,
)
createConfigOptions.SetName("env-stage")
createConfigOptions.SetDescription("Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace.")
createConfigOptions.SetLabels([]string{"env:stage", "governance:test", "build:0"})
createConfigOptions.SetLocatorID("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global")
createConfigOptions.SetInput(inputVariableModel)
createConfigOptions.SetSetting(projectConfigSettingModel)

projectConfigCanonical, response, err := projectService.CreateConfig(createConfigOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(projectConfigCanonical, "", " ")
fmt.Println(string(b))

// end-create_config

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(201))
Expect(projectConfigCanonical).ToNot(BeNil())

configIdLink = *projectConfigCanonical.ID
fmt.Fprintf(GinkgoWriter, "Saved configIdLink value: %v\n", configIdLink)
})
It(`ListProjects request example`, func() {
fmt.Println("\nListProjects() result:")
// begin-list_projects
Expand Down Expand Up @@ -249,6 +206,45 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
Expect(response.StatusCode).To(Equal(200))
Expect(projectCanonical).ToNot(BeNil())
})
It(`CreateConfig request example`, func() {
fmt.Println("\nCreateConfig() result:")
// begin-create_config

inputVariableModel := &projectv1.InputVariable{
}
inputVariableModel.SetProperty("account_id", core.StringPtr(`$configs[].name["account-stage"].input.account_id`))
inputVariableModel.SetProperty("resource_group", core.StringPtr("stage"))
inputVariableModel.SetProperty("access_tags", core.StringPtr(`["env:stage"]`))
inputVariableModel.SetProperty("logdna_name", core.StringPtr("Name of the LogDNA stage service instance"))
inputVariableModel.SetProperty("sysdig_name", core.StringPtr("Name of the SysDig stage service instance"))

projectConfigSettingModel := &projectv1.ProjectConfigSetting{
}
projectConfigSettingModel.SetProperty("IBMCLOUD_TOOLCHAIN_ENDPOINT", core.StringPtr("https://api.us-south.devops.dev.cloud.ibm.com"))

createConfigOptions := projectService.NewCreateConfigOptions(
projectIdLink,
)
createConfigOptions.SetName("env-stage")
createConfigOptions.SetDescription("Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace.")
createConfigOptions.SetLabels([]string{"env:stage", "governance:test", "build:0"})
createConfigOptions.SetLocatorID("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global")
createConfigOptions.SetInput(inputVariableModel)
createConfigOptions.SetSetting(projectConfigSettingModel)

projectConfigCanonical, response, err := projectService.CreateConfig(createConfigOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(projectConfigCanonical, "", " ")
fmt.Println(string(b))

// end-create_config

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(201))
Expect(projectConfigCanonical).ToNot(BeNil())
})
It(`ListConfigs request example`, func() {
fmt.Println("\nListConfigs() result:")
// begin-list_configs
Expand Down Expand Up @@ -276,7 +272,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

getConfigOptions := projectService.NewGetConfigOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigCanonical, response, err := projectService.GetConfig(getConfigOptions)
Expand Down Expand Up @@ -306,7 +302,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

updateConfigOptions := projectService.NewUpdateConfigOptions(
projectIdLink,
configIdLink,
"testString",
)
updateConfigOptions.SetInput(inputVariableModel)

Expand All @@ -329,7 +325,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

forceApproveOptions := projectService.NewForceApproveOptions(
projectIdLink,
configIdLink,
"testString",
)
forceApproveOptions.SetComment("Approving the changes")

Expand All @@ -352,7 +348,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

approveOptions := projectService.NewApproveOptions(
projectIdLink,
configIdLink,
"testString",
)
approveOptions.SetComment("Approving the changes")

Expand All @@ -375,7 +371,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

checkConfigOptions := projectService.NewCheckConfigOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigVersionResponse, response, err := projectService.CheckConfig(checkConfigOptions)
Expand All @@ -397,7 +393,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

installConfigOptions := projectService.NewInstallConfigOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigVersionResponse, response, err := projectService.InstallConfig(installConfigOptions)
Expand All @@ -418,7 +414,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

uninstallConfigOptions := projectService.NewUninstallConfigOptions(
projectIdLink,
configIdLink,
"testString",
)

response, err := projectService.UninstallConfig(uninstallConfigOptions)
Expand All @@ -440,7 +436,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

listConfigResourcesOptions := projectService.NewListConfigResourcesOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigResourceCollection, response, err := projectService.ListConfigResources(listConfigResourcesOptions)
Expand All @@ -462,7 +458,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

listConfigVersionsOptions := projectService.NewListConfigVersionsOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigVersionSummaryCollection, response, err := projectService.ListConfigVersions(listConfigVersionsOptions)
Expand All @@ -484,7 +480,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

getConfigVersionOptions := projectService.NewGetConfigVersionOptions(
projectIdLink,
configIdLink,
"testString",
int64(38),
)

Expand All @@ -507,7 +503,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

deleteConfigOptions := projectService.NewDeleteConfigOptions(
projectIdLink,
configIdLink,
"testString",
)

projectConfigDelete, response, err := projectService.DeleteConfig(deleteConfigOptions)
Expand Down
Loading

0 comments on commit ec9f35e

Please sign in to comment.