diff --git a/config/external.go b/config/external.go index 9f592fb3..ca98bdfb 100644 --- a/config/external.go +++ b/config/external.go @@ -29,6 +29,10 @@ import ( // whatever programming language you wish, while still remaining compatible // with garm. type External struct { + // InterfaceVersion is the version of the interface that the external + // provider implements. This is used to ensure compatibility between + // the external provider and garm. + InterfaceVersion string `toml:"interface_version" json:"interface-version"` // ConfigFile is the path on disk to a file which will be passed to // the external binary as an environment variable: GARM_PROVIDER_CONFIG // You can use this file for any configuration you need to do for the diff --git a/go.mod b/go.mod index 4057e225..e13a7fea 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.3 require ( github.com/BurntSushi/toml v1.3.2 github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 - github.com/cloudbase/garm-provider-common v0.1.3 + github.com/cloudbase/garm-provider-common v0.1.4-0.20240821093055-dfdf8e2e4853 github.com/felixge/httpsnoop v1.0.4 github.com/go-openapi/errors v0.22.0 github.com/go-openapi/runtime v0.28.0 @@ -28,7 +28,7 @@ require ( github.com/prometheus/client_golang v1.19.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 - golang.org/x/crypto v0.25.0 + golang.org/x/crypto v0.26.0 golang.org/x/oauth2 v0.19.0 golang.org/x/sync v0.7.0 gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 @@ -85,8 +85,8 @@ require ( go.opentelemetry.io/otel v1.25.0 // indirect go.opentelemetry.io/otel/metric v1.25.0 // indirect go.opentelemetry.io/otel/trace v1.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f4939954..338c248a 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cloudbase/garm-provider-common v0.1.3 h1:8pHSRs2ljwLHgtDrge68dZ7ILUW97VF5h2ZA2fQubGQ= -github.com/cloudbase/garm-provider-common v0.1.3/go.mod h1:VIJzbcg5iwyD4ac99tnnwcActfwibn/VOt2MYOFjf2c= +github.com/cloudbase/garm-provider-common v0.1.4-0.20240821093055-dfdf8e2e4853 h1:eaWT9rcqYheM1IMQtHQJNKLwSQfVKhj6veX221rDkIU= +github.com/cloudbase/garm-provider-common v0.1.4-0.20240821093055-dfdf8e2e4853/go.mod h1:/N8rXH2iXCsqCcOODsI2DTR9afnijMhNp/vjR9wbzSg= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -180,10 +180,10 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= @@ -191,10 +191,10 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/runner/common/mocks/Provider.go b/runner/common/mocks/Provider.go index 1390d972..92dece39 100644 --- a/runner/common/mocks/Provider.go +++ b/runner/common/mocks/Provider.go @@ -9,6 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" params "github.com/cloudbase/garm/params" + "github.com/cloudbase/garm/runner/common" ) // Provider is an autogenerated mock type for the Provider type @@ -35,7 +36,7 @@ func (_m *Provider) AsParams() params.Provider { } // CreateInstance provides a mock function with given fields: ctx, bootstrapParams -func (_m *Provider) CreateInstance(ctx context.Context, bootstrapParams garm_provider_commonparams.BootstrapInstance) (garm_provider_commonparams.ProviderInstance, error) { +func (_m *Provider) CreateInstance(ctx context.Context, bootstrapParams garm_provider_commonparams.BootstrapInstance, createInstanceParams common.CreateInstanceParams) (garm_provider_commonparams.ProviderInstance, error) { ret := _m.Called(ctx, bootstrapParams) if len(ret) == 0 { @@ -63,7 +64,7 @@ func (_m *Provider) CreateInstance(ctx context.Context, bootstrapParams garm_pro } // DeleteInstance provides a mock function with given fields: ctx, instance -func (_m *Provider) DeleteInstance(ctx context.Context, instance string) error { +func (_m *Provider) DeleteInstance(ctx context.Context, instance string, deleteInstanceParams common.DeleteInstanceParams) error { ret := _m.Called(ctx, instance) if len(ret) == 0 { @@ -99,7 +100,7 @@ func (_m *Provider) DisableJITConfig() bool { } // GetInstance provides a mock function with given fields: ctx, instance -func (_m *Provider) GetInstance(ctx context.Context, instance string) (garm_provider_commonparams.ProviderInstance, error) { +func (_m *Provider) GetInstance(ctx context.Context, instance string, getInstanceParams common.GetInstanceParams) (garm_provider_commonparams.ProviderInstance, error) { ret := _m.Called(ctx, instance) if len(ret) == 0 { @@ -127,7 +128,7 @@ func (_m *Provider) GetInstance(ctx context.Context, instance string) (garm_prov } // ListInstances provides a mock function with given fields: ctx, poolID -func (_m *Provider) ListInstances(ctx context.Context, poolID string) ([]garm_provider_commonparams.ProviderInstance, error) { +func (_m *Provider) ListInstances(ctx context.Context, poolID string, listInstancesParams common.ListInstancesParams) ([]garm_provider_commonparams.ProviderInstance, error) { ret := _m.Called(ctx, poolID) if len(ret) == 0 { @@ -157,7 +158,7 @@ func (_m *Provider) ListInstances(ctx context.Context, poolID string) ([]garm_pr } // RemoveAllInstances provides a mock function with given fields: ctx -func (_m *Provider) RemoveAllInstances(ctx context.Context) error { +func (_m *Provider) RemoveAllInstances(ctx context.Context, removeAllInstances common.RemoveAllInstancesParams) error { ret := _m.Called(ctx) if len(ret) == 0 { @@ -175,7 +176,7 @@ func (_m *Provider) RemoveAllInstances(ctx context.Context) error { } // Start provides a mock function with given fields: ctx, instance -func (_m *Provider) Start(ctx context.Context, instance string) error { +func (_m *Provider) Start(ctx context.Context, instance string, startParams common.StartParams) error { ret := _m.Called(ctx, instance) if len(ret) == 0 { @@ -193,7 +194,7 @@ func (_m *Provider) Start(ctx context.Context, instance string) error { } // Stop provides a mock function with given fields: ctx, instance -func (_m *Provider) Stop(ctx context.Context, instance string) error { +func (_m *Provider) Stop(ctx context.Context, instance string, stopParams common.StopParams) error { ret := _m.Called(ctx, instance) if len(ret) == 0 { diff --git a/runner/common/params.go b/runner/common/params.go new file mode 100644 index 00000000..fdf73dbc --- /dev/null +++ b/runner/common/params.go @@ -0,0 +1,88 @@ +// Copyright 2022 Cloudbase Solutions SRL +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package common + +import "github.com/cloudbase/garm/params" + +// Constants used for the provider interface version. +const ( + Version010 = "v0.1.0" + Version011 = "v0.1.1" +) + +// Each struct is a wrapper for the actual parameters struct for a specific version. +// Version 0.1.0 doesn't have any specific parameters, so there is no need for a struct for it. +type CreateInstanceParams struct { + CreateInstanceV011 CreateInstanceV011Params +} + +type DeleteInstanceParams struct { + DeleteInstanceV011 DeleteInstanceV011Params +} + +type GetInstanceParams struct { + GetInstanceV011 GetInstanceV011Params +} + +type ListInstancesParams struct { + ListInstancesV011 ListInstancesV011Params +} + +type RemoveAllInstancesParams struct { + RemoveAllInstancesV011 RemoveAllInstancesV011Params +} + +type StopParams struct { + StopV011 StopV011Params +} + +type StartParams struct { + StartV011 StartV011Params +} + +// Struct for the base provider parameters. +type ProviderBaseParams struct { + PoolInfo params.Pool + ControllerInfo params.ControllerInfo +} + +// Structs for version v0.1.1. +type CreateInstanceV011Params struct { + ProviderBaseParams +} + +type DeleteInstanceV011Params struct { + ProviderBaseParams +} + +type GetInstanceV011Params struct { + ProviderBaseParams +} + +type ListInstancesV011Params struct { + ProviderBaseParams +} + +type RemoveAllInstancesV011Params struct { + ProviderBaseParams +} + +type StopV011Params struct { + ProviderBaseParams +} + +type StartV011Params struct { + ProviderBaseParams +} diff --git a/runner/common/provider.go b/runner/common/provider.go index 8ed98e0c..7454540f 100644 --- a/runner/common/provider.go +++ b/runner/common/provider.go @@ -24,19 +24,19 @@ import ( //go:generate mockery --all type Provider interface { // CreateInstance creates a new compute instance in the provider. - CreateInstance(ctx context.Context, bootstrapParams commonParams.BootstrapInstance) (commonParams.ProviderInstance, error) + CreateInstance(ctx context.Context, bootstrapParams commonParams.BootstrapInstance, createInstanceParams CreateInstanceParams) (commonParams.ProviderInstance, error) // Delete instance will delete the instance in a provider. - DeleteInstance(ctx context.Context, instance string) error + DeleteInstance(ctx context.Context, instance string, deleteInstanceParams DeleteInstanceParams) error // GetInstance will return details about one instance. - GetInstance(ctx context.Context, instance string) (commonParams.ProviderInstance, error) + GetInstance(ctx context.Context, instance string, getInstanceParams GetInstanceParams) (commonParams.ProviderInstance, error) // ListInstances will list all instances for a provider. - ListInstances(ctx context.Context, poolID string) ([]commonParams.ProviderInstance, error) + ListInstances(ctx context.Context, poolID string, listInstancesParams ListInstancesParams) ([]commonParams.ProviderInstance, error) // RemoveAllInstances will remove all instances created by this provider. - RemoveAllInstances(ctx context.Context) error + RemoveAllInstances(ctx context.Context, removeAllInstancesParams RemoveAllInstancesParams) error // Stop shuts down the instance. - Stop(ctx context.Context, instance string) error + Stop(ctx context.Context, instance string, stopParams StopParams) error // Start boots up an instance. - Start(ctx context.Context, instance string) error + Start(ctx context.Context, instance string, startParams StartParams) error // DisableJITConfig tells us if the provider explicitly disables JIT configuration and // forces runner registration tokens to be used. This may happen if a provider has not yet // been updated to support JIT configuration. diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 09383e34..4d317dd9 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -130,6 +130,16 @@ type basePoolManager struct { keyMux *keyMutex } +func (r *basePoolManager) getProviderBaseParams(pool params.Pool) common.ProviderBaseParams { + r.mux.Lock() + defer r.mux.Unlock() + + return common.ProviderBaseParams{ + PoolInfo: pool, + ControllerInfo: r.controllerInfo, + } +} + func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error { if err := r.ValidateOwner(job); err != nil { return errors.Wrap(err, "validating owner") @@ -589,7 +599,12 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner) slog.DebugContext( r.ctx, "updating instances cache for pool", "pool_id", pool.ID) - poolInstances, err = provider.ListInstances(r.ctx, pool.ID) + listInstancesParams := common.ListInstancesParams{ + ListInstancesV011: common.ListInstancesV011Params{ + ProviderBaseParams: r.getProviderBaseParams(pool), + }, + } + poolInstances, err = provider.ListInstances(r.ctx, pool.ID, listInstancesParams) if err != nil { return errors.Wrapf(err, "fetching instances for pool %s", pool.ID) } @@ -654,7 +669,12 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner) r.ctx, "instance was found in stopped state; starting", "runner_name", dbInstance.Name) - if err := provider.Start(r.ctx, dbInstance.ProviderID); err != nil { + startParams := common.StartParams{ + StartV011: common.StartV011Params{ + ProviderBaseParams: r.getProviderBaseParams(pool), + }, + } + if err := provider.Start(r.ctx, dbInstance.ProviderID, startParams); err != nil { return errors.Wrapf(err, "starting instance %s", dbInstance.ProviderID) } return nil @@ -870,7 +890,12 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error defer func() { if instanceIDToDelete != "" { - if err := provider.DeleteInstance(r.ctx, instanceIDToDelete); err != nil { + deleteInstanceParams := common.DeleteInstanceParams{ + DeleteInstanceV011: common.DeleteInstanceV011Params{ + ProviderBaseParams: r.getProviderBaseParams(pool), + }, + } + if err := provider.DeleteInstance(r.ctx, instanceIDToDelete, deleteInstanceParams); err != nil { if !errors.Is(err, runnerErrors.ErrNotFound) { slog.With(slog.Any("error", err)).ErrorContext( r.ctx, "failed to cleanup instance", @@ -880,7 +905,12 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error } }() - providerInstance, err := provider.CreateInstance(r.ctx, bootstrapArgs) + createInstanceParams := common.CreateInstanceParams{ + CreateInstanceV011: common.CreateInstanceV011Params{ + ProviderBaseParams: r.getProviderBaseParams(pool), + }, + } + providerInstance, err := provider.CreateInstance(r.ctx, bootstrapArgs, createInstanceParams) if err != nil { instanceIDToDelete = instance.Name return errors.Wrap(err, "creating instance") @@ -1316,7 +1346,12 @@ func (r *basePoolManager) deleteInstanceFromProvider(ctx context.Context, instan "runner_name", instance.Name, "provider_id", identifier) - if err := provider.DeleteInstance(ctx, identifier); err != nil { + deleteInstanceParams := common.DeleteInstanceParams{ + DeleteInstanceV011: common.DeleteInstanceV011Params{ + ProviderBaseParams: r.getProviderBaseParams(pool), + }, + } + if err := provider.DeleteInstance(ctx, identifier, deleteInstanceParams); err != nil { return errors.Wrap(err, "removing instance") } diff --git a/runner/providers/common/common.go b/runner/providers/common/common.go new file mode 100644 index 00000000..4e49e080 --- /dev/null +++ b/runner/providers/common/common.go @@ -0,0 +1,23 @@ +package common + +import ( + garmErrors "github.com/cloudbase/garm-provider-common/errors" + commonParams "github.com/cloudbase/garm-provider-common/params" + "github.com/cloudbase/garm/runner/providers/util" +) + +func ValidateResult(inst commonParams.ProviderInstance) error { + if inst.ProviderID == "" { + return garmErrors.NewProviderError("missing provider ID") + } + + if inst.Name == "" { + return garmErrors.NewProviderError("missing instance name") + } + + if !util.IsValidProviderStatus(inst.Status) { + return garmErrors.NewProviderError("invalid status returned (%s)", inst.Status) + } + + return nil +} diff --git a/runner/providers/external/external.go b/runner/providers/external/external.go index 446f69a5..23b9b894 100644 --- a/runner/providers/external/external.go +++ b/runner/providers/external/external.go @@ -2,334 +2,22 @@ package external import ( "context" - "encoding/json" "fmt" - "log/slog" - "os/exec" - "github.com/pkg/errors" - - garmErrors "github.com/cloudbase/garm-provider-common/errors" - "github.com/cloudbase/garm-provider-common/execution" - commonParams "github.com/cloudbase/garm-provider-common/params" - garmExec "github.com/cloudbase/garm-provider-common/util/exec" "github.com/cloudbase/garm/config" - "github.com/cloudbase/garm/metrics" - "github.com/cloudbase/garm/params" "github.com/cloudbase/garm/runner/common" + v010 "github.com/cloudbase/garm/runner/providers/v0.1.0" + v011 "github.com/cloudbase/garm/runner/providers/v0.1.1" ) -var _ common.Provider = (*external)(nil) - +// NewProvider selects the provider based on the interface version func NewProvider(ctx context.Context, cfg *config.Provider, controllerID string) (common.Provider, error) { - if cfg.ProviderType != params.ExternalProvider { - return nil, garmErrors.NewBadRequestError("invalid provider config") - } - - execPath, err := cfg.External.ExecutablePath() - if err != nil { - return nil, errors.Wrap(err, "fetching executable path") - } - - envVars := cfg.External.GetEnvironmentVariables() - - return &external{ - ctx: ctx, - controllerID: controllerID, - cfg: cfg, - execPath: execPath, - environmentVariables: envVars, - }, nil -} - -type external struct { - ctx context.Context - controllerID string - cfg *config.Provider - execPath string - environmentVariables []string -} - -func (e *external) validateResult(inst commonParams.ProviderInstance) error { - if inst.ProviderID == "" { - return garmErrors.NewProviderError("missing provider ID") - } - - if inst.Name == "" { - return garmErrors.NewProviderError("missing instance name") - } - - if !IsValidProviderStatus(inst.Status) { - return garmErrors.NewProviderError("invalid status returned (%s)", inst.Status) - } - - return nil -} - -// CreateInstance creates a new compute instance in the provider. -func (e *external) CreateInstance(ctx context.Context, bootstrapParams commonParams.BootstrapInstance) (commonParams.ProviderInstance, error) { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.CreateInstanceCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_POOL_ID=%s", bootstrapParams.PoolID), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - asJs, err := json.Marshal(bootstrapParams) - if err != nil { - return commonParams.ProviderInstance{}, errors.Wrap(err, "serializing bootstrap params") - } - - metrics.InstanceOperationCount.WithLabelValues( - "CreateInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - - out, err := garmExec.Exec(ctx, e.execPath, asJs, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "CreateInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - - var param commonParams.ProviderInstance - if err := json.Unmarshal(out, ¶m); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "CreateInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) - } - - if err := e.validateResult(param); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "CreateInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) - } - - retAsJs, _ := json.MarshalIndent(param, "", " ") - slog.DebugContext( - ctx, "provider returned", - "output", string(retAsJs)) - return param, nil -} - -// Delete instance will delete the instance in a provider. -func (e *external) DeleteInstance(ctx context.Context, instance string) error { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.DeleteInstanceCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - metrics.InstanceOperationCount.WithLabelValues( - "DeleteInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - var exitErr *exec.ExitError - if !errors.As(err, &exitErr) || exitErr.ExitCode() != execution.ExitCodeNotFound { - metrics.InstanceOperationFailedCount.WithLabelValues( - "DeleteInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - } - return nil -} - -// GetInstance will return details about one instance. -func (e *external) GetInstance(ctx context.Context, instance string) (commonParams.ProviderInstance, error) { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.GetInstanceCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - // nolint:golangci-lint,godox - // TODO(gabriel-samfira): handle error types. Of particular interest is to - // know when the error is ErrNotFound. - metrics.InstanceOperationCount.WithLabelValues( - "GetInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "GetInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - - var param commonParams.ProviderInstance - if err := json.Unmarshal(out, ¶m); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "GetInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) - } - - if err := e.validateResult(param); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "GetInstance", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) - } - - return param, nil -} - -// ListInstances will list all instances for a provider. -func (e *external) ListInstances(ctx context.Context, poolID string) ([]commonParams.ProviderInstance, error) { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.ListInstancesCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_POOL_ID=%s", poolID), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - metrics.InstanceOperationCount.WithLabelValues( - "ListInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - - out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "ListInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - - var param []commonParams.ProviderInstance - if err := json.Unmarshal(out, ¶m); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "ListInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) - } - - ret := make([]commonParams.ProviderInstance, len(param)) - for idx, inst := range param { - if err := e.validateResult(inst); err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "ListInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) - } - ret[idx] = inst - } - return ret, nil -} - -// RemoveAllInstances will remove all instances created by this provider. -func (e *external) RemoveAllInstances(ctx context.Context) error { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.RemoveAllInstancesCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - metrics.InstanceOperationCount.WithLabelValues( - "RemoveAllInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - - _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "RemoveAllInstances", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - return nil -} - -// Stop shuts down the instance. -func (e *external) Stop(ctx context.Context, instance string) error { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.StopInstanceCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - metrics.InstanceOperationCount.WithLabelValues( - "Stop", // label: operation - e.cfg.Name, // label: provider - ).Inc() - _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "Stop", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - return nil -} - -// Start boots up an instance. -func (e *external) Start(ctx context.Context, instance string) error { - asEnv := []string{ - fmt.Sprintf("GARM_COMMAND=%s", execution.StartInstanceCommand), - fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), - fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), - fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), - } - asEnv = append(asEnv, e.environmentVariables...) - - metrics.InstanceOperationCount.WithLabelValues( - "Start", // label: operation - e.cfg.Name, // label: provider - ).Inc() - - _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) - if err != nil { - metrics.InstanceOperationFailedCount.WithLabelValues( - "Start", // label: operation - e.cfg.Name, // label: provider - ).Inc() - return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) - } - return nil -} - -func (e *external) AsParams() params.Provider { - return params.Provider{ - Name: e.cfg.Name, - Description: e.cfg.Description, - ProviderType: e.cfg.ProviderType, - } -} - -// DisableJITConfig tells us if the provider explicitly disables JIT configuration and -// forces runner registration tokens to be used. This may happen if a provider has not yet -// been updated to support JIT configuration. -func (e *external) DisableJITConfig() bool { - if e.cfg == nil { - return false + switch cfg.External.InterfaceVersion { + case common.Version010, "": + return v010.NewProvider(ctx, cfg, controllerID) + case common.Version011: + return v011.NewProvider(ctx, cfg, controllerID) + default: + return nil, fmt.Errorf("unsupported interface version: %s", cfg.External.InterfaceVersion) } - return e.cfg.DisableJITConfig } diff --git a/runner/providers/external/util.go b/runner/providers/util/util.go similarity index 97% rename from runner/providers/external/util.go rename to runner/providers/util/util.go index 460714e9..2948730b 100644 --- a/runner/providers/external/util.go +++ b/runner/providers/util/util.go @@ -1,4 +1,4 @@ -package external +package util import ( commonParams "github.com/cloudbase/garm-provider-common/params" diff --git a/runner/providers/v0.1.0/external.go b/runner/providers/v0.1.0/external.go new file mode 100644 index 00000000..6dd0ef46 --- /dev/null +++ b/runner/providers/v0.1.0/external.go @@ -0,0 +1,326 @@ +package v010 + +import ( + "context" + "encoding/json" + "fmt" + "log/slog" + "os/exec" + + "github.com/pkg/errors" + + garmErrors "github.com/cloudbase/garm-provider-common/errors" + commonExecution "github.com/cloudbase/garm-provider-common/execution/common" + commonParams "github.com/cloudbase/garm-provider-common/params" + garmExec "github.com/cloudbase/garm-provider-common/util/exec" + "github.com/cloudbase/garm/config" + "github.com/cloudbase/garm/metrics" + "github.com/cloudbase/garm/params" + "github.com/cloudbase/garm/runner/common" + commonExternal "github.com/cloudbase/garm/runner/providers/common" +) + +var _ common.Provider = (*external)(nil) + +// NewProvider creates a legacy external provider. +func NewProvider(ctx context.Context, cfg *config.Provider, controllerID string) (common.Provider, error) { + if cfg.ProviderType != params.ExternalProvider { + return nil, garmErrors.NewBadRequestError("invalid provider config") + } + + execPath, err := cfg.External.ExecutablePath() + if err != nil { + return nil, errors.Wrap(err, "fetching executable path") + } + + // Set GARM_INTERFACE_VERSION to the version of the interface that the external + // provider implements. This is used to ensure compatibility between the external + // provider and garm + + envVars := cfg.External.GetEnvironmentVariables() + envVars = append(envVars, fmt.Sprintf("GARM_INTERFACE_VERSION=%s", common.Version010)) + + return &external{ + ctx: ctx, + controllerID: controllerID, + cfg: cfg, + execPath: execPath, + environmentVariables: envVars, + }, nil +} + +type external struct { + ctx context.Context + controllerID string + cfg *config.Provider + execPath string + environmentVariables []string +} + +// CreateInstance creates a new compute instance in the provider. +func (e *external) CreateInstance(ctx context.Context, bootstrapParams commonParams.BootstrapInstance, _ common.CreateInstanceParams) (commonParams.ProviderInstance, error) { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.CreateInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_POOL_ID=%s", bootstrapParams.PoolID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + asJs, err := json.Marshal(bootstrapParams) + if err != nil { + return commonParams.ProviderInstance{}, errors.Wrap(err, "serializing bootstrap params") + } + + metrics.InstanceOperationCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + out, err := garmExec.Exec(ctx, e.execPath, asJs, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + if err := commonExternal.ValidateResult(param); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + + retAsJs, _ := json.MarshalIndent(param, "", " ") + slog.DebugContext( + ctx, "provider returned", + "output", string(retAsJs)) + return param, nil +} + +// Delete instance will delete the instance in a provider. +func (e *external) DeleteInstance(ctx context.Context, instance string, _ common.DeleteInstanceParams) error { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.DeleteInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "DeleteInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + var exitErr *exec.ExitError + if !errors.As(err, &exitErr) || exitErr.ExitCode() != commonExecution.ExitCodeNotFound { + metrics.InstanceOperationFailedCount.WithLabelValues( + "DeleteInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + } + return nil +} + +// GetInstance will return details about one instance. +func (e *external) GetInstance(ctx context.Context, instance string, _ common.GetInstanceParams) (commonParams.ProviderInstance, error) { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.GetInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + // nolint:golangci-lint,godox + // TODO(gabriel-samfira): handle error types. Of particular interest is to + // know when the error is ErrNotFound. + metrics.InstanceOperationCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + if err := commonExternal.ValidateResult(param); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + + return param, nil +} + +// ListInstances will list all instances for a provider. +func (e *external) ListInstances(ctx context.Context, poolID string, _ common.ListInstancesParams) ([]commonParams.ProviderInstance, error) { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.ListInstancesCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_POOL_ID=%s", poolID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param []commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + ret := make([]commonParams.ProviderInstance, len(param)) + for idx, inst := range param { + if err := commonExternal.ValidateResult(inst); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + ret[idx] = inst + } + return ret, nil +} + +// RemoveAllInstances will remove all instances created by this provider. +func (e *external) RemoveAllInstances(ctx context.Context, _ common.RemoveAllInstancesParams) error { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.RemoveAllInstancesCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "RemoveAllInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "RemoveAllInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +// Stop shuts down the instance. +func (e *external) Stop(ctx context.Context, instance string, _ common.StopParams) error { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.StopInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "Stop", // label: operation + e.cfg.Name, // label: provider + ).Inc() + _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "Stop", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +// Start boots up an instance. +func (e *external) Start(ctx context.Context, instance string, _ common.StartParams) error { + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.StartInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "Start", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + _, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "Start", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +func (e *external) AsParams() params.Provider { + return params.Provider{ + Name: e.cfg.Name, + Description: e.cfg.Description, + ProviderType: e.cfg.ProviderType, + } +} + +// DisableJITConfig tells us if the provider explicitly disables JIT configuration and +// forces runner registration tokens to be used. This may happen if a provider has not yet +// been updated to support JIT configuration. +func (e *external) DisableJITConfig() bool { + if e.cfg == nil { + return false + } + return e.cfg.DisableJITConfig +} diff --git a/runner/providers/v0.1.1/external.go b/runner/providers/v0.1.1/external.go new file mode 100644 index 00000000..530a2645 --- /dev/null +++ b/runner/providers/v0.1.1/external.go @@ -0,0 +1,386 @@ +package v011 + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "log/slog" + "os/exec" + + "github.com/pkg/errors" + + garmErrors "github.com/cloudbase/garm-provider-common/errors" + commonExecution "github.com/cloudbase/garm-provider-common/execution/common" + commonParams "github.com/cloudbase/garm-provider-common/params" + garmExec "github.com/cloudbase/garm-provider-common/util/exec" + "github.com/cloudbase/garm/config" + "github.com/cloudbase/garm/metrics" + "github.com/cloudbase/garm/params" + "github.com/cloudbase/garm/runner/common" + commonExternal "github.com/cloudbase/garm/runner/providers/common" +) + +var _ common.Provider = (*external)(nil) + +func NewProvider(ctx context.Context, cfg *config.Provider, controllerID string) (common.Provider, error) { + if cfg.ProviderType != params.ExternalProvider { + return nil, garmErrors.NewBadRequestError("invalid provider config") + } + + execPath, err := cfg.External.ExecutablePath() + if err != nil { + return nil, errors.Wrap(err, "fetching executable path") + } + + // Set GARM_INTERFACE_VERSION to the version of the interface that the external + // provider implements. This is used to ensure compatibility between the external + // provider and garm + envVars := cfg.External.GetEnvironmentVariables() + envVars = append(envVars, fmt.Sprintf("GARM_INTERFACE_VERSION=%s", cfg.External.InterfaceVersion)) + + return &external{ + ctx: ctx, + controllerID: controllerID, + cfg: cfg, + execPath: execPath, + environmentVariables: envVars, + }, nil +} + +type external struct { + ctx context.Context + cfg *config.Provider + controllerID string + execPath string + environmentVariables []string +} + +// CreateInstance creates a new compute instance in the provider. +func (e *external) CreateInstance(ctx context.Context, bootstrapParams commonParams.BootstrapInstance, _ common.CreateInstanceParams) (commonParams.ProviderInstance, error) { + extraspecs := bootstrapParams.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return commonParams.ProviderInstance{}, errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.CreateInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_POOL_ID=%s", bootstrapParams.PoolID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + asJs, err := json.Marshal(bootstrapParams) + if err != nil { + return commonParams.ProviderInstance{}, errors.Wrap(err, "serializing bootstrap params") + } + + metrics.InstanceOperationCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + out, err := garmExec.Exec(ctx, e.execPath, asJs, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + if err := commonExternal.ValidateResult(param); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "CreateInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + + retAsJs, _ := json.MarshalIndent(param, "", " ") + slog.DebugContext( + ctx, "provider returned", + "output", string(retAsJs)) + return param, nil +} + +// Delete instance will delete the instance in a provider. +func (e *external) DeleteInstance(ctx context.Context, instance string, deleteInstanceParams common.DeleteInstanceParams) error { + extraspecs := deleteInstanceParams.DeleteInstanceV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.DeleteInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_ID=%s", deleteInstanceParams.DeleteInstanceV011.PoolInfo.ID), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "DeleteInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + _, err = garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + var exitErr *exec.ExitError + if !errors.As(err, &exitErr) || exitErr.ExitCode() != commonExecution.ExitCodeNotFound { + metrics.InstanceOperationFailedCount.WithLabelValues( + "DeleteInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + } + return nil +} + +// GetInstance will return details about one instance. +func (e *external) GetInstance(ctx context.Context, instance string, getInstanceParams common.GetInstanceParams) (commonParams.ProviderInstance, error) { + extraspecs := getInstanceParams.GetInstanceV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return commonParams.ProviderInstance{}, errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.GetInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_ID=%s", getInstanceParams.GetInstanceV011.PoolInfo.ID), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + // nolint:golangci-lint,godox + // TODO(gabriel-samfira): handle error types. Of particular interest is to + // know when the error is ErrNotFound. + metrics.InstanceOperationCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + if err := commonExternal.ValidateResult(param); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "GetInstance", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + + return param, nil +} + +// ListInstances will list all instances for a provider. +func (e *external) ListInstances(ctx context.Context, poolID string, listInstancesParams common.ListInstancesParams) ([]commonParams.ProviderInstance, error) { + extraspecs := listInstancesParams.ListInstancesV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return []commonParams.ProviderInstance{}, errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.ListInstancesCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_POOL_ID=%s", poolID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + out, err := garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err == nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + + var param []commonParams.ProviderInstance + if err := json.Unmarshal(out, ¶m); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) + } + + ret := make([]commonParams.ProviderInstance, len(param)) + for idx, inst := range param { + if err := commonExternal.ValidateResult(inst); err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "ListInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return []commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to validate result: %s", err) + } + ret[idx] = inst + } + return ret, nil +} + +// RemoveAllInstances will remove all instances created by this provider. +func (e *external) RemoveAllInstances(ctx context.Context, removeAllInstances common.RemoveAllInstancesParams) error { + extraspecs := removeAllInstances.RemoveAllInstancesV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.RemoveAllInstancesCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_ID=%s", removeAllInstances.RemoveAllInstancesV011.PoolInfo.ID), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "RemoveAllInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + _, err = garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "RemoveAllInstances", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +// Stop shuts down the instance. +func (e *external) Stop(ctx context.Context, instance string, stopParams common.StopParams) error { + extraspecs := stopParams.StopV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.StopInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_ID=%s", stopParams.StopV011.PoolInfo.ID), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "Stop", // label: operation + e.cfg.Name, // label: provider + ).Inc() + _, err = garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "Stop", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +// Start boots up an instance. +func (e *external) Start(ctx context.Context, instance string, startParams common.StartParams) error { + extraspecs := startParams.StartV011.PoolInfo.ExtraSpecs + extraspecsValue, err := json.Marshal(extraspecs) + if err != nil { + return errors.Wrap(err, "serializing extraspecs") + } + // Encode the extraspecs as base64 to avoid issues with special characters. + base64EncodedExtraSpecs := base64.StdEncoding.EncodeToString(extraspecsValue) + asEnv := []string{ + fmt.Sprintf("GARM_COMMAND=%s", commonExecution.StartInstanceCommand), + fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID), + fmt.Sprintf("GARM_INSTANCE_ID=%s", instance), + fmt.Sprintf("GARM_PROVIDER_CONFIG_FILE=%s", e.cfg.External.ConfigFile), + fmt.Sprintf("GARM_POOL_ID=%s", startParams.StartV011.PoolInfo.ID), + fmt.Sprintf("GARM_POOL_EXTRASPECS=%s", base64EncodedExtraSpecs), + } + asEnv = append(asEnv, e.environmentVariables...) + + metrics.InstanceOperationCount.WithLabelValues( + "Start", // label: operation + e.cfg.Name, // label: provider + ).Inc() + + _, err = garmExec.Exec(ctx, e.execPath, nil, asEnv) + if err != nil { + metrics.InstanceOperationFailedCount.WithLabelValues( + "Start", // label: operation + e.cfg.Name, // label: provider + ).Inc() + return garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err) + } + return nil +} + +func (e *external) AsParams() params.Provider { + return params.Provider{ + Name: e.cfg.Name, + Description: e.cfg.Description, + ProviderType: e.cfg.ProviderType, + } +} + +// DisableJITConfig tells us if the provider explicitly disables JIT configuration and +// forces runner registration tokens to be used. This may happen if a provider has not yet +// been updated to support JIT configuration. +func (e *external) DisableJITConfig() bool { + if e.cfg == nil { + return false + } + return e.cfg.DisableJITConfig +} diff --git a/vendor/github.com/cloudbase/garm-provider-common/execution/common/commands.go b/vendor/github.com/cloudbase/garm-provider-common/execution/common/commands.go new file mode 100644 index 00000000..c4e3a607 --- /dev/null +++ b/vendor/github.com/cloudbase/garm-provider-common/execution/common/commands.go @@ -0,0 +1,98 @@ +// Copyright 2023 Cloudbase Solutions SRL +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package common + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "os" + + gErrors "github.com/cloudbase/garm-provider-common/errors" + "github.com/cloudbase/garm-provider-common/params" + "github.com/mattn/go-isatty" +) + +type ExecutionCommand string + +const ( + CreateInstanceCommand ExecutionCommand = "CreateInstance" + DeleteInstanceCommand ExecutionCommand = "DeleteInstance" + GetInstanceCommand ExecutionCommand = "GetInstance" + ListInstancesCommand ExecutionCommand = "ListInstances" + StartInstanceCommand ExecutionCommand = "StartInstance" + StopInstanceCommand ExecutionCommand = "StopInstance" + RemoveAllInstancesCommand ExecutionCommand = "RemoveAllInstances" + GetVersionCommand ExecutionCommand = "GetVersion" +) + +// V0.1.1 commands +const ( + ValidatePoolInfoCommand ExecutionCommand = "ValidatePoolInfo" + GetConfigJSONSchemaCommand ExecutionCommand = "GetConfigJSONSchema" + GetExtraSpecsJSONSchemaCommand ExecutionCommand = "GetExtraSpecsJSONSchema" +) + +const ( + // ExitCodeNotFound is an exit code that indicates a Not Found error + ExitCodeNotFound int = 30 + // ExitCodeDuplicate is an exit code that indicates a duplicate error + ExitCodeDuplicate int = 31 +) + +func GetBoostrapParamsFromStdin(c ExecutionCommand) (params.BootstrapInstance, error) { + var bootstrapParams params.BootstrapInstance + if c == CreateInstanceCommand { + if isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) { + return params.BootstrapInstance{}, fmt.Errorf("%s requires data passed into stdin", CreateInstanceCommand) + } + + var data bytes.Buffer + if _, err := io.Copy(&data, os.Stdin); err != nil { + return params.BootstrapInstance{}, fmt.Errorf("failed to copy bootstrap params") + } + + if data.Len() == 0 { + return params.BootstrapInstance{}, fmt.Errorf("%s requires data passed into stdin", CreateInstanceCommand) + } + + if err := json.Unmarshal(data.Bytes(), &bootstrapParams); err != nil { + return params.BootstrapInstance{}, fmt.Errorf("failed to decode instance params: %w", err) + } + if bootstrapParams.ExtraSpecs == nil { + // Initialize ExtraSpecs as an empty JSON object + bootstrapParams.ExtraSpecs = json.RawMessage([]byte("{}")) + } + + return bootstrapParams, nil + } + + // If the command is not CreateInstance, we don't need to read from stdin + return params.BootstrapInstance{}, nil +} + +func ResolveErrorToExitCode(err error) int { + if err != nil { + if errors.Is(err, gErrors.ErrNotFound) { + return ExitCodeNotFound + } else if errors.Is(err, gErrors.ErrDuplicateEntity) { + return ExitCodeDuplicate + } + return 1 + } + return 0 +} diff --git a/vendor/github.com/cloudbase/garm-provider-common/execution/interface.go b/vendor/github.com/cloudbase/garm-provider-common/execution/common/interface.go similarity index 89% rename from vendor/github.com/cloudbase/garm-provider-common/execution/interface.go rename to vendor/github.com/cloudbase/garm-provider-common/execution/common/interface.go index 24e39e09..d00afe92 100644 --- a/vendor/github.com/cloudbase/garm-provider-common/execution/interface.go +++ b/vendor/github.com/cloudbase/garm-provider-common/execution/common/interface.go @@ -12,7 +12,7 @@ // License for the specific language governing permissions and limitations // under the License. -package execution +package common import ( "context" @@ -20,7 +20,7 @@ import ( "github.com/cloudbase/garm-provider-common/params" ) -// ExternalProvider defines an interface that external providers need to implement. +// ExternalProvider defines a common interface that external providers need to implement. // This is very similar to the common.Provider interface, and was redefined here to // decouple it, in case it may diverge from native providers. type ExternalProvider interface { @@ -38,4 +38,6 @@ type ExternalProvider interface { Stop(ctx context.Context, instance string, force bool) error // Start boots up an instance. Start(ctx context.Context, instance string) error + // GetVersion returns the version of the provider. + GetVersion(ctx context.Context) string } diff --git a/vendor/github.com/cloudbase/garm-provider-common/execution/commands.go b/vendor/github.com/cloudbase/garm-provider-common/execution/common/versions.go similarity index 56% rename from vendor/github.com/cloudbase/garm-provider-common/execution/commands.go rename to vendor/github.com/cloudbase/garm-provider-common/execution/common/versions.go index b7976bfb..ebdbbb8c 100644 --- a/vendor/github.com/cloudbase/garm-provider-common/execution/commands.go +++ b/vendor/github.com/cloudbase/garm-provider-common/execution/common/versions.go @@ -12,16 +12,11 @@ // License for the specific language governing permissions and limitations // under the License. -package execution - -type ExecutionCommand string +package common const ( - CreateInstanceCommand ExecutionCommand = "CreateInstance" - DeleteInstanceCommand ExecutionCommand = "DeleteInstance" - GetInstanceCommand ExecutionCommand = "GetInstance" - ListInstancesCommand ExecutionCommand = "ListInstances" - StartInstanceCommand ExecutionCommand = "StartInstance" - StopInstanceCommand ExecutionCommand = "StopInstance" - RemoveAllInstancesCommand ExecutionCommand = "RemoveAllInstances" + // Version v0.1.0 + Version010 = "v0.1.0" + // Version v0.1.1 + Version011 = "v0.1.1" ) diff --git a/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go b/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go deleted file mode 100644 index 948fe3a7..00000000 --- a/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2023 Cloudbase Solutions SRL -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -package execution - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "fmt" - "io" - "os" - - gErrors "github.com/cloudbase/garm-provider-common/errors" - "github.com/cloudbase/garm-provider-common/params" - - "github.com/mattn/go-isatty" -) - -const ( - // ExitCodeNotFound is an exit code that indicates a Not Found error - ExitCodeNotFound int = 30 - // ExitCodeDuplicate is an exit code that indicates a duplicate error - ExitCodeDuplicate int = 31 -) - -func ResolveErrorToExitCode(err error) int { - if err != nil { - if errors.Is(err, gErrors.ErrNotFound) { - return ExitCodeNotFound - } else if errors.Is(err, gErrors.ErrDuplicateEntity) { - return ExitCodeDuplicate - } - return 1 - } - return 0 -} - -func GetEnvironment() (Environment, error) { - env := Environment{ - Command: ExecutionCommand(os.Getenv("GARM_COMMAND")), - ControllerID: os.Getenv("GARM_CONTROLLER_ID"), - PoolID: os.Getenv("GARM_POOL_ID"), - ProviderConfigFile: os.Getenv("GARM_PROVIDER_CONFIG_FILE"), - InstanceID: os.Getenv("GARM_INSTANCE_ID"), - } - - // If this is a CreateInstance command, we need to get the bootstrap params - // from stdin - if env.Command == CreateInstanceCommand { - if isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) { - return Environment{}, fmt.Errorf("%s requires data passed into stdin", CreateInstanceCommand) - } - - var data bytes.Buffer - if _, err := io.Copy(&data, os.Stdin); err != nil { - return Environment{}, fmt.Errorf("failed to copy bootstrap params") - } - - if data.Len() == 0 { - return Environment{}, fmt.Errorf("%s requires data passed into stdin", CreateInstanceCommand) - } - - var bootstrapParams params.BootstrapInstance - if err := json.Unmarshal(data.Bytes(), &bootstrapParams); err != nil { - return Environment{}, fmt.Errorf("failed to decode instance params: %w", err) - } - if bootstrapParams.ExtraSpecs == nil { - // Initialize ExtraSpecs as an empty JSON object - bootstrapParams.ExtraSpecs = json.RawMessage([]byte("{}")) - } - env.BootstrapParams = bootstrapParams - } - - if err := env.Validate(); err != nil { - return Environment{}, fmt.Errorf("failed to validate execution environment: %w", err) - } - - return env, nil -} - -type Environment struct { - Command ExecutionCommand - ControllerID string - PoolID string - ProviderConfigFile string - InstanceID string - BootstrapParams params.BootstrapInstance -} - -func (e Environment) Validate() error { - if e.Command == "" { - return fmt.Errorf("missing GARM_COMMAND") - } - - if e.ProviderConfigFile == "" { - return fmt.Errorf("missing GARM_PROVIDER_CONFIG_FILE") - } - - if _, err := os.Lstat(e.ProviderConfigFile); err != nil { - return fmt.Errorf("error accessing config file: %w", err) - } - - if e.ControllerID == "" { - return fmt.Errorf("missing GARM_CONTROLLER_ID") - } - - switch e.Command { - case CreateInstanceCommand: - if e.BootstrapParams.Name == "" { - return fmt.Errorf("missing bootstrap params") - } - if e.ControllerID == "" { - return fmt.Errorf("missing controller ID") - } - if e.PoolID == "" { - return fmt.Errorf("missing pool ID") - } - case DeleteInstanceCommand, GetInstanceCommand, - StartInstanceCommand, StopInstanceCommand: - if e.InstanceID == "" { - return fmt.Errorf("missing instance ID") - } - case ListInstancesCommand: - if e.PoolID == "" { - return fmt.Errorf("missing pool ID") - } - case RemoveAllInstancesCommand: - if e.ControllerID == "" { - return fmt.Errorf("missing controller ID") - } - default: - return fmt.Errorf("unknown GARM_COMMAND: %s", e.Command) - } - return nil -} - -func Run(ctx context.Context, provider ExternalProvider, env Environment) (string, error) { - var ret string - switch env.Command { - case CreateInstanceCommand: - instance, err := provider.CreateInstance(ctx, env.BootstrapParams) - if err != nil { - return "", fmt.Errorf("failed to create instance in provider: %w", err) - } - - asJs, err := json.Marshal(instance) - if err != nil { - return "", fmt.Errorf("failed to marshal response: %w", err) - } - ret = string(asJs) - case GetInstanceCommand: - instance, err := provider.GetInstance(ctx, env.InstanceID) - if err != nil { - return "", fmt.Errorf("failed to get instance from provider: %w", err) - } - asJs, err := json.Marshal(instance) - if err != nil { - return "", fmt.Errorf("failed to marshal response: %w", err) - } - ret = string(asJs) - case ListInstancesCommand: - instances, err := provider.ListInstances(ctx, env.PoolID) - if err != nil { - return "", fmt.Errorf("failed to list instances from provider: %w", err) - } - asJs, err := json.Marshal(instances) - if err != nil { - return "", fmt.Errorf("failed to marshal response: %w", err) - } - ret = string(asJs) - case DeleteInstanceCommand: - if err := provider.DeleteInstance(ctx, env.InstanceID); err != nil { - return "", fmt.Errorf("failed to delete instance from provider: %w", err) - } - case RemoveAllInstancesCommand: - if err := provider.RemoveAllInstances(ctx); err != nil { - return "", fmt.Errorf("failed to destroy environment: %w", err) - } - case StartInstanceCommand: - if err := provider.Start(ctx, env.InstanceID); err != nil { - return "", fmt.Errorf("failed to start instance: %w", err) - } - case StopInstanceCommand: - if err := provider.Stop(ctx, env.InstanceID, true); err != nil { - return "", fmt.Errorf("failed to stop instance: %w", err) - } - default: - return "", fmt.Errorf("invalid command: %s", env.Command) - } - return ret, nil -} diff --git a/vendor/golang.org/x/crypto/LICENSE b/vendor/golang.org/x/crypto/LICENSE index 6a66aea5..2a7cf70d 100644 --- a/vendor/golang.org/x/crypto/LICENSE +++ b/vendor/golang.org/x/crypto/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE index 6a66aea5..2a7cf70d 100644 --- a/vendor/golang.org/x/net/LICENSE +++ b/vendor/golang.org/x/net/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE index 6a66aea5..2a7cf70d 100644 --- a/vendor/golang.org/x/sys/LICENSE +++ b/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa..ec07aab0 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e..af2aa99f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0f..08f35ea1 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488..d07dd09e 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b005..2d15200a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e262..3f1d3d4c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c7..b86ded54 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa852..4308ac17 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c..c8068a7a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b4..01a70b24 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd5..684a5168 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317af..61d74b59 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668a..a28c9e3e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508..ab5d1fe8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afd..c523090e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92c..01e6ea78 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba..7aa610b1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0..92af771b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e..b27ef5e6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3..237a2cef 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa728..4a5c555a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e0150..a02fb49a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e..e26a7c61 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214..c48f7c21 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d9..ad4b9aac 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c30..b622533e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb..cfe6646b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda6..13f624f6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 05770011..fe222b75 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a..1bc1a5ad 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410..1851df14 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b56173..0b43c693 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751..e1ec0dbe 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656..880c6d6e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776..7c8452a6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f..b8ef95b0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d07..2ffdf861 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d5321..2af3b5c7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e6..1da08d52 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b6..b7a25135 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354..6e85b0aa 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff0..f15dadf0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed5..28b487df 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a..1e7f321e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc..524b0820 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d52476..d3e38f68 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c7477061..70b35bf3 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f..6c778c23 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346..37281cf5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018..7e567f1e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b..38ae55e5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca..55e92e60 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c3..60658d6a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc4..e203e8a7 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b..5944b97d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e1635..c66d416d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9..9889f6a5 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad..01d86825 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d7..7b703e77 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b834..7f1961b9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5b..b6e1ab76 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f..1fa34fd1 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db..3f03b3d5 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba76101..9bb979a3 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/vendor/modules.txt b/vendor/modules.txt index 8380b1d6..6385761b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,11 +21,11 @@ github.com/cespare/xxhash/v2 # github.com/chzyer/readline v1.5.1 ## explicit; go 1.15 github.com/chzyer/readline -# github.com/cloudbase/garm-provider-common v0.1.3 +# github.com/cloudbase/garm-provider-common v0.1.4-0.20240821093055-dfdf8e2e4853 ## explicit; go 1.22 github.com/cloudbase/garm-provider-common/defaults github.com/cloudbase/garm-provider-common/errors -github.com/cloudbase/garm-provider-common/execution +github.com/cloudbase/garm-provider-common/execution/common github.com/cloudbase/garm-provider-common/params github.com/cloudbase/garm-provider-common/util github.com/cloudbase/garm-provider-common/util/exec @@ -267,7 +267,7 @@ go.opentelemetry.io/otel/metric/embedded ## explicit; go 1.21 go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded -# golang.org/x/crypto v0.25.0 +# golang.org/x/crypto v0.26.0 ## explicit; go 1.20 golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish @@ -276,7 +276,7 @@ golang.org/x/crypto/chacha20poly1305 golang.org/x/crypto/hkdf golang.org/x/crypto/internal/alias golang.org/x/crypto/internal/poly1305 -# golang.org/x/net v0.27.0 +# golang.org/x/net v0.28.0 ## explicit; go 1.18 golang.org/x/net/internal/socks golang.org/x/net/proxy @@ -287,7 +287,7 @@ golang.org/x/oauth2/internal # golang.org/x/sync v0.7.0 ## explicit; go 1.18 golang.org/x/sync/errgroup -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix