Repository: lima-vm/lima
Pull request #798 (2022-04-15 06:12:16)

CI: update actions


Patch:
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 4f972e14..ca097d05 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -7,3 +7,10 @@ updates:
   open-pull-requests-limit: 10
   reviewers:
   - AkihiroSuda
+- package-ecosystem: github-actions
+  directory: "/"
+  schedule:
+    interval: daily
+  open-pull-requests-limit: 10
+  reviewers:
+  - AkihiroSuda
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4382bd76..0c71fef4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -15,16 +15,16 @@ jobs:
     runs-on: macos-11
     timeout-minutes: 20
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 1
     - name: Make darwin artifacts
       run: make artifacts-darwin
     - name: "Upload artifacts"
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: artifacts-darwin
         path: _artifacts/
@@ -33,12 +33,12 @@ jobs:
     needs: artifacts-darwin
     timeout-minutes: 20
     steps:
-    - uses: actions/checkout@v2
-    - uses: actions/download-artifact@v2
+    - uses: actions/checkout@v3
+    - uses: actions/download-artifact@v3
       with:
         name: artifacts-darwin
         path: _artifacts/
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
     - name: Install gcc-aarch64-linux-gnu
diff --git a/examples/default.yaml b/examples/default.yaml
index 86695c77..6050f9cc 100644
--- a/examples/default.yaml
+++ b/examples/default.yaml
@@ -105,27 +105,6 @@ ssh:
 # ADVANCED CONFIGURATION
 # ===================================================================== #
 
-caCerts:
-  # If set to `true`, this will remove all the default trusted CA certificates that
-  # are normally shipped with the OS.
-  # 🟢 Builtin default: false
-  removeDefaults: null
-
-  # A list of trusted CA certificate files. The files will be read and passed to cloud-init.
-  files:
-  # - examples/hello.crt
-
-  # A list of trusted CA certificates. These are directly passed to cloud-init.
-  certs:
-  # - |
-  #   -----BEGIN CERTIFICATE-----
-  #   YOUR-ORGS-TRUSTED-CA-CERT-HERE
-  #   -----END CERTIFICATE-----
-  # - |
-  #   -----BEGIN CERTIFICATE-----
-  #   YOUR-ORGS-TRUSTED-CA-CERT-HERE
-  #   -----END CERTIFICATE-----
-
 containerd:
   # Enable system-wide (aka rootful)  containerd and its dependencies (BuildKit, Stargz Snapshotter)
   # 🟢 Builtin default: false
diff --git a/pkg/cidata/cidata.TEMPLATE.d/user-data b/pkg/cidata/cidata.TEMPLATE.d/user-data
index 7b8005d6..ec34349f 100644
--- a/pkg/cidata/cidata.TEMPLATE.d/user-data
+++ b/pkg/cidata/cidata.TEMPLATE.d/user-data
@@ -52,15 +52,3 @@ resolv_conf:
   - {{$ns}}
   {{- end }}
 {{- end }}
-
-{{ with .CACerts }}
-ca-certs:
-  remove_defaults: {{ .RemoveDefaults }}
-  trusted:
-  {{- range $cert := .Trusted }}
-  - |
-    {{- range $line := $cert.Lines }}
-    {{ $line }}
-    {{- end }}
-  {{- end }}
-{{- end }}
diff --git a/pkg/cidata/cidata.go b/pkg/cidata/cidata.go
index 2ed805aa..947ad957 100644
--- a/pkg/cidata/cidata.go
+++ b/pkg/cidata/cidata.go
@@ -186,28 +186,6 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
 		}
 	}
 
-	args.CACerts.RemoveDefaults = y.CACertificates.RemoveDefaults
-
-	for _, path := range y.CACertificates.Files {
-		expanded, err := localpathutil.Expand(path)
-		if err != nil {
-			return err
-		}
-
-		content, err := os.ReadFile(expanded)
-		if err != nil {
-			return err
-		}
-
-		cert := getCert(string(content))
-		args.CACerts.Trusted = append(args.CACerts.Trusted, cert)
-	}
-
-	for _, content := range y.CACertificates.Certs {
-		cert := getCert(content)
-		args.CACerts.Trusted = append(args.CACerts.Trusted, cert)
-	}
-
 	if err := ValidateTemplateArgs(args); err != nil {
 		return err
 	}
@@ -266,15 +244,3 @@ func GuestAgentBinary(arch string) (io.ReadCloser, error) {
 	gaPath := filepath.Join(dir, "lima-guestagent.Linux-"+arch)
 	return os.Open(gaPath)
 }
