Skip to content

Commit

Permalink
feat: extend skaffold diagnose config-dependencies add to support G…
Browse files Browse the repository at this point in the history
…CB Repo v2
  • Loading branch information
renzodavid9 committed Mar 19, 2024
1 parent eeaf001 commit 1a88dae
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
32 changes: 27 additions & 5 deletions pkg/skaffold/inspect/configDependencies/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ type configDependencyList struct {
}

type configDependencyEntry struct {
Names []string `json:"configs,omitempty"`
Path string `json:"path,omitempty"`
Git *git `json:"git,omitempty"`
GoogleCloudStorage *googleCloudStorage `json:"googleCloudStorage,omitempty"`
ActiveProfiles []activeProfile `json:"activeProfiles,omitempty"`
Names []string `json:"configs,omitempty"`
Path string `json:"path,omitempty"`
Git *git `json:"git,omitempty"`
GoogleCloudStorage *googleCloudStorage `json:"googleCloudStorage,omitempty"`
GoogleCloudBuildRepoV2 *googleCloudBuildRepoV2 `json:"googleCloudBuildRepoV2,omitempty"`
ActiveProfiles []activeProfile `json:"activeProfiles,omitempty"`
}

type git struct {
Expand All @@ -53,6 +54,16 @@ type googleCloudStorage struct {
Sync bool `json:"sync,omitempty"`
}

type googleCloudBuildRepoV2 struct {
ProjectID string `json:"projectID"`
Region string `json:"region"`
Connection string `json:"connection"`
Repo string `json:"repo"`
Path string `json:"path,omitempty"`
Ref string `json:"ref,omitempty"`
Sync bool `json:"sync,omitempty"`
}

type activeProfile struct {
Name string `json:"name"`
ActivatedBy []string `json:"activatedBy,omitempty"`
Expand Down Expand Up @@ -118,6 +129,17 @@ func convertToLatestConfigDependencies(cfgDepList configDependencyList) []latest
Sync: &d.GoogleCloudStorage.Sync,
}
}
if d.GoogleCloudBuildRepoV2 != nil {
cd.GoogleCloudBuildRepoV2 = &latest.GoogleCloudBuildRepoV2Info{
ProjectID: d.GoogleCloudBuildRepoV2.ProjectID,
Region: d.GoogleCloudBuildRepoV2.Region,
Connection: d.GoogleCloudBuildRepoV2.Connection,
Repo: d.GoogleCloudBuildRepoV2.Repo,
Path: d.GoogleCloudBuildRepoV2.Path,
Ref: d.GoogleCloudBuildRepoV2.Ref,
Sync: &d.GoogleCloudBuildRepoV2.Sync,
}
}
var profileDep []latest.ProfileDependency
for _, ap := range d.ActiveProfiles {
profileDep = append(profileDep, latest.ProfileDependency{
Expand Down
51 changes: 51 additions & 0 deletions pkg/skaffold/inspect/configDependencies/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,57 @@ apiVersion: %s
kind: Config
metadata:
name: cfg1_1
`, apiVersion, apiVersion),
},
{
description: "adds GoogleCloudBuildRepoV2 remote config dependency",
config: fmt.Sprintf(`apiVersion: %s
kind: Config
metadata:
name: cfg1
---
apiVersion: %s
kind: Config
metadata:
name: cfg2
`, apiVersion, apiVersion),
input: `
{
"dependencies": [
{
"configs": ["c1"],
"googleCloudBuildRepoV2": {
"projectID": "k8s-skaffold",
"region": "us-central1",
"connection": "github-connection-e2e-tests",
"repo": "skaffold-getting-started",
"path": "skaffold.yaml",
"ref": "main"
}
}
]
}`,
modules: []string{"cfg1"},
expected: fmt.Sprintf(`apiVersion: %s
kind: Config
metadata:
name: cfg1
requires:
- configs:
- c1
googleCloudBuildRepoV2:
projectID: k8s-skaffold
region: us-central1
connection: github-connection-e2e-tests
repo: skaffold-getting-started
path: skaffold.yaml
ref: main
sync: false
---
apiVersion: %s
kind: Config
metadata:
name: cfg2
`, apiVersion, apiVersion),
},
{
Expand Down

0 comments on commit 1a88dae

Please sign in to comment.