Skip to content

Commit 56d72f2

Browse files
Fn cli multi arch (#656)
* support for architectures types in application create and deploy * fixing --local flag for deploy * testing with local fnserver image * fixing bug introduced by reading response body before processing * updating oci sdk for arch param inclusion * adding arm64 lib build * shape type support and shape in function inspect * updating go version in dockerfile * using default builder instance for supported platforms for single arch * updating oci sdk * optimizing deploy * updating fn_go to public version * adding release to linux arm64 code --------- Co-authored-by: Vishal Maurya <[email protected]>
1 parent adccd07 commit 56d72f2

File tree

532 files changed

+36604
-6965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

532 files changed

+36604
-6965
lines changed

.circleci/config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- GO111MODULE=on
99
- GOFLAGS=-mod=vendor
1010
- GOPATH=/home/circleci/go
11-
- GOVERSION=1.16.3
11+
- GOVERSION=1.17
1212
- OS=linux
1313
- ARCH=amd64
1414
steps:
@@ -35,6 +35,12 @@ jobs:
3535
command: make test
3636
no_output_timeout: 20m
3737
environment:
38+
- run:
39+
name: test build linux arm64
40+
command: go build -o fn_linux_arm64
41+
environment:
42+
GOOS: linux
43+
GOARCH: arm64
3844
- run:
3945
name: test build macos
4046
command: go build -o fn_mac

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
# build stage
18-
FROM golang:1.16.3-alpine3.12 AS build-env
18+
FROM golang:1.17.0-alpine3.14 AS build-env
1919
RUN apk add --no-cache gcc musl-dev
2020
ARG D=/go/src/github.com/fnproject/cli
2121
ARG GO111MODULE=on
@@ -24,7 +24,7 @@ ADD . $D
2424
RUN cd $D && go build -o fn-alpine && cp fn-alpine /tmp/
2525

2626
# final stage
27-
FROM alpine:3.12
27+
FROM alpine:3.14
2828
RUN apk add --no-cache ca-certificates curl
2929
WORKDIR /app
3030
COPY --from=build-env /tmp/fn-alpine /app/fn

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11

22
# Releases
33

4+
## v 0.6.25
5+
6+
* Support for multiple shapes(architectures) functions images:
7+
* x86 (default)
8+
* arm
9+
* multiarch (x86, arm)
10+
11+
* cli now is supported on `Arm Linux` as well.
12+
13+
414
## v 0.6.24
515

616
* Allowing `fn inspect functions` and `fn list functions` for PBF(Pre-Built Functions) function with empty image and digest field. By default, it was not supported.

THIRD_PARTY_LICENSES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The following dependencies of fn-cli are licensed under Apache 2.0 license
105105

106106
github.com/coreos/go-semver/semver
107107
github.com/golang/mock/gomock
108-
github.com/oracle/oci-go-sdk/v48
108+
github.com/oracle/oci-go-sdk/v65
109109
github.com/go-openapi/validate
110110
github.com/xeipuuv/gojsonpointer
111111
github.com/go-openapi/loads
@@ -1880,7 +1880,7 @@ Google Inc.
18801880
-----------------------------------------------------------------
18811881
The following dependency of fn-cli is licensed under Apache License 2.0
18821882

1883-
github.com/oracle/oci-go-sdk/v48
1883+
github.com/oracle/oci-go-sdk/v65
18841884

18851885
Apache License 2.0 : A copy of the Apache License V2.0 is included in this file.
18861886

commands/build.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ package commands
1818

1919
import (
2020
"fmt"
21-
"os"
22-
"path/filepath"
23-
2421
"github.com/fnproject/cli/common"
2522
"github.com/urfave/cli"
23+
"os"
24+
"path/filepath"
2625
)
2726

2827
// BuildCommand returns build cli.command
@@ -97,7 +96,9 @@ func (b *buildcmd) build(c *cli.Context) error {
9796
}
9897

9998
buildArgs := c.StringSlice("build-arg")
100-
ff, err = common.BuildFuncV20180708(common.IsVerbose(), fpath, ff, buildArgs, b.noCache)
99+
100+
// Passing empty shape for build command
101+
ff, err = common.BuildFuncV20180708(common.IsVerbose(), fpath, ff, buildArgs, b.noCache, "")
101102
if err != nil {
102103
return err
103104
}

commands/build_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (b *BuildServerCmd) buildServer(c *cli.Context) error {
117117
if err != nil {
118118
return err
119119
}
120-
err = common.RunBuild(common.IsVerbose(), dir, c.String("tag"), "Dockerfile", nil, b.noCache, containerEngineType)
120+
err = common.RunBuild(common.IsVerbose(), dir, c.String("tag"), "Dockerfile", nil, b.noCache, containerEngineType, "")
121121
if err != nil {
122122
return err
123123
}

commands/deploy.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ import (
3939
trigger "github.com/fnproject/cli/objects/trigger"
4040
v2Client "github.com/fnproject/fn_go/clientv2"
4141
models "github.com/fnproject/fn_go/modelsv2"
42-
"github.com/oracle/oci-go-sdk/v48/artifacts"
43-
ociCommon "github.com/oracle/oci-go-sdk/v48/common"
44-
"github.com/oracle/oci-go-sdk/v48/keymanagement"
42+
"github.com/oracle/oci-go-sdk/v65/artifacts"
43+
ociCommon "github.com/oracle/oci-go-sdk/v65/common"
44+
"github.com/oracle/oci-go-sdk/v65/keymanagement"
4545
"github.com/urfave/cli"
4646
)
4747

@@ -58,7 +58,6 @@ type Message struct {
5858
}
5959

6060
var RegionsWithOldKMSEndpoints = map[ociCommon.Region]struct{}{
61-
ociCommon.RegionSEA: {},
6261
ociCommon.RegionPHX: {},
6362
ociCommon.RegionIAD: {},
6463
ociCommon.RegionFRA: {},
@@ -184,6 +183,7 @@ func (p *deploycmd) flags() []cli.Flag {
184183
// on the file system (can be overridden using the `path` arg in each `func.yaml`. The index/root function
185184
// is the one that lives in the same directory as the app.yaml.
186185
func (p *deploycmd) deploy(c *cli.Context) error {
186+
187187
appName := ""
188188
dir := common.GetDir(c)
189189

@@ -384,21 +384,30 @@ func (p *deploycmd) deployFuncV20180708(c *cli.Context, app *models.App, funcfil
384384
}
385385

386386
buildArgs := c.StringSlice("build-arg")
387-
_, err := common.BuildFuncV20180708(common.IsVerbose(), funcfilePath, funcfile, buildArgs, p.noCache)
388-
if err != nil {
389-
return err
390-
}
391387

388+
// In case of local ignore the architectures parameter
389+
shape := ""
392390
if !p.local {
393-
if err := common.PushV20180708(funcfile); err != nil {
394-
return err
391+
// fetch the architectures
392+
shape = app.Shape
393+
if shape == "" {
394+
shape = common.DefaultAppShape
395+
app.Shape = shape
396+
}
397+
398+
if _, ok := common.ShapeMap[shape]; !ok {
399+
return errors.New(fmt.Sprintf("Invalid application : %s shape: %s", app.Name, shape))
395400
}
396401
}
397402

398-
if err := p.signImage(funcfile); err != nil {
403+
_, err := common.BuildFuncV20180708(common.IsVerbose(), funcfilePath, funcfile, buildArgs, p.noCache, shape)
404+
if err != nil {
399405
return err
400406
}
401407

408+
if err := p.signImage(funcfile); err != nil {
409+
return err
410+
}
402411
return p.updateFunction(c, app.ID, funcfile)
403412
}
404413

commands/image_signature_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/fnproject/cli/common"
88
"github.com/fnproject/cli/config"
99
"github.com/fnproject/fn_go/provider/oracle"
10-
ociCommon "github.com/oracle/oci-go-sdk/v48/common"
10+
ociCommon "github.com/oracle/oci-go-sdk/v65/common"
1111
"github.com/spf13/viper"
1212
"net/url"
1313
"testing"

commands/invoke_others.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows
12
// +build !windows
23

34
package commands

commands/invoke_windows.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build windows
2+
13
/*
24
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
35
*
@@ -13,7 +15,6 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
16-
// +build windows
1718

1819
package commands
1920

commands/start.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ func start(c *cli.Context) error {
9797
}
9898

9999
image := fmt.Sprintf("%s:%s", common.FunctionsDockerImage, c.String("version"))
100-
101100
args = append(args, image)
102101
cmd := exec.Command("docker", args...)
103102
cmd.Stdout = os.Stdout

common/color/windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
package color

0 commit comments

Comments
 (0)