-
-func getCert(content string) Cert {
-	lines := []string{}
-	for _, line := range strings.Split(content, "\n") {
-		if line == "" {
-			continue
-		}
-		lines = append(lines, strings.TrimSpace(line))
-	}
-	// return lines
-	return Cert{Lines: lines}
-}
diff --git a/pkg/cidata/template.go b/pkg/cidata/template.go
index ac95a126..a2e77029 100644
--- a/pkg/cidata/template.go
+++ b/pkg/cidata/template.go
@@ -19,15 +19,6 @@ var templateFS embed.FS
 
 const templateFSRoot = "cidata.TEMPLATE.d"
 
-type CACerts struct {
-	RemoveDefaults *bool
-	Trusted        []Cert
-}
-
-type Cert struct {
-	Lines []string
-}
-
 type Containerd struct {
 	System bool
 	User   bool
@@ -60,7 +51,6 @@ type TemplateArgs struct {
 	TCPDNSLocalPort int
 	Env             map[string]string
 	DNSAddresses    []string
-	CACerts         CACerts
 }
 
 func ValidateTemplateArgs(args TemplateArgs) error {
diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go
index 0e4867dd..9abbe10d 100644
--- a/pkg/limayaml/defaults.go
+++ b/pkg/limayaml/defaults.go
@@ -73,7 +73,6 @@ func MACAddress(uniqueID string) string {
 // - Mounts are appended in d, y, o order, but "merged" when the Location matches a previous entry;
 //   the highest priority Writable setting wins.
 // - DNS are picked from the highest priority where DNS is not empty.
-// - CACertificates Files and Certs are uniquely appended
 func FillDefault(y, d, o *LimaYAML, filePath string) {
 	if y.Arch == nil {
 		y.Arch = d.Arch
@@ -456,22 +455,6 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
 		env[k] = v
 	}
 	y.Env = env
-
-	if y.CACertificates.RemoveDefaults == nil {
-		y.CACertificates.RemoveDefaults = d.CACertificates.RemoveDefaults
-	}
-	if o.CACertificates.RemoveDefaults != nil {
-		y.CACertificates.RemoveDefaults = o.CACertificates.RemoveDefaults
-	}
-	if y.CACertificates.RemoveDefaults == nil {
-		y.CACertificates.RemoveDefaults = pointer.Bool(false)
-	}
-
-	caFiles := unique(append(append(d.CACertificates.Files, y.CACertificates.Files...), o.CACertificates.Files...))
-	y.CACertificates.Files = caFiles
-
-	caCerts := unique(append(append(d.CACertificates.Certs, y.CACertificates.Certs...), o.CACertificates.Certs...))
-	y.CACertificates.Certs = caCerts
 }
 
 func FillPortForwardDefaults(rule *PortForward, instDir string) {
@@ -583,15 +566,3 @@ func Cname(host string) string {
 	}
 	return host
 }
-
-func unique(s []string) []string {
-	keys := make(map[string]bool)
-	list := []string{}
-	for _, entry := range s {
-		if _, found := keys[entry]; !found {
-			keys[entry] = true
-			list = append(list, entry)
-		}
-	}
-	return list
-}
diff --git a/pkg/limayaml/limayaml.go b/pkg/limayaml/limayaml.go
index 013000d7..67236c2d 100644
--- a/pkg/limayaml/limayaml.go
+++ b/pkg/limayaml/limayaml.go
@@ -30,7 +30,6 @@ type LimaYAML struct {
 	HostResolver      HostResolver      `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
 	UseHostResolver   *bool             `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
 	PropagateProxyEnv *bool             `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
-	CACertificates    CACertificates    `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
 }
 
 type Arch = string
@@ -156,12 +155,6 @@ type HostResolver struct {
 	Hosts   map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty"`
 }
 
-type CACertificates struct {
-	RemoveDefaults *bool    `yaml:"removeDefaults,omitempty" json:"removeDefaults,omitempty"` // default: false
-	Files          []string `yaml:"files,omitempty" json:"files,omitempty"`
-	Certs          []string `yaml:"certs,omitempty" json:"certs,omitempty"`
-}
-
 // DEPRECATED types below
 
 // Types have been renamed to turn all references to the old names into compiler errors,


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 9184e4bd..2aab9bb0 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,16 +13,16 @@ jobs:
     runs-on: ubuntu-20.04
     timeout-minutes: 30
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 1
     - name: Run golangci-lint
-      uses: golangci/golangci-lint-action@v2
+      uses: golangci/golangci-lint-action@v3
       with:
-        version: v1.45.0
+        version: v1.45.2
         args: --verbose
     - name: Run yamllint
       run: yamllint .
@@ -56,10 +56,10 @@ jobs:
     runs-on: macos-11
     timeout-minutes: 120
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 1
     - name: Unit tests
@@ -88,11 +88,9 @@ jobs:
       run: |
         (
           brew install autoconf automake
-          cd ~
           git clone https://github.com/lima-vm/vde_vmnet
           cd vde_vmnet
           git checkout $VDE_VMNET_VERSION
-          sudo git config --global --add safe.directory /Users/runner/vde_vmnet
           sudo make PREFIX=/opt/vde install
         )
         (
@@ -142,7 +140,7 @@ jobs:
       matrix:
         oldver: ["v0.8.0"]
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
     - uses: actions/checkout@v3
@@ -151,7 +149,7 @@ jobs:
     - name: Install test dependencies
       run: brew install qemu bash coreutils
     - name: Cache ~/Library/Caches/lima/download
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       with:
         path: ~/Library/Caches/lima/download
         key: ${{ runner.os }}-upgrade-${{ matrix.oldver }}
@@ -168,10 +166,10 @@ jobs:
     runs-on: macos-11
     timeout-minutes: 20
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 1
     - name: Make darwin artifacts
@@ -182,14 +180,14 @@ jobs:
     runs-on: ubuntu-20.04
     timeout-minutes: 20
     steps:
-    - uses: actions/setup-go@v2
+    - uses: actions/setup-go@v3
       with:
         go-version: 1.18.x
     - name: Install gcc-aarch64-linux-gnu
       run: |
         sudo apt-get update
         sudo apt-get install -y gcc-aarch64-linux-gnu
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 1
     - name: Make linux artifacts
diff --git a/pkg/limayaml/defaults_test.go b/pkg/limayaml/defaults_test.go
index 8d6e0563..c146e36a 100644
--- a/pkg/limayaml/defaults_test.go
+++ b/pkg/limayaml/defaults_test.go
@@ -76,9 +76,6 @@ func TestFillDefault(t *testing.T) {
 			IPv6:    pointer.Bool(false),
 		},
 		PropagateProxyEnv: pointer.Bool(true),
-		CACertificates: CACertificates{
-			RemoveDefaults: pointer.Bool(false),
-		},
 	}
 	builtin.CPUType[arch] = "host"
 
@@ -129,12 +126,6 @@ func TestFillDefault(t *testing.T) {
 		Env: map[string]string{
 			"ONE": "Eins",
 		},
-		CACertificates: CACertificates{
-			Files: []string{"ca.crt"},
-			Certs: []string{
-				"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
-			},
-		},
 	}
 
 	expect := builtin
@@ -188,14 +179,6 @@ func TestFillDefault(t *testing.T) {
 
 	expect.Env = y.Env
 
-	expect.CACertificates = CACertificates{
-		RemoveDefaults: pointer.Bool(false),
-		Files:          []string{"ca.crt"},
-		Certs: []string{
-			"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
-		},
-	}
-
 	FillDefault(&y, &LimaYAML{}, &LimaYAML{}, filePath)
 	assert.DeepEqual(t, &y, &expect, opts...)
 
@@ -284,12 +267,6 @@ func TestFillDefault(t *testing.T) {
 			"ONE": "one",
 			"TWO": "two",
 		},
-		CACertificates: CACertificates{
-			RemoveDefaults: pointer.Bool(true),
-			Certs: []string{
-				"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
-			},
-		},
 	}
 
 	expect = d
@@ -305,10 +282,6 @@ func TestFillDefault(t *testing.T) {
 		"default.": d.HostResolver.Hosts["default"],
 	}
 	expect.MountType = pointer.String(REVSSHFS)
-	expect.CACertificates.RemoveDefaults = pointer.Bool(true)
-	expect.CACertificates.Certs = []string{
-		"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
-	}
 
 	y = LimaYAML{}
 	FillDefault(&y, &d, &LimaYAML{}, filePath)
@@ -440,9 +413,6 @@ func TestFillDefault(t *testing.T) {
 			"TWO":   "deux",
 			"THREE": "trois",
 		},
-		CACertificates: CACertificates{
-			RemoveDefaults: pointer.Bool(true),
-		},
 	}
 
 	y = filledDefaults
@@ -481,12 +451,6 @@ func TestFillDefault(t *testing.T) {
 	// ONE remains from filledDefaults.Env; the rest are set from o
 	expect.Env["ONE"] = y.Env["ONE"]
 
-	expect.CACertificates.RemoveDefaults = pointer.Bool(true)
-	expect.CACertificates.Files = []string{"ca.crt"}
-	expect.CACertificates.Certs = []string{
-		"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
-	}
-
 	FillDefault(&y, &d, &o, filePath)
 	assert.DeepEqual(t, &y, &expect, opts...)
 }