Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend skaffold inspect config-dependencies add to support GCB Repo v2 #9349

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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