GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: write func.yaml before remote upload (#4023) · knative/func@265def9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cmd
    • deploy.go
    • deploy_test.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cmd/deploy.go‎

Copy file name to clipboardExpand all lines: cmd/deploy.go
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ func runDeploy(cmd *cobra.Command, newClient ClientFactory) (err error) {
316316

317317
// Deploy
318318
if cfg.Remote {
319+
// Write func.yaml before the pipeline uploads sources to the PVC,
320+
// so that the on-cluster deploy step sees the latest config
321+
// (e.g. --service-account, --deployer).
322+
if err = f.Write(); err != nil {
323+
return
324+
}
319325
var url string
320326
// Invoke a remote build/push/deploy pipeline
321327
// Returned is the function with fields like Registry, f.Deploy.Image &
Collapse file

‎cmd/deploy_test.go‎

Copy file name to clipboardExpand all lines: cmd/deploy_test.go
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,50 @@ func TestDeploy_UnsetFlag(t *testing.T) {
18311831
}
18321832
}
18331833

1834+
// TestDeploy_DeployerRemote ensures that when deploying remotely,
1835+
// func.yaml is written to disk before the pipeline starts, so the on-cluster
1836+
// deploy step picks up the --deployer value.
1837+
func TestDeploy_DeployerRemote(t *testing.T) {
1838+
root := FromTempDirectory(t)
1839+
1840+
f := fn.Function{Runtime: "go", Root: root, Registry: TestRegistry}
1841+
_, err := fn.New().Init(f)
1842+
if err != nil {
1843+
t.Fatal(err)
1844+
}
1845+
1846+
pipelinesProvider := mock.NewPipelinesProvider()
1847+
pipelinesProvider.RunFn = func(f fn.Function) (string, fn.Function, error) {
1848+
// Inside the pipeline Run, func.yaml on disk should already
1849+
// have the deployer written.
1850+
diskFn, err := fn.NewFunction(root)
1851+
if err != nil {
1852+
t.Fatalf("failed to load func.yaml during pipeline Run: %v", err)
1853+
}
1854+
if diskFn.Deploy.Deployer != "keda" {
1855+
t.Fatalf("expected func.yaml on disk to have deployer 'keda', got '%v'", diskFn.Deploy.Deployer)
1856+
}
1857+
f.Deploy.Namespace = "default"
1858+
if f.Deploy.Image, err = f.ImageName(); err != nil {
1859+
return "", f, err
1860+
}
1861+
return "", f, nil
1862+
}
1863+
1864+
cmd := NewDeployCmd(NewTestClient(
1865+
fn.WithPipelinesProvider(pipelinesProvider),
1866+
fn.WithRegistry(TestRegistry),
1867+
))
1868+
cmd.SetArgs([]string{"--remote", "--deployer=keda", "--namespace=default"})
1869+
if err := cmd.Execute(); err != nil {
1870+
t.Fatal(err)
1871+
}
1872+
1873+
if !pipelinesProvider.RunInvoked {
1874+
t.Fatal("expected pipeline Run to be invoked")
1875+
}
1876+
}
1877+
18341878
// Test_ValidateBuilder tests that the builder validation accepts the
18351879
// set of known builders, and spot-checks an error is thrown for unknown.
18361880
func Test_ValidateBuilder(t *testing.T) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.