Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/moby/patternmatcher v0.6.1
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0
github.com/pkg/errors v0.9.1
github.com/skpr/api v1.5.1
github.com/skpr/api v1.5.2
github.com/skpr/compass/tracing v0.0.0-20251208094547-dafe383c3926
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.10.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skpr/api v1.5.1 h1:/B4eHvXseL2LiAvxj41gqB0EbbG3lCGPPx19AjTeIw0=
github.com/skpr/api v1.5.1/go.mod h1:jF55rQ39jyjTVo6MA74SRwYQduK/w+lPj6hjR6hqsyQ=
github.com/skpr/api v1.5.2 h1:JDIha2gf9Ycy/5JEYY+qyHidjKAIQa0M2q6jaFq0Vao=
github.com/skpr/api v1.5.2/go.mod h1:LMyIte2bWjGuO2e8XOA6FKNFUX10itF2qYVTckM7dwg=
github.com/skpr/compass/tracing v0.0.0-20251208094547-dafe383c3926 h1:g8m8qqehB6/GMeM81BaIXQOkD2LZbCQE0HPRGear9Jw=
github.com/skpr/compass/tracing v0.0.0-20251208094547-dafe383c3926/go.mod h1:Rokt2mnHteBaBmsSgiNk4P7laV0E8/BLQsSLyGUJLtk=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
Expand Down
23 changes: 14 additions & 9 deletions internal/client/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestLoadFromDirectory(t *testing.T) {
Size: "small",
Services: Services{
MySQL: map[string]MySQL{
"default": MySQL{
"default": {
Image: MySQLImage{
Schedule: "0 20 * * *",
},
Expand Down Expand Up @@ -75,6 +75,9 @@ func TestLoadFromDirectory(t *testing.T) {
Backup: Backup{
Schedule: "@daily",
},
Metrics: Metrics{
Enabled: true,
},
},
"stg": {
Ingress: Ingress{
Expand All @@ -92,7 +95,7 @@ func TestLoadFromDirectory(t *testing.T) {
Size: "small",
Services: Services{
MySQL: map[string]MySQL{
"default": MySQL{
"default": {
Image: MySQLImage{
Schedule: "0 20 * * *",
},
Expand Down Expand Up @@ -160,7 +163,7 @@ func TestLoadFromDirectory(t *testing.T) {
Size: "large",
Services: Services{
MySQL: map[string]MySQL{
"default": MySQL{
"default": {
Image: MySQLImage{
Schedule: "0 20 * * *",
},
Expand Down Expand Up @@ -225,7 +228,7 @@ func TestLoadFromDirectory(t *testing.T) {
Size: "small",
Services: Services{
MySQL: map[string]MySQL{
"default": MySQL{
"default": {
Image: MySQLImage{
Schedule: "0 20 * * *",
},
Expand Down Expand Up @@ -279,12 +282,14 @@ func TestLoadFromDirectory(t *testing.T) {
}

for name, environment := range environments {
e, err := LoadFromDirectory("./testdata/.skpr", name)
assert.NoError(t, err)
t.Run(name, func(t *testing.T) {
e, err := LoadFromDirectory("./testdata/.skpr", name)
assert.NoError(t, err)

if diff := deep.Equal(environment, e); diff != nil {
t.Error(diff)
}
if diff := deep.Equal(environment, e); diff != nil {
t.Error(diff)
}
})
}

}
3 changes: 3 additions & 0 deletions internal/client/project/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (e Environment) Proto(name, version string) (*pb.Environment, error) {
Schedule: e.Backup.Schedule,
Suspend: e.Backup.Suspend,
},
Metrics: &pb.EnvironmentMetrics{
Enabled: e.Metrics.Enabled,
},
}

for bvName, bvConfig := range e.Backup.Volume {
Expand Down
8 changes: 8 additions & 0 deletions internal/client/project/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func TestProto(t *testing.T) {
},
},
},
Metrics: Metrics{
Enabled: true,
},
}

want := &pb.Environment{
Expand Down Expand Up @@ -318,6 +321,9 @@ func TestProto(t *testing.T) {
},
},
},
Metrics: &pb.EnvironmentMetrics{
Enabled: true,
},
}

env, err := environment.Proto("dev", "v0.0.1")
Expand All @@ -342,4 +348,6 @@ func TestProto(t *testing.T) {
assert.Equal(t, want.Solr, env.Solr, "Solr is configured")
assert.Equal(t, want.Link, env.Link, "Links are configured")
assert.Equal(t, want.Volume, env.Volume, "Volumes are configured")

assert.Equal(t, want.Metrics, env.Metrics, "Metrics is configured")
}
5 changes: 4 additions & 1 deletion internal/client/project/testdata/.skpr/dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ingress:
routes:
- dev.example.com
- dev.example.com

metrics:
enabled: true
6 changes: 6 additions & 0 deletions internal/client/project/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Environment struct {
Backup Backup `yaml:"backup" json:"backup"`
Link map[string]Link `yaml:"link" json:"link"`
Volumes map[string]EnvironmentSpecVolume `yaml:"volumes" json:"volumes"`
Metrics Metrics `yaml:"metrics,omitempty" json:"metrics,omitempty"`
}

// EnvironmentSpecVolume defines Volume configuration for this environemnt.
Expand Down Expand Up @@ -244,3 +245,8 @@ type Link struct {
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Environment string `yaml:"environment,omitempty" json:"environment,omitempty"`
}

// Metrics defines the spec for application metric collection.
type Metrics struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}