Skip to content

Commit

Permalink
Feat: expose region in status (#318)
Browse files Browse the repository at this point in the history
Region is the region for the cloud resources created by this Configuration.
If spec.region is not empty, it's the value of it. Otherwise, it's the value
of spec.providerReference.region.

Signed-off-by: Zheng Xi Zhou <[email protected]>

Co-authored-by: Zheng Xi Zhou <[email protected]>
  • Loading branch information
zzxwill and Zheng Xi Zhou authored May 31, 2022
1 parent ae8296e commit cef58c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/v1beta2/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type ConfigurationApplyStatus struct {
State state.ConfigurationState `json:"state,omitempty"`
Message string `json:"message,omitempty"`
Outputs map[string]Property `json:"outputs,omitempty"`
// Region is the region for the cloud resources created by this Configuration. If spec.region is not empty, it's the
// value of it. Otherwise, it's the value of spec.providerReference.region.
Region string `json:"region,omitempty"`
}

// ConfigurationDestroyStatus is the status for Configuration destroy
Expand Down
5 changes: 5 additions & 0 deletions chart/crds/terraform.core.oam.dev_configurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ spec:
type: string
type: object
type: object
region:
description: Region is the region for the cloud resources created
by this Configuration. If spec.region is not empty, it's the
value of it. Otherwise, it's the value of spec.providerReference.region.
type: string
state:
description: A ConfigurationState represents the status of a resource
type: string
Expand Down
3 changes: 3 additions & 0 deletions controllers/configuration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ type TFConfigurationMeta struct {
VariableSecretName string
VariableSecretData map[string][]byte
DeleteResource bool
Region string
Credentials map[string]string

Backend backend.Backend
Expand Down Expand Up @@ -582,6 +583,7 @@ func (meta *TFConfigurationMeta) updateApplyStatus(ctx context.Context, k8sClien
configuration.Status.Apply = v1beta2.ConfigurationApplyStatus{
State: state,
Message: message,
Region: meta.Region,
}
configuration.Status.ObservedGeneration = configuration.Generation
if state == types.Available {
Expand Down Expand Up @@ -1110,5 +1112,6 @@ func (meta *TFConfigurationMeta) getCredentials(ctx context.Context, k8sClient c
return errors.New(provider.ErrCredentialNotRetrieved)
}
meta.Credentials = credentials
meta.Region = region
return nil
}

0 comments on commit cef58c7

Please sign in to comment.