Files
NageshbansalandGitHub b7722f0f22 feat: introduce casting kind (#116)
### Summary                            

- Introduce a `kind` discriminator for Casting. Existing Casting without
a kind field keep working, empty kind defaults to `Installation`
- New `api/v1alpha1/installation/` subpackage with the Installation
Casting, Spec types and holds its own JSON schema from its Go type:
`installation/casting.schema.json`
- New Machinery interface in `api/v1alpha1/machinery.go` exposes
`Kind()` and `TrackableProperties()` so Dispatcher(Getv1alpha1 and
Forge/Cast/Gauge) work across any kind without knowing its concrete
type.
- A root casting.schema.json lists every per-Kind schema to supports
IDEs completion from one schema URL
- cmd/foundryctl gen schemas reads a list of types from schemaTargets.
Adding a kind means adding one entry.
  
Related: https://github.com/SigNoz/platform-pod/issues/1970
2026-05-16 17:40:03 +05:30

37 lines
1.2 KiB
Go

package installation
import "encoding/json"
// Infrastructure holds the configuration for infrastructure manifest generation (e.g., Terraform).
// The cloud provider is resolved automatically from spec.deployment.platform — no provider field
// is needed here.
type Infrastructure struct {
// Whether infrastructure manifest generation is enabled
Enabled bool `json:"enabled" yaml:"enabled"`
// Status holds the generated IaC file contents keyed by filename (e.g. "main.tf.json").
// This is populated by foundry after generation and written to the lock file.
Status map[string]string `json:"status,omitempty" yaml:"status,omitempty"`
_ struct{} `additionalProperties:"false"`
}
// MarshalJSON implements json.Marshaler. It manually omits Status when zero
// so that the strategic merge patch doesn't overwrite defaults with empty values.
func (i Infrastructure) MarshalJSON() ([]byte, error) {
m := map[string]any{
"enabled": i.Enabled,
}
if len(i.Status) > 0 {
m["status"] = i.Status
}
return json.Marshal(m)
}
// DefaultInfrastructure returns the default Infrastructure configuration.
func DefaultInfrastructure() Infrastructure {
return Infrastructure{
Enabled: false,
}
}