forked from streamnative/terraform-provider-pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add source resource (streamnative#41)
* feat: add source resource * fix: add miss dependency * fix: improve the resources fields * test: add acc test for pulsar_source * fix: use online connector * fix: test providers Signed-off-by: Zixuan Liu <[email protected]> Signed-off-by: Max Xu <[email protected]>
- Loading branch information
Showing
11 changed files
with
937 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 bytesize | ||
|
||
const MB = 1 << (10 * 2) | ||
|
||
type byteSize struct { | ||
value uint64 | ||
} | ||
|
||
func newByteSize(n uint64) *byteSize { | ||
return &byteSize{value: n} | ||
} | ||
|
||
func FormBytes(n uint64) *byteSize { | ||
return newByteSize(n) | ||
} | ||
|
||
func FormMegaBytes(n uint64) *byteSize { | ||
return newByteSize(n * MB) | ||
} | ||
|
||
func (b *byteSize) ToBytes() uint64 { | ||
return b.value | ||
} | ||
|
||
func (b *byteSize) ToMegaBytes() uint64 { | ||
return b.value / MB | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 bytesize | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFormBytes(t *testing.T) { | ||
testcases := make(map[uint64]uint64) | ||
testcases[1] = 1 * 1024 * 1024 | ||
testcases[2] = 2 * 1024 * 1024 | ||
testcases[10] = 10 * 1024 * 1024 | ||
testcases[20] = 20 * 1024 * 1024 | ||
|
||
for mb, bytes := range testcases { | ||
b := FormBytes(bytes) | ||
assert.Equal(t, bytes, b.ToBytes()) | ||
assert.Equal(t, mb, b.ToMegaBytes()) | ||
} | ||
} | ||
|
||
func TestFormMegaBytes(t *testing.T) { | ||
testcases := make(map[uint64]uint64) | ||
testcases[1] = 1 * 1024 * 1024 | ||
testcases[2] = 2 * 1024 * 1024 | ||
testcases[10] = 10 * 1024 * 1024 | ||
testcases[20] = 20 * 1024 * 1024 | ||
|
||
for mb, bytes := range testcases { | ||
b := FormMegaBytes(mb) | ||
assert.Equal(t, bytes, b.ToBytes()) | ||
assert.Equal(t, mb, b.ToMegaBytes()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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. | ||
|
||
terraform { | ||
required_providers { | ||
pulsar = { | ||
version = "1.0.0" | ||
source = "registry.terraform.io/apache/pulsar" | ||
} | ||
} | ||
} | ||
|
||
provider "pulsar" { | ||
web_service_url = "http://localhost:8080" | ||
api_version = "3" | ||
} | ||
|
||
resource "pulsar_source" "source-1" { | ||
provider = pulsar | ||
|
||
name = "source-1" | ||
tenant = "public" | ||
namespace = "default" | ||
|
||
archive = "https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-2.8.1/connectors/pulsar-io-file-2.8.1.nar" | ||
|
||
destination_topic_name = "source-1-topic" | ||
|
||
processing_guarantees = "EFFECTIVELY_ONCE" | ||
|
||
configs = "{\"inputDirectory\":\"opt\"}" | ||
|
||
cpu = 2 | ||
disk_mb = 20480 | ||
ram_mb = 2048 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.